summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2015-07-27 15:44:56 +1200
committerStefan Metzmacher <metze@samba.org>2015-09-03 09:11:35 +0200
commit9a8165b31ffaa5283fed3badb822fcca01a702a0 (patch)
treebbc5ac08c2139d9b4e4807683ef4d50204ebf2a7
parent3c29480ab7ef9562779278a5064d18ea5c3d2f29 (diff)
downloadsamba-9a8165b31ffaa5283fed3badb822fcca01a702a0.tar.gz
dbcheck: Try to avoid duplicate searches
BUG: https://bugzilla.samba.org/show_bug.cgi?id=10973 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> (cherry picked from commit fb88f9cbd969267aaffa021724cf34087c653ba8)
-rw-r--r--python/samba/dbchecker.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py
index 9da9cb01565..351f85a7f5a 100644
--- a/python/samba/dbchecker.py
+++ b/python/samba/dbchecker.py
@@ -82,6 +82,8 @@ class dbcheck(object):
self.wellknown_sds = get_wellknown_sds(self.samdb)
self.fix_all_missing_objectclass = False
+ self.dn_set = set()
+
self.name_map = {}
try:
res = samdb.search(base="CN=DnsAdmins,CN=Users,%s" % samdb.domain_dn(), scope=ldb.SCOPE_BASE,
@@ -127,12 +129,12 @@ class dbcheck(object):
def check_database(self, DN=None, scope=ldb.SCOPE_SUBTREE, controls=[], attrs=['*']):
'''perform a database check, returning the number of errors found'''
-
res = self.samdb.search(base=DN, scope=scope, attrs=['dn'], controls=controls)
self.report('Checking %u objects' % len(res))
error_count = 0
for object in res:
+ self.dn_set.add(str(object.dn))
error_count += self.check_object(object.dn, attrs=attrs)
if DN is None:
@@ -1433,7 +1435,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
error_count += 1
try:
- if dn != self.samdb.get_root_basedn():
+ if dn != self.samdb.get_root_basedn() and str(dn.parent()) not in self.dn_set:
res = self.samdb.search(base=dn.parent(), scope=ldb.SCOPE_BASE,
controls=["show_recycled:1", "show_deleted:1"])
except ldb.LdbError, (enum, estr):