samba-tool group listmembers: use binary encoded group names
authorBjörn Baumbach <bb@sernet.de>
Wed, 26 Feb 2020 12:38:50 +0000 (13:38 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 28 Feb 2020 03:08:45 +0000 (03:08 +0000)
Allows to find groups with names like e.g. 'group1 (xy)'.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14296

Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/netcmd/group.py

index e3116ee71c4c49c9331c36d01c31c614cc6782b5..c56eb2d335413356a6b53c4d3edd8ae7daf7c021 100644 (file)
@@ -516,7 +516,8 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com
             samdb = SamDB(url=H, session_info=system_session(),
                           credentials=creds, lp=lp)
 
-            search_filter = "(&(objectClass=group)(samaccountname=%s))" % groupname
+            search_filter = ("(&(objectClass=group)(sAMAccountName=%s))" %
+                             ldb.binary_encode(groupname))
             try:
                 res = samdb.search(samdb.domain_dn(), scope=ldb.SCOPE_SUBTREE,
                                    expression=(search_filter),