summaryrefslogtreecommitdiff
path: root/source4/scripting/devel
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2012-10-23 22:12:08 -0700
committerAndrew Bartlett <abartlet@samba.org>2013-01-21 22:31:20 +0100
commit0755b835cc4e474f752de1b8cc56a9a6da14a3cd (patch)
tree04d20d65eae74e19d7b51ea00ff921fac69b6abf /source4/scripting/devel
parent7822952a11707ff8aaa415adef62082c158c2398 (diff)
downloadsamba-0755b835cc4e474f752de1b8cc56a9a6da14a3cd.tar.gz
samba-0755b835cc4e474f752de1b8cc56a9a6da14a3cd.tar.bz2
samba-0755b835cc4e474f752de1b8cc56a9a6da14a3cd.zip
devel-getncchange: try to find the dest_dsa automatically
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/scripting/devel')
-rwxr-xr-xsource4/scripting/devel/getncchanges22
1 files changed, 19 insertions, 3 deletions
diff --git a/source4/scripting/devel/getncchanges b/source4/scripting/devel/getncchanges
index d401c82869..cf4c0801b5 100755
--- a/source4/scripting/devel/getncchanges
+++ b/source4/scripting/devel/getncchanges
@@ -13,6 +13,7 @@ import samba.getopt as options
from samba.dcerpc import drsuapi, misc
from samba.samdb import SamDB
from samba.auth import system_session
+from samba.ndr import ndr_unpack
def do_DsBind(drs):
'''make a DsBind call, returning the binding handle'''
@@ -102,8 +103,7 @@ if __name__ == "__main__":
parser.add_option("", "--pas", dest="use_pas", action='store_true', default=False,
help="send partial attribute set",)
parser.add_option("", "--nb-iter", type='int', help="Number of getncchange iterations")
- parser.add_option("", "--dest-dsa", type='str',
- default='"9c637462-5b8c-4467-aef2-bdb1f57bc4ef"', help="destination DSA GUID")
+ parser.add_option("", "--dest-dsa", type='str', help="destination DSA GUID")
parser.add_option("", "--replica-flags", type='int',
default=drsuapi.DRSUAPI_DRS_INIT_SYNC |
drsuapi.DRSUAPI_DRS_PER_SYNC |
@@ -148,8 +148,24 @@ if __name__ == "__main__":
else:
exop = int(opts.exop)
+ dest_dsa = opts.dest_dsa
+ if not dest_dsa:
+ print "no dest_dsa specified trying to figure out from ldap"
+ msgs = samdb.search(controls=["search_options:1:2"],
+ expression='(objectclass=ntdsdsa)')
+ if len(msgs) == 1:
+ dest_dsa = str(ndr_unpack(misc.GUID, msgs[0]["invocationId"][0]))
+ print "Found this dsa: %s" % dest_dsa
+ else:
+ # TODO fixme
+ pass
+ if not dest_dsa:
+ print "Unable to find the dest_dsa automatically please specify it"
+ import sys
+ sys.exit(1)
+
null_guid = misc.GUID()
- req8.destination_dsa_guid = misc.GUID(opts.dest_dsa)
+ req8.destination_dsa_guid = misc.GUID(dest_dsa)
req8.source_dsa_invocation_id = misc.GUID(samdb.get_invocation_id())
req8.naming_context = drsuapi.DsReplicaObjectIdentifier()
req8.naming_context.dn = opts.dn.decode("utf-8")