summaryrefslogtreecommitdiff
path: root/python/samba/samdb.py
diff options
context:
space:
mode:
authorJoe Guo <joeg@catalyst.net.nz>2018-03-13 16:47:58 +1300
committerAndrew Bartlett <abartlet@samba.org>2018-04-06 06:29:10 +0200
commite41b9b04e23f0e8831ff922d247b737bf8116151 (patch)
treee9cba4c6c816e66fb365fcc41ec156b90fe22721 /python/samba/samdb.py
parent6e4a49e992a9b3b3dc5e96896c934abcb6ee6b4e (diff)
downloadsamba-e41b9b04e23f0e8831ff922d247b737bf8116151.tar.gz
samba-tool: improve computer management commands
This pathch is based on Björn Baumbach's work: 1. Add `--ip-address` option for create subcommand, to allow user set DNS A or AAAA records while creating the computer. 2. Delete above DNS records while deleting the computer. 3. Add `--service-principal-name` option for create command, to allow user set `servicePrincipalName` while creating the computer. 4. Tests. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'python/samba/samdb.py')
-rw-r--r--python/samba/samdb.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/python/samba/samdb.py b/python/samba/samdb.py
index 63266328189..b66afb7431c 100644
--- a/python/samba/samdb.py
+++ b/python/samba/samdb.py
@@ -491,13 +491,16 @@ member: %s
self.transaction_commit()
def newcomputer(self, computername, computerou=None, description=None,
- prepare_oldjoin=False):
+ prepare_oldjoin=False, ip_address_list=None,
+ service_principal_name_list=None):
"""Adds a new user with additional parameters
:param computername: Name of the new computer
:param computerou: Object container for new computer
:param description: Description of the new computer
:param prepare_oldjoin: Preset computer password for oldjoin mechanism
+ :param ip_address_list: ip address list for DNS A or AAAA record
+ :param service_principal_name_list: string list of servicePincipalName
"""
cn = re.sub(r"\$$", "", computername)
@@ -511,8 +514,6 @@ member: %s
computer_dn = "CN=%s,%s" % (cn, computercontainer_dn)
- dnsdomain = ldb.Dn(self,
- self.domain_dn()).canonical_str().replace("/", "")
ldbmessage = {"dn": computer_dn,
"sAMAccountName": samaccountname,
"objectClass": "computer",
@@ -521,12 +522,19 @@ member: %s
if description is not None:
ldbmessage["description"] = description
+ if service_principal_name_list:
+ ldbmessage["servicePrincipalName"] = service_principal_name_list
+
accountcontrol = str(dsdb.UF_WORKSTATION_TRUST_ACCOUNT |
dsdb.UF_ACCOUNTDISABLE)
if prepare_oldjoin:
accountcontrol = str(dsdb.UF_WORKSTATION_TRUST_ACCOUNT)
ldbmessage["userAccountControl"] = accountcontrol
+ if ip_address_list:
+ ldbmessage['dNSHostName'] = '{}.{}'.format(
+ cn, self.domain_dns_name())
+
self.transaction_start()
try:
self.add(ldbmessage)