summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-12-05 00:40:48 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:48:15 +0100
commitf5860b5a853c40c9e48f5bb0a87c086d268c53bd (patch)
treecdfe5c94af464f22950118c85952fdf49371ae15 /source4/scripting/ejs
parent6d2f6f1aae2fd20dec9ed37019de26c7b33b7d2c (diff)
downloadsamba-f5860b5a853c40c9e48f5bb0a87c086d268c53bd.tar.gz
samba-f5860b5a853c40c9e48f5bb0a87c086d268c53bd.tar.bz2
samba-f5860b5a853c40c9e48f5bb0a87c086d268c53bd.zip
r26298: Use metze's schema loading code to pre-initialise the schema into the
samdb before we start writing entries into it. In doing so, I realised we still used 'dnsDomain', which is not part of the standard schema (now removed). We also set the 'wrong' side of the linked attributes for the masteredBy on each partition - this is now set in provision_self_join and backlinks via the linked attributes code. When we have the schema loaded, we must also have a valid domain SID loaded, so that the objectclass module works. This required some ejs glue. Andrew Bartlett (This used to be commit b0de08916e8cb59ce6a2ea94bbc9ac0679830ac1)
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r--source4/scripting/ejs/smbcalls_ldb.c51
1 files changed, 48 insertions, 3 deletions
diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c
index b8c35d267e..7599cbf443 100644
--- a/source4/scripting/ejs/smbcalls_ldb.c
+++ b/source4/scripting/ejs/smbcalls_ldb.c
@@ -28,6 +28,7 @@
#include "ldb_wrap.h"
#include "dsdb/samdb/samdb.h"
#include "librpc/ndr/libndr.h"
+#include "libcli/security/security.h"
/*
get the connected db
@@ -598,7 +599,7 @@ static int ejs_ldb_attach_dsdb_schema_from_ldif(MprVarHandle eid, int argc, char
}
/*
- commit a ldb attach a dsdb_schema from ldif files
+ set a particular invocationId against the running LDB
usage:
ok = ldb.set_ntds_invocationId("7729aa4b-f990-41ad-b81a-8b6a14090f41");
*/
@@ -640,9 +641,9 @@ static int ejs_ldb_set_ntds_invocationId(MprVarHandle eid, int argc, char **argv
}
/*
- commit a ldb attach a dsdb_schema from ldif files
+ attach a particular ntds objectGUID against the current ldb
usage:
- ok = ldb.get_ntds_objectGUID("7729aa4b-f990-41ad-b81a-8b6a14090f41");
+ ok = ldb.set_ntds_objectGUID("7729aa4b-f990-41ad-b81a-8b6a14090f41");
*/
static int ejs_ldb_set_ntds_objectGUID(MprVarHandle eid, int argc, char **argv)
{
@@ -682,6 +683,48 @@ static int ejs_ldb_set_ntds_objectGUID(MprVarHandle eid, int argc, char **argv)
}
/*
+ attach a particular domain SID against the current ldb
+ usage:
+ ok = ldb.set_domain_sid("S-S-1-5-21-3065342217-3567412576-2214182334");
+*/
+static int ejs_ldb_set_domain_sid(MprVarHandle eid, int argc, char **argv)
+{
+ struct ldb_context *ldb;
+ struct dom_sid *dom_sid;
+ char *dom_sid_str;
+ bool ok;
+
+ if (argc != 1) {
+ ejsSetErrorMsg(eid, "ldb.set_domain_sid invalid arguments");
+ return -1;
+ }
+
+ ldb = ejs_get_ldb_context(eid);
+ if (ldb == NULL) {
+ return -1;
+ }
+
+ dom_sid_str = argv[0];
+
+ dom_sid = dom_sid_parse_talloc(NULL, dom_sid_str);
+ if (!dom_sid) {
+ ejsSetErrorMsg(eid, "ldb.set_domain_sid - failed to parse domain sid '%s'\n",
+ dom_sid_str);
+ return -1;
+ }
+
+ ok = samdb_set_domain_sid(ldb, dom_sid);
+ talloc_free(dom_sid);
+ if (!ok) {
+ ejsSetErrorMsg(eid, "ldb.set_domain_sid - failed to set cached ntds invocationId\n");
+ return -1;
+ }
+
+ mpr_Return(eid, mprCreateBoolVar(ok));
+ return 0;
+}
+
+/*
initialise ldb ejs subsystem
*/
static int ejs_ldb_init(MprVarHandle eid, int argc, struct MprVar **argv)
@@ -708,6 +751,8 @@ static int ejs_ldb_init(MprVarHandle eid, int argc, struct MprVar **argv)
ejs_ldb_set_ntds_invocationId);
mprSetStringCFunction(ldb, "set_ntds_objectGUID",
ejs_ldb_set_ntds_objectGUID);
+ mprSetStringCFunction(ldb, "set_domain_sid",
+ ejs_ldb_set_domain_sid);
mprSetVar(ldb, "SCOPE_BASE", mprCreateNumberVar(LDB_SCOPE_BASE));
mprSetVar(ldb, "SCOPE_ONE", mprCreateNumberVar(LDB_SCOPE_ONELEVEL));
mprSetVar(ldb, "SCOPE_SUBTREE", mprCreateNumberVar(LDB_SCOPE_SUBTREE));