]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool: Escape username and computername in ldb search filter
authorAndrew Bartlett <abartlet@samba.org>
Fri, 6 Apr 2018 04:20:22 +0000 (16:20 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 6 Apr 2018 04:29:10 +0000 (06:29 +0200)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/netcmd/computer.py
python/samba/netcmd/user.py

index 17ae581441f462d773f099dbde695c5daccf29c0..8462379e4edabe9531e8c54a8719266b99f6592d 100644 (file)
@@ -360,7 +360,8 @@ sudo is used so a computer may run the command as root.
             samaccountname = "%s$" % computername
 
         filter = ("(&(sAMAccountName=%s)(sAMAccountType=%u))" %
-                  (samaccountname, dsdb.ATYPE_WORKSTATION_TRUST))
+                  (ldb.binary_encode(samaccountname),
+                   dsdb.ATYPE_WORKSTATION_TRUST))
         try:
             res = samdb.search(base=samdb.domain_dn(),
                                scope=ldb.SCOPE_SUBTREE,
@@ -544,7 +545,8 @@ class cmd_computer_move(Command):
             samaccountname = "%s$" % computername
 
         filter = ("(&(sAMAccountName=%s)(sAMAccountType=%u))" %
-                  (samaccountname, dsdb.ATYPE_WORKSTATION_TRUST))
+                  (ldb.binary_encode(samaccountname),
+                   dsdb.ATYPE_WORKSTATION_TRUST))
         try:
             res = samdb.search(base=domain_dn,
                                expression=filter,
index 6eebf9276131374323e6354a54903fcd0aed91ab..dfe167d8c7d5fdee49c68391fc59c30039405661 100644 (file)
@@ -440,7 +440,7 @@ Example2 shows how to delete a user in the domain against the local server.   su
                       credentials=creds, lp=lp)
 
         filter = ("(&(sAMAccountName=%s)(sAMAccountType=805306368))" %
-                   username)
+                   ldb.binary_encode(username))
 
         try:
             res = samdb.search(base=samdb.domain_dn(),