summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/scripting/libjs/provision.js28
1 files changed, 26 insertions, 2 deletions
diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js
index 7133e50b4c..5ce9c8886f 100644
--- a/source4/scripting/libjs/provision.js
+++ b/source4/scripting/libjs/provision.js
@@ -111,6 +111,30 @@ function hostname()
/*
+ erase an ldb, removing all records
+*/
+function ldb_erase(ldb)
+{
+ var attrs = new Array("dn");
+
+ /* delete the specials */
+ ldb.del("@INDEXLIST");
+ ldb.del("@ATTRIBUTES");
+ ldb.del("@SUBCLASSES");
+ ldb.del("@MODULES");
+
+ /* and the rest */
+ var res = ldb.search("(|(objectclass=*)(dn=*))", attrs);
+ var i;
+ for (i=0;i<res.length;i++) {
+ ldb.del(res[i].dn);
+ }
+ res = ldb.search("(objectclass=*)", attrs);
+ assert(res.length == 0);
+}
+
+
+/*
setup a ldb in the private dir
*/
function setup_ldb(ldif, dbname, subobj)
@@ -125,8 +149,6 @@ function setup_ldb(ldif, dbname, subobj)
var dbfile = lpGet("private dir") + "/" + dbname;
var src = lpGet("setup directory") + "/" + ldif;
- sys.unlink(dbfile);
-
var data = sys.file_load(src);
data = data + extra;
data = substitute_var(data, subobj);
@@ -134,6 +156,8 @@ function setup_ldb(ldif, dbname, subobj)
var ok = ldb.connect(dbfile);
assert(ok);
+ ldb_erase(ldb);
+
ok = ldb.add(data);
assert(ok);
}