diff options
author | Andrew Tridgell <tridge@samba.org> | 2011-08-11 16:59:11 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-08-12 04:00:07 +0200 |
commit | f444eeb51c358a8062ba6e00101f88b753d69fc7 (patch) | |
tree | 8b84f3934ccdcc5431a1f17cefb3cc9b6b2ce53a /source4/scripting/python | |
parent | fb490d88c1b43ae95ef8be7c32be4f3562eba4e2 (diff) | |
download | samba-f444eeb51c358a8062ba6e00101f88b753d69fc7.tar.gz samba-f444eeb51c358a8062ba6e00101f88b753d69fc7.tar.bz2 samba-f444eeb51c358a8062ba6e00101f88b753d69fc7.zip |
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 <abartlet@samba.org>
Diffstat (limited to 'source4/scripting/python')
-rw-r--r-- | source4/scripting/python/samba/dbchecker.py | 43 |
1 files changed, 43 insertions, 0 deletions
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='): + self.report('ERROR: dsServiceName not in GUID form in @ROOTDSE') + error_count += 1 + if not self.confirm('Change dsServiceName to GUID form?'): + return error_count + res = self.samdb.search(base=ldb.Dn(self.samdb, obj['dsServiceName'][0]), + scope=ldb.SCOPE_BASE, attrs=['objectGUID']) + guid_str = str(ndr_unpack(misc.GUID, res[0]['objectGUID'][0])) + m = ldb.Message() + m.dn = dn + m['dsServiceName'] = ldb.MessageElement("<GUID=%s>" % 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): |