mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
samba-tool group listmembers: handle group-does-not-exist error
Return a error with a proper message instead of just do nothing when the target group does not exist. 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>
This commit is contained in:
committed by
Andrew Bartlett
parent
789d84c0a9
commit
40e498e743
@ -517,15 +517,14 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com
|
|||||||
credentials=creds, lp=lp)
|
credentials=creds, lp=lp)
|
||||||
|
|
||||||
search_filter = "(&(objectClass=group)(samaccountname=%s))" % groupname
|
search_filter = "(&(objectClass=group)(samaccountname=%s))" % groupname
|
||||||
res = samdb.search(samdb.domain_dn(), scope=ldb.SCOPE_SUBTREE,
|
try:
|
||||||
expression=(search_filter),
|
res = samdb.search(samdb.domain_dn(), scope=ldb.SCOPE_SUBTREE,
|
||||||
attrs=["objectSid"])
|
expression=(search_filter),
|
||||||
|
attrs=["objectSid"])
|
||||||
if (len(res) != 1):
|
group_dn = res[0].get('dn', idx=0)
|
||||||
return
|
object_sid = res[0].get('objectSid', idx=0)
|
||||||
|
except IndexError:
|
||||||
group_dn = res[0].get('dn', idx=0)
|
raise CommandError('Unable to find group "%s"' % (groupname))
|
||||||
object_sid = res[0].get('objectSid', idx=0)
|
|
||||||
|
|
||||||
object_sid = ndr_unpack(security.dom_sid, object_sid)
|
object_sid = ndr_unpack(security.dom_sid, object_sid)
|
||||||
(group_dom_sid, rid) = object_sid.split()
|
(group_dom_sid, rid) = object_sid.split()
|
||||||
|
Reference in New Issue
Block a user