1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

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.
This commit is contained in:
Amitay Isaacs 2012-07-03 14:17:48 +10:00
parent a9c4336733
commit 0365df93e6

View File

@ -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)