1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-02 00:22:11 +03:00

s4:python tools - Centralise the lookups for the default domain (root) in the call "domain_dn" from SamDB

This commit is contained in:
Matthias Dieter Wallnöfer
2009-08-17 11:47:53 +02:00
parent 0a46fd630e
commit 0a5ea25d21
2 changed files with 7 additions and 16 deletions

View File

@ -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

View File

@ -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])