summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2012-07-03 14:17:48 +1000
committerAmitay Isaacs <amitay@gmail.com>2012-07-03 15:20:42 +1000
commit0365df93e61b44cbdd7270c48495a6b4ac251677 (patch)
tree12a5e11ff0c46e3557081df35873ef5773e8d94c /source4
parenta9c4336733c6e76c129c71901500fb7d305ad45f (diff)
downloadsamba-0365df93e61b44cbdd7270c48495a6b4ac251677.tar.gz
samba-0365df93e61b44cbdd7270c48495a6b4ac251677.tar.bz2
samba-0365df93e61b44cbdd7270c48495a6b4ac251677.zip
samba-tool: gpo: Use utility function dc_url() to set the connection url
In create and fetch subcommands, we also need to know DC hostname. So first find a DC and use DC hostname to construct connection url. If ldap:// url is specified with -H, then use that to construct DC hostname.
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/samba/netcmd/gpo.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/source4/scripting/python/samba/netcmd/gpo.py b/source4/scripting/python/samba/netcmd/gpo.py
index cbddcc5a8d..86c5465bb5 100644
--- a/source4/scripting/python/samba/netcmd/gpo.py
+++ b/source4/scripting/python/samba/netcmd/gpo.py
@@ -672,11 +672,11 @@ class cmd_getinheritance(Command):
def run(self, container_dn, H=None, sambaopts=None, credopts=None,
versionopts=None):
- self.url = H
self.lp = sambaopts.get_loadparm()
-
self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
+ self.url = dc_url(self.lp, self.creds, H)
+
samdb_connect(self)
try:
@@ -723,13 +723,12 @@ class cmd_setinheritance(Command):
else:
raise CommandError("Unknown inheritance state (%s)" % inherit_state)
- self.url = H
self.lp = sambaopts.get_loadparm()
-
self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
- samdb_connect(self)
+ self.url = dc_url(self.lp, self.creds, H)
+ samdb_connect(self)
try:
msg = self.samdb.search(base=container_dn, scope=ldb.SCOPE_BASE,
expression="(objectClass=*)",
@@ -774,8 +773,13 @@ class cmd_fetch(Command):
self.lp = sambaopts.get_loadparm()
self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
- dc_hostname = netcmd_finddc(self.lp, self.creds)
- self.url = dc_url(self.lp, self.creds, H, dc=dc_hostname)
+ # We need to know writable DC to setup SMB connection
+ if H and H.startswith('ldap://'):
+ dc_hostname = H[7:]
+ self.url = H
+ else:
+ dc_hostname = netcmd_finddc(self.lp, self.creds)
+ self.url = dc_url(self.lp, self.creds, dc=dc_hostname)
samdb_connect(self)
try:
@@ -843,9 +847,14 @@ class cmd_create(Command):
self.lp = sambaopts.get_loadparm()
self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
- self.url = dc_url(self.lp, self.creds, url=H)
+ # We need to know writable DC to setup SMB connection
+ if H and H.startswith('ldap://'):
+ dc_hostname = H[7:]
+ self.url = H
+ else:
+ dc_hostname = netcmd_finddc(self.lp, self.creds)
+ self.url = dc_url(self.lp, self.creds, dc=dc_hostname)
- dc_hostname = netcmd_finddc(self.lp, self.creds)
samdb_connect(self)
msg = get_gpo_info(self.samdb, displayname=displayname)