From 222fdd5237c1fd8551c39ce544171df3a5a41831 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 31 Aug 2005 21:04:17 +0000 Subject: r9842: More error checks in the ldb_map modules, extend testsuite (This used to be commit b7992de4b7d42a55e00509c887a269a07c19627d) --- source4/scripting/ejs/smbcalls_ldb.c | 8 ++--- source4/scripting/libjs/upgrade.js | 59 +++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 32 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c index aabd43d1ac..855dd157f7 100644 --- a/source4/scripting/ejs/smbcalls_ldb.c +++ b/source4/scripting/ejs/smbcalls_ldb.c @@ -311,10 +311,10 @@ static int ejs_base64decode(MprVarHandle eid, int argc, struct MprVar **argv) /* - perform an ldb modify + perform an ldb add syntax: - ok = ldb.modify(ldifstring); + ok = ldb.add(ldifstring); */ static int ejs_ldbAdd(MprVarHandle eid, int argc, struct MprVar **argv) { @@ -322,10 +322,10 @@ static int ejs_ldbAdd(MprVarHandle eid, int argc, struct MprVar **argv) } /* - perform an ldb add + perform an ldb modify syntax: - ok = ldb.add(ldifstring); + ok = ldb.modify(ldifstring); */ static int ejs_ldbModify(MprVarHandle eid, int argc, struct MprVar **argv) { diff --git a/source4/scripting/libjs/upgrade.js b/source4/scripting/libjs/upgrade.js index 59e433b0f2..ac7e445330 100644 --- a/source4/scripting/libjs/upgrade.js +++ b/source4/scripting/libjs/upgrade.js @@ -418,34 +418,6 @@ function upgrade(subobj, samba3, message, paths) ok = samdb.modify(ldif); assert(ok); - // figure out ldapurl, if applicable - var ldapurl = undefined; - var pdb = samba3.configuration.get_list("passdb backend"); - if (pdb != undefined) { - for (var b in pdb) { - if (substr(pdb[b], 0, 7) == "ldapsam") { - ldapurl = substr(pdb[b], 8); - } - } - } - - // URL was not specified in passdb backend but ldap /is/ used - if (ldapurl == "") { - ldapurl = "ldap://" + samba3.configuration.get("ldap server"); - } - - // Enable samba3sam module if original passdb backend was ldap - if (ldapurl != undefined) { - message("Enabling Samba3 LDAP mappings for SAM database\n"); - var ldif = sprintf(" -dn: @MAP=samba3sam -@MAP_URL: %s", ldapurl); - samdb.add(ldif); - - samdb.modify("dn: @MODULES -@LIST: samldb,timestamps,objectguid,rdn_name,samba3sam"); - } - message("Importing users\n"); for (var i in samba3.samaccounts) { var msg = "... " + samba3.samaccounts[i].username; @@ -500,6 +472,37 @@ dn: @MAP=samba3sam ok = winsdb.add(ldif); assert(ok); + // figure out ldapurl, if applicable + var ldapurl = undefined; + var pdb = samba3.configuration.get_list("passdb backend"); + if (pdb != undefined) { + for (var b in pdb) { + if (substr(pdb[b], 0, 7) == "ldapsam") { + ldapurl = substr(pdb[b], 8); + } + } + } + + // URL was not specified in passdb backend but ldap /is/ used + if (ldapurl == "") { + ldapurl = "ldap://" + samba3.configuration.get("ldap server"); + } + + // Enable samba3sam module if original passdb backend was ldap + if (ldapurl != undefined) { + message("Enabling Samba3 LDAP mappings for SAM database\n"); + var ldif = sprintf(" +dn: @MAP=samba3sam +@MAP_URL: %s", ldapurl); + ok = samdb.add(ldif); + assert(ok); + + ok = samdb.modify("dn: @MODULES +replace: @LIST +@LIST: samldb,timestamps,objectguid,rdn_name,samba3sam"); + assert(ok); + } + return ret; } -- cgit