From f444eeb51c358a8062ba6e00101f88b753d69fc7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 11 Aug 2011 16:59:11 +1000 Subject: s4-dbcheck: offer to fix dsServiceName to be in GUID form this fixes the dsServiceName so it can handle server renames Pair-Programmed-With: Andrew Bartlett --- source4/scripting/python/samba/dbchecker.py | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'source4') diff --git a/source4/scripting/python/samba/dbchecker.py b/source4/scripting/python/samba/dbchecker.py index b16b75aa16..85c7f80b91 100644 --- a/source4/scripting/python/samba/dbchecker.py +++ b/source4/scripting/python/samba/dbchecker.py @@ -77,10 +77,17 @@ class dbcheck(object): 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: error_count += self.check_object(object.dn, attrs=attrs) + + if DN is None: + error_count += self.check_rootdse() + if error_count != 0 and not self.fix: self.report("Please use --fix to fix these errors") + + self.report('Checked %u objects (%u errors)' % (len(res), error_count)) return error_count @@ -480,6 +487,42 @@ class dbcheck(object): return error_count + ################################################################ + # check special @ROOTDSE attributes + def check_rootdse(self): + '''check the @ROOTDSE special object''' + dn = ldb.Dn(self.samdb, '@ROOTDSE') + if self.verbose: + self.report("Checking object %s" % dn) + res = self.samdb.search(base=dn, scope=ldb.SCOPE_BASE) + if len(res) != 1: + self.report("Object %s disappeared during check" % dn) + return 1 + obj = res[0] + error_count = 0 + + # check that the dsServiceName is in GUID form + if not 'dsServiceName' in obj: + self.report('ERROR: dsServiceName missing in @ROOTDSE') + return error_count+1 + + if not obj['dsServiceName'][0].startswith('" % guid_str, + ldb.FLAG_MOD_REPLACE, 'dsServiceName') + if self.do_modify(m, [], "Failed to change dsServiceName to GUID form", validate=False): + self.report("Changed dsServiceName to GUID form") + return error_count + + ############################################### # re-index the database def reindex_database(self): -- cgit