samba-tool: rewrite the reindex_database to use the latest indexing version
authorMatthieu Patou <mat@matws.net>
Mon, 7 Jan 2013 08:20:47 +0000 (00:20 -0800)
committerMatthieu Patou <mat@matws.net>
Wed, 27 May 2015 05:01:39 +0000 (22:01 -0700)
Also modify the @INDEXLIST attribute as it is designed for this purpose

python/samba/dbchecker.py

index 74e9678367f98276268a1238809811f20e192f0b..355a228898fcb486e7b87ead10fbb06e079f558f 100644 (file)
@@ -1420,10 +1420,16 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
     # re-index the database
     def reindex_database(self):
         '''re-index the whole database'''
+        flag = ldb.FLAG_MOD_REPLACE
+        dn = ldb.Dn(self.samdb, "@INDEXLIST")
+        att = "@IDXMASTERVERSION"
+        res = self.samdb.search(base=dn, attrs=[att], scope=ldb.SCOPE_BASE)
+        if len(res) > 0:
+            if not res[0].get(att):
+                flag= ldb.FLAG_MOD_ADD
         m = ldb.Message()
-        m.dn = ldb.Dn(self.samdb, "@ATTRIBUTES")
-        m['add']    = ldb.MessageElement('NONE', ldb.FLAG_MOD_ADD, 'force_reindex')
-        m['delete'] = ldb.MessageElement('NONE', ldb.FLAG_MOD_DELETE, 'force_reindex')
+        m.dn = dn
+        m[att] = ldb.MessageElement("4", flag, att)
         return self.do_modify(m, [], 're-indexed database', validate=False)
 
     ###############################################