mirror of
https://github.com/samba-team/samba.git
synced 2025-01-21 18:04:06 +03:00
netcmd: delegation: don't use assert but raise CommandError
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
This commit is contained in:
parent
6d7ad27865
commit
9ca05ec28c
@ -159,7 +159,8 @@ class cmd_delegation_show(Command):
|
|||||||
"msDS-AllowedToActOnBehalfOfOtherIdentity"])
|
"msDS-AllowedToActOnBehalfOfOtherIdentity"])
|
||||||
if len(res) == 0:
|
if len(res) == 0:
|
||||||
raise CommandError("Unable to find account name '%s'" % accountname)
|
raise CommandError("Unable to find account name '%s'" % accountname)
|
||||||
assert(len(res) == 1)
|
elif len(res) != 1:
|
||||||
|
raise CommandError("Found multiple accounts.")
|
||||||
|
|
||||||
uac = int(res[0].get("userAccountControl")[0])
|
uac = int(res[0].get("userAccountControl")[0])
|
||||||
allowed = res[0].get("msDS-AllowedToDelegateTo")
|
allowed = res[0].get("msDS-AllowedToDelegateTo")
|
||||||
@ -335,7 +336,8 @@ class cmd_delegation_add_service(Command):
|
|||||||
attrs=["msDS-AllowedToDelegateTo"])
|
attrs=["msDS-AllowedToDelegateTo"])
|
||||||
if len(res) == 0:
|
if len(res) == 0:
|
||||||
raise CommandError("Unable to find account name '%s'" % accountname)
|
raise CommandError("Unable to find account name '%s'" % accountname)
|
||||||
assert(len(res) == 1)
|
elif len(res) != 1:
|
||||||
|
raise CommandError("Found multiple accounts.")
|
||||||
|
|
||||||
msg = ldb.Message()
|
msg = ldb.Message()
|
||||||
msg.dn = res[0].dn
|
msg.dn = res[0].dn
|
||||||
@ -390,7 +392,8 @@ class cmd_delegation_del_service(Command):
|
|||||||
attrs=["msDS-AllowedToDelegateTo"])
|
attrs=["msDS-AllowedToDelegateTo"])
|
||||||
if len(res) == 0:
|
if len(res) == 0:
|
||||||
raise CommandError("Unable to find account name '%s'" % accountname)
|
raise CommandError("Unable to find account name '%s'" % accountname)
|
||||||
assert(len(res) == 1)
|
elif len(res) != 1:
|
||||||
|
raise CommandError("Found multiple accounts.")
|
||||||
|
|
||||||
msg = ldb.Message()
|
msg = ldb.Message()
|
||||||
msg.dn = res[0].dn
|
msg.dn = res[0].dn
|
||||||
@ -445,7 +448,8 @@ class cmd_delegation_add_principal(Command):
|
|||||||
attrs=["msDS-AllowedToActOnBehalfOfOtherIdentity"])
|
attrs=["msDS-AllowedToActOnBehalfOfOtherIdentity"])
|
||||||
if len(account_res) == 0:
|
if len(account_res) == 0:
|
||||||
raise CommandError(f"Unable to find account name '{accountname}'")
|
raise CommandError(f"Unable to find account name '{accountname}'")
|
||||||
assert(len(account_res) == 1)
|
elif len(account_res) != 1:
|
||||||
|
raise CommandError("Found multiple accounts.")
|
||||||
|
|
||||||
data = account_res[0].get(
|
data = account_res[0].get(
|
||||||
"msDS-AllowedToActOnBehalfOfOtherIdentity", idx=0)
|
"msDS-AllowedToActOnBehalfOfOtherIdentity", idx=0)
|
||||||
@ -487,7 +491,8 @@ class cmd_delegation_add_principal(Command):
|
|||||||
attrs=["objectSid"])
|
attrs=["objectSid"])
|
||||||
if len(princ_res) == 0:
|
if len(princ_res) == 0:
|
||||||
raise CommandError(f"Unable to find principal name '{principal}'")
|
raise CommandError(f"Unable to find principal name '{principal}'")
|
||||||
assert(len(princ_res) == 1)
|
elif len(princ_res) != 1:
|
||||||
|
raise CommandError("Found multiple accounts.")
|
||||||
|
|
||||||
princ_sid = security.dom_sid(
|
princ_sid = security.dom_sid(
|
||||||
sam.schema_format_value(
|
sam.schema_format_value(
|
||||||
@ -588,7 +593,8 @@ class cmd_delegation_del_principal(Command):
|
|||||||
attrs=["msDS-AllowedToActOnBehalfOfOtherIdentity"])
|
attrs=["msDS-AllowedToActOnBehalfOfOtherIdentity"])
|
||||||
if len(account_res) == 0:
|
if len(account_res) == 0:
|
||||||
raise CommandError("Unable to find account name '%s'" % accountname)
|
raise CommandError("Unable to find account name '%s'" % accountname)
|
||||||
assert(len(account_res) == 1)
|
elif len(account_res) != 1:
|
||||||
|
raise CommandError("Found multiple accounts.")
|
||||||
|
|
||||||
data = account_res[0].get(
|
data = account_res[0].get(
|
||||||
"msDS-AllowedToActOnBehalfOfOtherIdentity", idx=0)
|
"msDS-AllowedToActOnBehalfOfOtherIdentity", idx=0)
|
||||||
@ -622,7 +628,8 @@ class cmd_delegation_del_principal(Command):
|
|||||||
attrs=["objectSid"])
|
attrs=["objectSid"])
|
||||||
if len(princ_res) == 0:
|
if len(princ_res) == 0:
|
||||||
raise CommandError(f"Unable to find principal name '{principal}'")
|
raise CommandError(f"Unable to find principal name '{principal}'")
|
||||||
assert(len(princ_res) == 1)
|
elif len(princ_res) != 1:
|
||||||
|
raise CommandError("Found multiple accounts.")
|
||||||
|
|
||||||
princ_sid = security.dom_sid(
|
princ_sid = security.dom_sid(
|
||||||
sam.schema_format_value(
|
sam.schema_format_value(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user