diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-08-01 20:47:22 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-08-01 20:47:22 +0200 |
commit | fff006bd84fc3fd1d9fdd22e3c20110285b2c144 (patch) | |
tree | b30fb1c84bc3443c2b6fb3b927509bb85c34ed1e | |
parent | 3b4ff07ded89703b2a58ae2c9ca6f0ea82bb5a52 (diff) | |
download | samba-fff006bd84fc3fd1d9fdd22e3c20110285b2c144.tar.gz samba-fff006bd84fc3fd1d9fdd22e3c20110285b2c144.tar.bz2 samba-fff006bd84fc3fd1d9fdd22e3c20110285b2c144.zip |
Move domain DN determination out of newuser function.
(This used to be commit cbac27e6faa99ebaa3e6d653017c968db836560a)
-rw-r--r-- | source4/scripting/python/samba/samdb.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py index c47cf4a0dc..c7d93d6aff 100644 --- a/source4/scripting/python/samba/samdb.py +++ b/source4/scripting/python/samba/samdb.py @@ -86,6 +86,14 @@ userAccountControl: %u """ % (user_dn, userAccountControl) self.modify_ldif(mod) + def domain_dn(self): + # find the DNs for the domain and the domain users group + res = self.search("", scope=ldb.SCOPE_BASE, + expression="(defaultNamingContext=*)", + attrs=["defaultNamingContext"]) + assert(len(res) == 1 and res[0]["defaultNamingContext"] is not None) + return res[0]["defaultNamingContext"][0] + def newuser(self, username, unixname, password): """add a new user record. @@ -96,12 +104,7 @@ userAccountControl: %u # connect to the sam self.transaction_start() - # find the DNs for the domain and the domain users group - res = self.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] + domain_dn = self.domain_dn() assert(domain_dn is not None) user_dn = "CN=%s,CN=Users,%s" % (username, domain_dn) |