1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-31 20:22:15 +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:
Björn Baumbach
2020-02-26 13:08:43 +01:00
committed by Andrew Bartlett
parent 789d84c0a9
commit 40e498e743

View File

@ -517,15 +517,14 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com
credentials=creds, lp=lp)
search_filter = "(&(objectClass=group)(samaccountname=%s))" % groupname
res = samdb.search(samdb.domain_dn(), scope=ldb.SCOPE_SUBTREE,
expression=(search_filter),
attrs=["objectSid"])
if (len(res) != 1):
return
group_dn = res[0].get('dn', idx=0)
object_sid = res[0].get('objectSid', idx=0)
try:
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)
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()