summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-06-09 15:01:30 +1000
committerAndrew Tridgell <tridge@samba.org>2011-06-09 08:15:10 +0200
commit516dc404fd7f299b68adae356f2416ca8e265031 (patch)
treee49ef599df6d9bfff644b942f00458e3cbf09257 /source4
parent1596595b7e644de6432d7c8fb9e10ee2b525440e (diff)
downloadsamba-516dc404fd7f299b68adae356f2416ca8e265031.tar.gz
samba-516dc404fd7f299b68adae356f2416ca8e265031.tar.bz2
samba-516dc404fd7f299b68adae356f2416ca8e265031.zip
samba-tool: added --local option to drs replicate command
this allows replication directly to the local SAM, which means it can run without the samba daemon running. It also bypasses all usnChanged checks, which is useful for forcing replication of a set of objects which are not marked as replication being needed Autobuild-User: Andrew Tridgell <tridge@samba.org> Autobuild-Date: Thu Jun 9 08:15:10 CEST 2011 on sn-devel-104
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/samba/netcmd/drs.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/source4/scripting/python/samba/netcmd/drs.py b/source4/scripting/python/samba/netcmd/drs.py
index 56c0e39a59..61717a70e9 100644
--- a/source4/scripting/python/samba/netcmd/drs.py
+++ b/source4/scripting/python/samba/netcmd/drs.py
@@ -233,6 +233,39 @@ class cmd_drs_kcc(Command):
self.message("Consistency check on %s successful." % DC)
+def drs_local_replicate(self, SOURCE_DC, NC):
+ '''replicate from a source DC to the local SAM'''
+ self.server = SOURCE_DC
+ drsuapi_connect(self)
+
+ self.local_samdb = SamDB(session_info=system_session(), url=None,
+ credentials=self.creds, lp=self.lp)
+
+ self.samdb = SamDB(url="ldap://%s" % self.server,
+ session_info=system_session(),
+ credentials=self.creds, lp=self.lp)
+
+ # work out the source and destination GUIDs
+ res = self.local_samdb.search(base="", scope=ldb.SCOPE_BASE, attrs=["dsServiceName"])
+ self.ntds_dn = res[0]["dsServiceName"][0]
+
+ res = self.local_samdb.search(base=self.ntds_dn, scope=ldb.SCOPE_BASE, attrs=["objectGUID"])
+ self.ntds_guid = misc.GUID(self.samdb.schema_format_value("objectGUID", res[0]["objectGUID"][0]))
+
+
+ source_dsa_invocation_id = misc.GUID(self.samdb.get_invocation_id())
+ destination_dsa_guid = self.ntds_guid
+
+ self.samdb.transaction_start()
+ repl = drs_utils.drs_Replicate("ncacn_ip_tcp:%s[seal]" % self.server, self.lp,
+ self.creds, self.local_samdb)
+ try:
+ repl.replicate(NC, source_dsa_invocation_id, destination_dsa_guid)
+ except Exception, e:
+ raise CommandError("Error replicating DN %s" % NC, e)
+ self.samdb.transaction_commit()
+
+
class cmd_drs_replicate(Command):
"""replicate a naming context between two DCs"""
@@ -250,9 +283,10 @@ class cmd_drs_replicate(Command):
takes_options = [
Option("--add-ref", help="use ADD_REF to add to repsTo on source", action="store_true"),
Option("--sync-forced", help="use SYNC_FORCED to force inbound replication", action="store_true"),
+ Option("--local", help="pull changes directly into the local database (destination DC is ignored)", action="store_true"),
]
- def run(self, DEST_DC, SOURCE_DC, NC, add_ref=False, sync_forced=False,
+ def run(self, DEST_DC, SOURCE_DC, NC, add_ref=False, sync_forced=False, local=False,
sambaopts=None,
credopts=None, versionopts=None, server=None):
@@ -261,6 +295,10 @@ class cmd_drs_replicate(Command):
self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
+ if local:
+ drs_local_replicate(self, SOURCE_DC, NC)
+ return
+
drsuapi_connect(self)
samdb_connect(self)