]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool ldapcmp: use CommandError on auth failure
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 17 Aug 2022 23:53:29 +0000 (11:53 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Tue, 6 Sep 2022 21:12:36 +0000 (21:12 +0000)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/netcmd/ldapcmp.py

index 5118e65ca98778c4b6b5b00ec18de0992de44d91..fb49cbe1ae546efe8e7df2963928a705d8f11928 100644 (file)
@@ -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")