1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

samba-tool: Use same method for removing trailing $ as elsewhere in the tool

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Apr  6 09:30:14 CEST 2018 on sn-devel-144
This commit is contained in:
Andrew Bartlett 2018-04-06 16:21:15 +12:00
parent 0a6c2ac88f
commit 95cad5cab3

View File

@ -24,6 +24,7 @@ import samba.getopt as options
import ldb
import socket
import samba
import re
from samba import sd_utils
from samba.dcerpc import dnsserver, dnsp, security
from samba.dnsserver import ARecord, AAAARecord
@ -266,8 +267,13 @@ Example3 shows how to create a new computer in the OrgUnit organizational unit.
if ip_address_list:
# if ip_address_list provided, then we need to create DNS
# records for this computer.
hostname = re.sub(r"\$$", "", computername)
if hostname.count('$'):
raise CommandError('Illegal computername "%s"' % computername)
filters = '(&(sAMAccountName={}$)(objectclass=computer))'.format(
ldb.binary_encode(computername.rstrip('$')))
ldb.binary_encode(hostname))
recs = samdb.search(
base=samdb.domain_dn(),
@ -289,7 +295,7 @@ Example3 shows how to create a new computer in the OrgUnit organizational unit.
)
add_dns_records(
samdb, computername.rstrip('$'), dns_conn,
samdb, hostname, dns_conn,
change_owner_sd, samdb.host_dns_name(),
ip_address_list, self.get_logger())
except Exception, e: