summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/scripting/ejs/smbcalls_ldb.c31
-rw-r--r--source4/scripting/libjs/upgrade.js2
2 files changed, 31 insertions, 2 deletions
diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c
index e9dba94eaa..78063ed6b4 100644
--- a/source4/scripting/ejs/smbcalls_ldb.c
+++ b/source4/scripting/ejs/smbcalls_ldb.c
@@ -322,7 +322,35 @@ static int ejs_base64decode(MprVarHandle eid, int argc, struct MprVar **argv)
return 0;
}
-
+
+/*
+ escape a DN
+ usage:
+ dataout = ldb.dn_escape(datain)
+ */
+static int ejs_dn_escape(MprVarHandle eid, int argc, struct MprVar **argv)
+{
+ char *ret;
+ struct ldb_val val;
+
+ if (argc != 1) {
+ ejsSetErrorMsg(eid, "ldb.dn_escape invalid argument count");
+ return -1;
+ }
+
+ val.data = mprToString(argv[0]);
+ val.length = strlen((const char *)val.data);
+
+ ret = ldb_dn_escape_value(mprMemCtx(), val);
+ if (ret == NULL) {
+ mpr_Return(eid, mprCreateUndefinedVar());
+ } else {
+ mpr_Return(eid, mprString(ret));
+ talloc_free(ret);
+ }
+
+ return 0;
+}
/*
perform an ldb add
@@ -511,6 +539,7 @@ static int ejs_ldb_init(MprVarHandle eid, int argc, struct MprVar **argv)
mprSetCFunction(ldb, "errstring", ejs_ldbErrstring);
mprSetCFunction(ldb, "encode", ejs_base64encode);
mprSetCFunction(ldb, "decode", ejs_base64decode);
+ mprSetCFunction(ldb, "dn_escape", ejs_dn_escape);
mprSetCFunction(ldb, "close", ejs_ldbClose);
mprSetCFunction(ldb, "transaction_start", ejs_ldbTransactionStart);
mprSetCFunction(ldb, "transaction_cancel", ejs_ldbTransactionCancel);
diff --git a/source4/scripting/libjs/upgrade.js b/source4/scripting/libjs/upgrade.js
index 4ac6b6db34..0ffb790d5f 100644
--- a/source4/scripting/libjs/upgrade.js
+++ b/source4/scripting/libjs/upgrade.js
@@ -151,7 +151,7 @@ objectSid: %s-%d
lmPwdHash:: %s
ntPwdHash:: %s
-", acc.fullname, domaindn, acc.logon_time, acc.logoff_time, acc.username, acc.nt_username, acc.nt_username,
+", ldb.dn_escape(acc.fullname), domaindn, acc.logon_time, acc.logoff_time, acc.username, acc.nt_username, acc.nt_username,
acc.fullname, acc.acct_desc, acc.group_rid, acc.bad_password_count, acc.logon_count,
acc.domain, acc.dir_drive, acc.munged_dial, acc.homedir, acc.logon_script,