diff options
author | Stefan Metzmacher <metze@samba.org> | 2012-11-29 09:31:12 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2012-12-03 08:46:25 +0100 |
commit | a1a525e2a9b0bc20e3e06695fbcbdf0d172839a1 (patch) | |
tree | 55a3b071ccab75615d9031de3438ad20e2a3c433 /source4/scripting/python | |
parent | a42c49c93acb9e480b6e174f56fb75ae0524b984 (diff) | |
download | samba-a1a525e2a9b0bc20e3e06695fbcbdf0d172839a1.tar.gz samba-a1a525e2a9b0bc20e3e06695fbcbdf0d172839a1.tar.bz2 samba-a1a525e2a9b0bc20e3e06695fbcbdf0d172839a1.zip |
s4:samba-tool/gpo: use the dns_domain from the server when creating gpos
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source4/scripting/python')
-rw-r--r-- | source4/scripting/python/samba/netcmd/gpo.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/source4/scripting/python/samba/netcmd/gpo.py b/source4/scripting/python/samba/netcmd/gpo.py index cc6381990b..5169085635 100644 --- a/source4/scripting/python/samba/netcmd/gpo.py +++ b/source4/scripting/python/samba/netcmd/gpo.py @@ -42,6 +42,8 @@ from samba import policy from samba import smb import uuid from samba.ntacls import dsacl2fsacl +from samba.dcerpc import nbt +from samba.net import Net def samdb_connect(ctx): @@ -892,12 +894,22 @@ class cmd_create(Command): self.lp = sambaopts.get_loadparm() self.creds = credopts.get_credentials(self.lp, fallback_machine=True) + net = Net(creds=self.creds, lp=self.lp) + # We need to know writable DC to setup SMB connection if H and H.startswith('ldap://'): dc_hostname = H[7:] self.url = H + flags = (nbt.NBT_SERVER_LDAP | + nbt.NBT_SERVER_DS | + nbt.NBT_SERVER_WRITABLE) + cldap_ret = net.finddc(address=dc_hostname, flags=flags) else: - dc_hostname = netcmd_finddc(self.lp, self.creds) + flags = (nbt.NBT_SERVER_LDAP | + nbt.NBT_SERVER_DS | + nbt.NBT_SERVER_WRITABLE) + cldap_ret = net.finddc(domain=self.lp.get('realm'), flags=flags) + dc_hostname = cldap_ret.pdc_dns_name self.url = dc_url(self.lp, self.creds, dc=dc_hostname) samdb_connect(self) @@ -909,7 +921,7 @@ class cmd_create(Command): # Create new GUID guid = str(uuid.uuid4()) gpo = "{%s}" % guid.upper() - realm = self.lp.get('realm') + realm = cldap_ret.dns_domain unc_path = "\\\\%s\\sysvol\\%s\\Policies\\%s" % (realm, realm, gpo) # Create GPT |