]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
r19252: - fixed 'erase' argument to setup_ldb()
authorAndrew Tridgell <tridge@samba.org>
Thu, 12 Oct 2006 08:32:58 +0000 (08:32 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:20:58 +0000 (14:20 -0500)
- when wiping a ldb, wipe within each naming context first. By not
  wiping the naming contexts we didn't wipe the partitions, which
  caused a massive slowdown in re-provisioning due to re-indexing of
  the schema.
(This used to be commit b62437214cf7c98c81598c4f37c91ab284928dbb)

source4/scripting/libjs/provision.js

index c20453a74d1570727397258c5a0d6d34a9171fd4..e020cc41bde861e85b01e9973c50b0a02a378f42 100644 (file)
@@ -157,7 +157,24 @@ function ldb_delete(ldb)
 */
 function ldb_erase(ldb)
 {
-       var attrs = new Array("dn");
+       var attrs = new Array("namingContexts");
+       var res;
+
+       /* delete within each naming context - this copes with existing partitions */
+       res = ldb.search("objectClass=*", "", ldb.SCOPE_BASE, attrs);
+       if (typeof(res) != "undefined") {
+               if (res.length > 0) {
+                       var names = res[0].namingContexts;
+                       for (i=0;i<names.length;i++) {
+                               attrs = new Array("dn");
+                               res = ldb.search("(objectclass=*)", names[i], ldb.SCOPE_SUBTREE, attrs);
+                               var j;
+                               for (j=0;j<res.length;j++) {
+                                       ldb.del(res[j].dn);
+                               }
+                       }
+               }
+       }
 
        /* delete the specials */
        ldb.del("@INDEXLIST");
@@ -168,6 +185,7 @@ function ldb_erase(ldb)
        ldb.del("@KLUDGEACL");
 
        /* and the rest */
+       attrs = new Array("dn");
        var basedn = "";
        var res = ldb.search("(&(|(objectclass=*)(dn=*))(!(dn=@BASEINFO)))", basedn, ldb.SCOPE_SUBTREE, attrs);
        var i;
@@ -179,6 +197,7 @@ function ldb_erase(ldb)
                ldb.del(res[i].dn);
        }
 
+
        var res = ldb.search("(&(|(objectclass=*)(dn=*))(!(dn=@BASEINFO)))", basedn, ldb.SCOPE_SUBTREE, attrs);
        if (res.length != 0) {
                ldb_delete(ldb);
@@ -292,7 +311,7 @@ function setup_ldb(ldif, info, dbname)
                failok = arguments[4];
         }
        var ldb = open_ldb(info, dbname, erase);
-       if (setup_add_ldif(ldif, info, ldb, erase, failok)) {
+       if (setup_add_ldif(ldif, info, ldb, failok)) {
                var commit_ok = ldb.transaction_commit();
                if (!commit_ok) {
                        info.message("ldb commit failed: " + ldb.errstring() + "\n");