s4:python tools - Centralise the lookups for the default domain (root) in the call...
[metze/samba/wip.git] / source4 / setup / enableaccount
index 1b7341946f9c63e099f1b2be2f2f545a235d5734..d4e954074b13cdfe01b5ba4b876b0ad0d1f91ddf 100755 (executable)
@@ -56,14 +56,9 @@ else:
 samdb = SamDB(url=url, session_info=system_session(), 
               credentials=creds, lp=lp)
 
-if opts.base is None:
-       res = samdb.search("", scope=ldb.SCOPE_BASE, 
-                         expression="(defaultNamingContext=*)", 
-                         attrs=["defaultNamingContext"])
-       assert(len(res) == 1 and res[0]["defaultNamingContext"] is not None)
-       domain_dn = res[0]["defaultNamingContext"][0]
-else:
-       domain_dn = opts.base
+domain_dn = opts.base
+if domain_dn is None:
+        domain_dn = SamDB.domain_dn(samdb)
 
 filter = "(&(objectClass=user)(samAccountName=%s))" % username