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