summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2013-02-14 14:59:28 +1100
committerAndrew Bartlett <abartlet@samba.org>2013-03-02 21:52:20 +0100
commit606f5d6cc6b018259ba0306fe3b55e21b4b70fdb (patch)
tree3085aefc47060cc624b570d9d71deaaea2203697
parent161fa15697fab9effbe1db9640cece847dcf63cd (diff)
downloadsamba-606f5d6cc6b018259ba0306fe3b55e21b4b70fdb.tar.gz
samba-606f5d6cc6b018259ba0306fe3b55e21b4b70fdb.tar.bz2
samba-606f5d6cc6b018259ba0306fe3b55e21b4b70fdb.zip
samba-tool ldapcmp: Add --skip-missing-dn to not error on DNs present in one DB but not the other
This is needed to compare some parts of the database, particularly in --two mode, which are just never going to have exactly the same DNs. Andrew Bartlett Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--python/samba/netcmd/ldapcmp.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py
index 8398205e4b..3c6c5f123d 100644
--- a/python/samba/netcmd/ldapcmp.py
+++ b/python/samba/netcmd/ldapcmp.py
@@ -45,7 +45,7 @@ class LDAPBase(object):
def __init__(self, host, creds, lp,
two=False, quiet=False, descriptor=False, sort_aces=False, verbose=False,
view="section", base="", scope="SUB",
- outf=sys.stdout, errf=sys.stderr):
+ outf=sys.stdout, errf=sys.stderr, skip_missing_dn=True):
ldb_options = []
samdb_url = host
if not "://" in host:
@@ -71,6 +71,7 @@ class LDAPBase(object):
self.view = view
self.verbose = verbose
self.host = host
+ self.skip_missing_dn = skip_missing_dn
self.base_dn = str(self.ldb.get_default_basedn())
self.root_dn = str(self.ldb.get_root_basedn())
self.config_dn = str(self.ldb.get_config_basedn())
@@ -686,6 +687,7 @@ class LDAPBundel(object):
self.verbose = self.con.verbose
self.search_base = self.con.search_base
self.search_scope = self.con.search_scope
+ self.skip_missing_dn = self.con.skip_missing_dn
self.summary = {}
self.summary["unique_attrs"] = []
self.summary["df_value_attrs"] = []
@@ -729,7 +731,8 @@ class LDAPBundel(object):
res = True
if self.size != other.size:
self.log( "\n* DN lists have different size: %s != %s" % (self.size, other.size) )
- res = False
+ if not self.skip_missing_dn:
+ res = False
#
# This is the case where we want to explicitly compare two objects with different DNs.
# It does not matter if they are in the same DC, in two DC in one domain or in two
@@ -738,7 +741,7 @@ class LDAPBundel(object):
title= "\n* DNs found only in %s:" % self.con.host
for x in self.dn_list:
if not x.upper() in [q.upper() for q in other.dn_list]:
- if title:
+ if title and not self.skip_missing_dn:
self.log( title )
title = None
res = False
@@ -749,7 +752,7 @@ class LDAPBundel(object):
title= "\n* DNs found only in %s:" % other.con.host
for x in other.dn_list:
if not x.upper() in [q.upper() for q in self.dn_list]:
- if title:
+ if title and not self.skip_missing_dn:
self.log( title )
title = None
res = False
@@ -902,13 +905,15 @@ class cmd_ldapcmp(Command):
help="Pass search scope that builds DN list. Options: SUB, ONE, BASE"),
Option("--filter", dest="filter", default="",
help="List of comma separated attributes to ignore in the comparision"),
+ Option("--skip-missing-dn", dest="skip_missing_dn", action="store_true", default=False,
+ help="Skip report and failure due to missing DNs in one server or another"),
]
def run(self, URL1, URL2,
context1=None, context2=None, context3=None,
two=False, quiet=False, verbose=False, descriptor=False, sort_aces=False,
view="section", base="", base2="", scope="SUB", filter="",
- credopts=None, sambaopts=None, versionopts=None):
+ credopts=None, sambaopts=None, versionopts=None, skip_missing_dn=False):
lp = sambaopts.get_loadparm()