From: Douglas Bagnall Date: Wed, 17 Aug 2022 23:53:29 +0000 (+1200) Subject: samba-tool ldapcmp: use CommandError on auth failure X-Git-Tag: talloc-2.4.0~1158 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2cdafb943121db8df843c0ca1b12e87f2058cbf2;p=thirdparty%2Fsamba.git samba-tool ldapcmp: use CommandError on auth failure Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py index 5118e65ca98..fb49cbe1ae5 100644 --- a/python/samba/netcmd/ldapcmp.py +++ b/python/samba/netcmd/ldapcmp.py @@ -108,8 +108,13 @@ class LDAPBase(object): return [str(x["cn"][0]) for x in res] def find_netbios(self): - res = self.ldb.search(base="CN=Partitions,%s" % self.config_dn, - scope=SCOPE_SUBTREE, attrs=["nETBIOSName"]) + try: + res = self.ldb.search(base="CN=Partitions,%s" % self.config_dn, + scope=SCOPE_SUBTREE, attrs=["nETBIOSName"]) + except LdbError as e: + enum, estr = e + if estr in ["Operation unavailable without authentication"]: + raise CommandError(estr, e) if len(res) == 0: raise CommandError("Could not find netbios name")