From: Douglas Bagnall Date: Sun, 3 Mar 2024 21:43:17 +0000 (+1300) Subject: samba-tool: tidy up uncaught insufficient rights LdbError X-Git-Tag: tdb-1.4.11~1529 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccfa16e2ec48da4ab601ca6b8b0ccfc77d625085;p=thirdparty%2Fsamba.git samba-tool: tidy up uncaught insufficient rights LdbError It is likely that many sub-commands will produce a traceback when people go `-H ldap://server -Ubob` when they needed to go `-UAdministrator`. We can catch these and show only the core message. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/netcmd/__init__.py b/python/samba/netcmd/__init__.py index 3e1f1c45aef..7d743526207 100644 --- a/python/samba/netcmd/__init__.py +++ b/python/samba/netcmd/__init__.py @@ -23,7 +23,7 @@ import textwrap import traceback import samba -from ldb import ERR_INVALID_CREDENTIALS, LdbError +from ldb import ERR_INVALID_CREDENTIALS, ERR_INSUFFICIENT_ACCESS_RIGHTS, LdbError from samba import colour from samba.auth import system_session from samba.getopt import Option, OptionParser @@ -242,6 +242,9 @@ class Command(object): elif ldb_emsg.startswith("Unable to open tdb "): self._print_error(message, ldb_emsg, 'ldb') force_traceback = False + elif ldb_ecode == ERR_INSUFFICIENT_ACCESS_RIGHTS: + self._print_error("User has insufficient access rights") + force_traceback = False else: self._print_error(message, ldb_emsg, 'ldb')