mirror of
https://github.com/samba-team/samba.git
synced 2025-11-29 16:23:52 +03:00
r12699: correctly escape invalid DN characters (reported by Steinar H. Gunderson).
this still doesn't work as a bug in ldb causes it to not understand
escaped characters in DNs when parsing DNs
(This used to be commit 10da56fb6c)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
769eb7d3fe
commit
34be0772d2
@@ -322,7 +322,35 @@ static int ejs_base64decode(MprVarHandle eid, int argc, struct MprVar **argv)
|
|||||||
|
|
||||||
return 0;
|
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
|
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, "errstring", ejs_ldbErrstring);
|
||||||
mprSetCFunction(ldb, "encode", ejs_base64encode);
|
mprSetCFunction(ldb, "encode", ejs_base64encode);
|
||||||
mprSetCFunction(ldb, "decode", ejs_base64decode);
|
mprSetCFunction(ldb, "decode", ejs_base64decode);
|
||||||
|
mprSetCFunction(ldb, "dn_escape", ejs_dn_escape);
|
||||||
mprSetCFunction(ldb, "close", ejs_ldbClose);
|
mprSetCFunction(ldb, "close", ejs_ldbClose);
|
||||||
mprSetCFunction(ldb, "transaction_start", ejs_ldbTransactionStart);
|
mprSetCFunction(ldb, "transaction_start", ejs_ldbTransactionStart);
|
||||||
mprSetCFunction(ldb, "transaction_cancel", ejs_ldbTransactionCancel);
|
mprSetCFunction(ldb, "transaction_cancel", ejs_ldbTransactionCancel);
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ objectSid: %s-%d
|
|||||||
lmPwdHash:: %s
|
lmPwdHash:: %s
|
||||||
ntPwdHash:: %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.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,
|
acc.domain, acc.dir_drive, acc.munged_dial, acc.homedir, acc.logon_script,
|
||||||
|
|||||||
Reference in New Issue
Block a user