1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

samba-tool: Escape username and computername in ldb search filter

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2018-04-06 16:20:22 +12:00
parent 306f5e57f2
commit 0a6c2ac88f
2 changed files with 5 additions and 3 deletions

View 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,

View 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(),