diff options
author | Andrew Tridgell <tridge@samba.org> | 2011-07-28 17:14:28 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-07-29 18:17:44 +1000 |
commit | 03f92508ef2ebb4e7790f612e3f833382c691051 (patch) | |
tree | 74c7d7cf500e7861547c620035c68f4c80128a72 /source4/scripting/python/samba/samdb.py | |
parent | 8dda0ef57fa908c94c14d2521ded883ceb253b2f (diff) | |
download | samba-03f92508ef2ebb4e7790f612e3f833382c691051.tar.gz samba-03f92508ef2ebb4e7790f612e3f833382c691051.tar.bz2 samba-03f92508ef2ebb4e7790f612e3f833382c691051.zip |
samba-tool: use ldb.binary_encode() on search expression elements
this allows us to deal with search elements containing characters that
must be escaped in LDAP
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Pair-Programmed-With: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'source4/scripting/python/samba/samdb.py')
-rw-r--r-- | source4/scripting/python/samba/samdb.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py index a7ed1d2c39..6f3953540a 100644 --- a/source4/scripting/python/samba/samdb.py +++ b/source4/scripting/python/samba/samdb.py @@ -189,7 +189,7 @@ pwdLastSet: 0 :param groupname: Name of the target group """ - groupfilter = "(&(sAMAccountName=%s)(objectCategory=%s,%s))" % (groupname, "CN=Group,CN=Schema,CN=Configuration", self.domain_dn()) + groupfilter = "(&(sAMAccountName=%s)(objectCategory=%s,%s))" % (ldb.binary_encode(groupname), "CN=Group,CN=Schema,CN=Configuration", self.domain_dn()) self.transaction_start() try: targetgroup = self.search(base=self.domain_dn(), scope=ldb.SCOPE_SUBTREE, @@ -214,7 +214,8 @@ pwdLastSet: 0 operation """ - groupfilter = "(&(sAMAccountName=%s)(objectCategory=%s,%s))" % (groupname, "CN=Group,CN=Schema,CN=Configuration", self.domain_dn()) + groupfilter = "(&(sAMAccountName=%s)(objectCategory=%s,%s))" % ( + ldb.binary_encode(groupname), "CN=Group,CN=Schema,CN=Configuration", self.domain_dn()) groupmembers = listofmembers.split(',') self.transaction_start() @@ -234,7 +235,8 @@ changetype: modify for member in groupmembers: targetmember = self.search(base=self.domain_dn(), scope=ldb.SCOPE_SUBTREE, - expression="(|(sAMAccountName=%s)(CN=%s))" % (member, member), attrs=[]) + expression="(|(sAMAccountName=%s)(CN=%s))" % ( + ldb.binary_encode(member), ldb.binary_encode(member)), attrs=[]) if len(targetmember) != 1: continue @@ -378,7 +380,7 @@ member: %s # Sets the password for it if setpassword: - self.setpassword("(samAccountName=%s)" % username, password, + self.setpassword("(samAccountName=%s)" % ldb.binary_encode(username), password, force_password_change_at_next_login_req) except Exception: self.transaction_cancel() |