]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool: Add --local-online mode to samba-tool drs replicate
authorAndrew Bartlett <abartlet@samba.org>
Fri, 8 Jul 2016 00:54:22 +0000 (12:54 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 8 Jul 2016 08:01:20 +0000 (10:01 +0200)
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>
python/samba/netcmd/drs.py

index ca5417bcefaae8f656f95f80c26fc84565e642b1..cbd1672a9f4d8a6eed58b8fe2632056faeb019b8 100644 (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))