s4:python tools - Centralise the lookups for the default domain (root) in the call...
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Mon, 17 Aug 2009 09:47:53 +0000 (11:47 +0200)
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Mon, 17 Aug 2009 09:58:39 +0000 (11:58 +0200)
source4/setup/enableaccount
source4/setup/pwsettings

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
 
index a2708531a15601ab82633b26d6bd0bf75c6be4a5..fc59f8c4041c565a70fc894efa5b1d03f875e57e 100755 (executable)
@@ -64,14 +64,10 @@ else:
 samdb = SamDB(url=url, session_info=system_session(),
               credentials=creds, lp=lp)
 
-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]
-
-res = samdb.search(domain_dn, scope=ldb.SCOPE_BASE, attrs=["pwdProperties",
-  "pwdHistoryLength", "minPwdLength", "minPwdAge", "maxPwdAge"])
+domain_dn = SamDB.domain_dn(samdb)
+res = samdb.search(domain_dn, scope=ldb.SCOPE_BASE,
+  attrs=["pwdProperties", "pwdHistoryLength", "minPwdLength", "minPwdAge",
+  "maxPwdAge"])
 assert(len(res) == 1)
 try:
        pwd_props = int(res[0]["pwdProperties"][0])