join: Avoid searching for more than strictly required during sanity check
authorAndrew Bartlett <abartlet@samba.org>
Thu, 18 Oct 2018 03:50:19 +0000 (16:50 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 18 Oct 2018 04:15:24 +0000 (06:15 +0200)
We check for the default base DN as this does require authentication, but
we do not need to search for more than just that (so use SCOPE_BASE) and
we need no attributes, so ask for none

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/join.py

index 6a9c3b9807ffb60e292f5521a69dddf2815521ce..75106ff52fa61576641e1cf157942678e4010dd5 100644 (file)
@@ -112,9 +112,9 @@ class DCJoinContext(object):
             ctx.site = DEFAULTSITE
 
         try:
-            ctx.samdb.search(scope=ldb.SCOPE_ONELEVEL, attrs=["dn"])
-        except ldb.LdbError as e4:
-            (enum, estr) = e4.args
+            ctx.samdb.search(scope=ldb.SCOPE_BASE, attrs=[])
+        except ldb.LdbError as e:
+            (enum, estr) = e.args
             raise DCJoinException(estr)
 
         ctx.base_dn = str(ctx.samdb.get_default_basedn())