From 88edeec6fc18c6b92910bfcef5f27362dc4b520b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Baumbach?= Date: Wed, 26 Feb 2020 13:39:44 +0100 Subject: [PATCH] samba-tool group listmembers: find group members by groups SID MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit BUG: https://bugzilla.samba.org/show_bug.cgi?id=14296 Signed-off-by: Björn Baumbach Reviewed-by: Andrew Bartlett (cherry picked from commit 1d2e9f27fa9cff55245e45a194f696fc9ca4376d) --- python/samba/netcmd/group.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py index 7f51c8e0d27..e3116ee71c4 100644 --- a/python/samba/netcmd/group.py +++ b/python/samba/netcmd/group.py @@ -521,15 +521,16 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com res = samdb.search(samdb.domain_dn(), scope=ldb.SCOPE_SUBTREE, expression=(search_filter), attrs=["objectSid"]) - group_dn = res[0].get('dn', idx=0) - object_sid = res[0].get('objectSid', idx=0) + group_sid_binary = res[0].get('objectSid', idx=0) except IndexError: raise CommandError('Unable to find group "%s"' % (groupname)) - object_sid = ndr_unpack(security.dom_sid, object_sid) - (group_dom_sid, rid) = object_sid.split() + group_sid = ndr_unpack(security.dom_sid, group_sid_binary) + (group_dom_sid, rid) = group_sid.split() + group_sid_dn = "" % (group_sid) - search_filter = "(|(primaryGroupID=%s)(memberOf=%s))" % (rid, group_dn) + search_filter = ("(|(primaryGroupID=%s)(memberOf=%s))" % + (rid, group_sid_dn)) res = samdb.search(samdb.domain_dn(), scope=ldb.SCOPE_SUBTREE, expression=(search_filter), attrs=["samAccountName", "cn"]) -- 2.11.4.GIT