mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +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:
@ -672,11 +672,11 @@ class cmd_getinheritance(Command):
|
|||||||
def run(self, container_dn, H=None, sambaopts=None, credopts=None,
|
def run(self, container_dn, H=None, sambaopts=None, credopts=None,
|
||||||
versionopts=None):
|
versionopts=None):
|
||||||
|
|
||||||
self.url = H
|
|
||||||
self.lp = sambaopts.get_loadparm()
|
self.lp = sambaopts.get_loadparm()
|
||||||
|
|
||||||
self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
|
self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
|
||||||
|
|
||||||
|
self.url = dc_url(self.lp, self.creds, H)
|
||||||
|
|
||||||
samdb_connect(self)
|
samdb_connect(self)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -723,13 +723,12 @@ class cmd_setinheritance(Command):
|
|||||||
else:
|
else:
|
||||||
raise CommandError("Unknown inheritance state (%s)" % inherit_state)
|
raise CommandError("Unknown inheritance state (%s)" % inherit_state)
|
||||||
|
|
||||||
self.url = H
|
|
||||||
self.lp = sambaopts.get_loadparm()
|
self.lp = sambaopts.get_loadparm()
|
||||||
|
|
||||||
self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
|
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:
|
try:
|
||||||
msg = self.samdb.search(base=container_dn, scope=ldb.SCOPE_BASE,
|
msg = self.samdb.search(base=container_dn, scope=ldb.SCOPE_BASE,
|
||||||
expression="(objectClass=*)",
|
expression="(objectClass=*)",
|
||||||
@ -774,8 +773,13 @@ class cmd_fetch(Command):
|
|||||||
self.lp = sambaopts.get_loadparm()
|
self.lp = sambaopts.get_loadparm()
|
||||||
self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
|
self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
|
||||||
|
|
||||||
|
# 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)
|
dc_hostname = netcmd_finddc(self.lp, self.creds)
|
||||||
self.url = dc_url(self.lp, self.creds, H, dc=dc_hostname)
|
self.url = dc_url(self.lp, self.creds, dc=dc_hostname)
|
||||||
|
|
||||||
samdb_connect(self)
|
samdb_connect(self)
|
||||||
try:
|
try:
|
||||||
@ -843,9 +847,14 @@ class cmd_create(Command):
|
|||||||
self.lp = sambaopts.get_loadparm()
|
self.lp = sambaopts.get_loadparm()
|
||||||
self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
|
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)
|
dc_hostname = netcmd_finddc(self.lp, self.creds)
|
||||||
|
self.url = dc_url(self.lp, self.creds, dc=dc_hostname)
|
||||||
|
|
||||||
samdb_connect(self)
|
samdb_connect(self)
|
||||||
|
|
||||||
msg = get_gpo_info(self.samdb, displayname=displayname)
|
msg = get_gpo_info(self.samdb, displayname=displayname)
|
||||||
|
Reference in New Issue
Block a user