mirror of
https://github.com/samba-team/samba.git
synced 2025-03-20 22:50:26 +03:00
samba-tool: improved user enable error handling
This commit is contained in:
parent
23177b5f44
commit
7b3d8b6c90
@ -108,7 +108,12 @@ class cmd_user_enable(Command):
|
||||
|
||||
samdb = SamDB(url=H, session_info=system_session(),
|
||||
credentials=creds, lp=lp)
|
||||
samdb.enable_account(filter)
|
||||
try:
|
||||
samdb.enable_account(filter)
|
||||
except Exception, msg:
|
||||
raise CommandError("Failed to enable user %s: %s" % (username or filter, msg))
|
||||
print("Enabled user %s" % (username or filter))
|
||||
|
||||
|
||||
class cmd_user_setexpiry(Command):
|
||||
"""Sets the expiration of a user account"""
|
||||
|
@ -79,6 +79,8 @@ class SamDB(samba.Ldb):
|
||||
"""
|
||||
res = self.search(base=self.domain_dn(), scope=ldb.SCOPE_SUBTREE,
|
||||
expression=search_filter, attrs=["userAccountControl"])
|
||||
if len(res) == 0:
|
||||
raise Exception('Unable to find user "%s"' % search_filter)
|
||||
assert(len(res) == 1)
|
||||
user_dn = res[0].dn
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user