summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2018-01-24 22:24:15 +0100
committerKarolin Seeger <kseeger@samba.org>2018-02-09 09:30:22 +0100
commit54b7de0c0827b31476591105ac3150e983c86ae4 (patch)
treec49a87b3e1dbc2a9121f3892463bb75f309a776f /python
parentf4cb28b18e1a2c39101554570451dfb0614cd5db (diff)
downloadsamba-54b7de0c0827b31476591105ac3150e983c86ae4.tar.gz
dbcheck: add a helper function that checks is a value has duplicate links
Will be used in a subsequent commit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> (cherry picked from commit e258b4fb281d8577c425e05b35ce05cf128617ea)
Diffstat (limited to 'python')
-rw-r--r--python/samba/dbchecker.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py
index 787cea2de48..d4c653aab6d 100644
--- a/python/samba/dbchecker.py
+++ b/python/samba/dbchecker.py
@@ -955,6 +955,38 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
return (error_count, duplicate_dict, unique_dict)
+ def has_duplicate_links(self, dn, forward_attr, forward_syntax):
+ '''check a linked values for duplicate forward links'''
+ error_count = 0
+
+ duplicate_cache_key = "%s:%s" % (str(dn), forward_attr)
+ if duplicate_cache_key in self.duplicate_link_cache:
+ return self.duplicate_link_cache[duplicate_cache_key]
+
+ forward_linkID, backlink_attr = self.get_attr_linkID_and_reverse_name(forward_attr)
+
+ attrs = [forward_attr]
+ controls = ["extended_dn:1:1", "reveal_internals:0"]
+
+ # check its the right GUID
+ try:
+ res = self.samdb.search(base=str(dn), scope=ldb.SCOPE_BASE,
+ attrs=attrs, controls=controls)
+ except ldb.LdbError, (enum, estr):
+ if enum != ldb.ERR_NO_SUCH_OBJECT:
+ raise
+
+ return False
+
+ obj = res[0]
+ error_count, duplicate_dict, unique_dict = \
+ self.check_duplicate_links(obj, forward_attr, forward_syntax, forward_linkID, backlink_attr)
+
+ if duplicate_cache_key in self.duplicate_link_cache:
+ return self.duplicate_link_cache[duplicate_cache_key]
+
+ return False
+
def check_dn(self, obj, attrname, syntax_oid):
'''check a DN attribute for correctness'''
error_count = 0