mirror of
https://github.com/samba-team/samba.git
synced 2025-01-05 09:18:06 +03:00
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>
This commit is contained in:
parent
161fa15697
commit
606f5d6cc6
@ -45,7 +45,7 @@ class LDAPBase(object):
|
|||||||
def __init__(self, host, creds, lp,
|
def __init__(self, host, creds, lp,
|
||||||
two=False, quiet=False, descriptor=False, sort_aces=False, verbose=False,
|
two=False, quiet=False, descriptor=False, sort_aces=False, verbose=False,
|
||||||
view="section", base="", scope="SUB",
|
view="section", base="", scope="SUB",
|
||||||
outf=sys.stdout, errf=sys.stderr):
|
outf=sys.stdout, errf=sys.stderr, skip_missing_dn=True):
|
||||||
ldb_options = []
|
ldb_options = []
|
||||||
samdb_url = host
|
samdb_url = host
|
||||||
if not "://" in host:
|
if not "://" in host:
|
||||||
@ -71,6 +71,7 @@ class LDAPBase(object):
|
|||||||
self.view = view
|
self.view = view
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
self.host = host
|
self.host = host
|
||||||
|
self.skip_missing_dn = skip_missing_dn
|
||||||
self.base_dn = str(self.ldb.get_default_basedn())
|
self.base_dn = str(self.ldb.get_default_basedn())
|
||||||
self.root_dn = str(self.ldb.get_root_basedn())
|
self.root_dn = str(self.ldb.get_root_basedn())
|
||||||
self.config_dn = str(self.ldb.get_config_basedn())
|
self.config_dn = str(self.ldb.get_config_basedn())
|
||||||
@ -686,6 +687,7 @@ class LDAPBundel(object):
|
|||||||
self.verbose = self.con.verbose
|
self.verbose = self.con.verbose
|
||||||
self.search_base = self.con.search_base
|
self.search_base = self.con.search_base
|
||||||
self.search_scope = self.con.search_scope
|
self.search_scope = self.con.search_scope
|
||||||
|
self.skip_missing_dn = self.con.skip_missing_dn
|
||||||
self.summary = {}
|
self.summary = {}
|
||||||
self.summary["unique_attrs"] = []
|
self.summary["unique_attrs"] = []
|
||||||
self.summary["df_value_attrs"] = []
|
self.summary["df_value_attrs"] = []
|
||||||
@ -729,7 +731,8 @@ class LDAPBundel(object):
|
|||||||
res = True
|
res = True
|
||||||
if self.size != other.size:
|
if self.size != other.size:
|
||||||
self.log( "\n* DN lists have different size: %s != %s" % (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.
|
# 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
|
# 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
|
title= "\n* DNs found only in %s:" % self.con.host
|
||||||
for x in self.dn_list:
|
for x in self.dn_list:
|
||||||
if not x.upper() in [q.upper() for q in other.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 )
|
self.log( title )
|
||||||
title = None
|
title = None
|
||||||
res = False
|
res = False
|
||||||
@ -749,7 +752,7 @@ class LDAPBundel(object):
|
|||||||
title= "\n* DNs found only in %s:" % other.con.host
|
title= "\n* DNs found only in %s:" % other.con.host
|
||||||
for x in other.dn_list:
|
for x in other.dn_list:
|
||||||
if not x.upper() in [q.upper() for q in self.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 )
|
self.log( title )
|
||||||
title = None
|
title = None
|
||||||
res = False
|
res = False
|
||||||
@ -902,13 +905,15 @@ class cmd_ldapcmp(Command):
|
|||||||
help="Pass search scope that builds DN list. Options: SUB, ONE, BASE"),
|
help="Pass search scope that builds DN list. Options: SUB, ONE, BASE"),
|
||||||
Option("--filter", dest="filter", default="",
|
Option("--filter", dest="filter", default="",
|
||||||
help="List of comma separated attributes to ignore in the comparision"),
|
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,
|
def run(self, URL1, URL2,
|
||||||
context1=None, context2=None, context3=None,
|
context1=None, context2=None, context3=None,
|
||||||
two=False, quiet=False, verbose=False, descriptor=False, sort_aces=False,
|
two=False, quiet=False, verbose=False, descriptor=False, sort_aces=False,
|
||||||
view="section", base="", base2="", scope="SUB", filter="",
|
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()
|
lp = sambaopts.get_loadparm()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user