1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-19 12:23:49 +03:00

samba-tool: Add --local-online mode to samba-tool drs replicate

This mode avoids an issue with using -P on an RODC, instead using an IRPC message
to trigger online replication right away

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Andrew Bartlett
2016-07-08 12:54:22 +12:00
parent ae2bd0012c
commit eeb0c97fdf

View File

@@ -299,11 +299,13 @@ class cmd_drs_replicate(Command):
Option("--sync-all", help="use SYNC_ALL to replicate from all DCs", action="store_true"),
Option("--full-sync", help="resync all objects", action="store_true"),
Option("--local", help="pull changes directly into the local database (destination DC is ignored)", action="store_true"),
Option("--local-online", help="pull changes into the local database (destination DC is ignored) as a normal online replication", action="store_true"),
]
def run(self, DEST_DC, SOURCE_DC, NC,
add_ref=False, sync_forced=False, sync_all=False, full_sync=False,
local=False, sambaopts=None, credopts=None, versionopts=None, server=None):
local=False, local_online=False,
sambaopts=None, credopts=None, versionopts=None, server=None):
self.server = DEST_DC
self.lp = sambaopts.get_loadparm()
@@ -314,7 +316,14 @@ class cmd_drs_replicate(Command):
drs_local_replicate(self, SOURCE_DC, NC)
return
drsuapi_connect(self)
if local_online:
server_bind = drsuapi.drsuapi("irpc:dreplsrv", self.lp)
server_bind_handle = misc.policy_handle()
else:
drsuapi_connect(self)
server_bind = self.drsuapi
server_bind_handle = self.drsuapi_handle
samdb_connect(self)
# we need to find the NTDS GUID of the source DC
@@ -349,7 +358,7 @@ class cmd_drs_replicate(Command):
req_options |= drsuapi.DRSUAPI_DRS_FULL_SYNC_NOW
try:
drs_utils.sendDsReplicaSync(self.drsuapi, self.drsuapi_handle, source_dsa_guid, NC, req_options)
drs_utils.sendDsReplicaSync(server_bind, server_bind_handle, source_dsa_guid, NC, req_options)
except drs_utils.drsException, estr:
raise CommandError("DsReplicaSync failed", estr)
self.message("Replicate from %s to %s was successful." % (SOURCE_DC, DEST_DC))