diff options
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r-- | source4/scripting/ejs/smbcalls_auth.c | 17 | ||||
-rw-r--r-- | source4/scripting/ejs/smbcalls_ldb.c | 11 |
2 files changed, 24 insertions, 4 deletions
diff --git a/source4/scripting/ejs/smbcalls_auth.c b/source4/scripting/ejs/smbcalls_auth.c index 8ef04bec97..3ec376f4fe 100644 --- a/source4/scripting/ejs/smbcalls_auth.c +++ b/source4/scripting/ejs/smbcalls_auth.c @@ -158,9 +158,26 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv) } /* + initialise credentials ejs object +*/ +static int ejs_system_session(MprVarHandle eid, int argc, struct MprVar **argv) +{ + struct MprVar *obj = mprInitObject(eid, "session_info", argc, argv); + struct auth_session_info *session_info = system_session(mprMemCtx()); + + if (session_info == NULL) { + return -1; + } + + mprSetPtrChild(obj, "session_info", session_info); + return 0; +} + +/* setup C functions that be called from ejs */ void smb_setup_ejs_auth(void) { ejsDefineCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "system_session", ejs_system_session, NULL, MPR_VAR_SCRIPT_HANDLE); } diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c index 798747b36c..39698947d7 100644 --- a/source4/scripting/ejs/smbcalls_ldb.c +++ b/source4/scripting/ejs/smbcalls_ldb.c @@ -385,9 +385,9 @@ static int ejs_ldbModify(MprVarHandle eid, int argc, struct MprVar **argv) static int ejs_ldbConnect(MprVarHandle eid, int argc, char **argv) { struct ldb_context *ldb; - struct auth_session_info *session_info; + struct auth_session_info *session_info = NULL; struct cli_credentials *creds = NULL; - struct MprVar *credentials; + struct MprVar *credentials, *session; struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0); const char *dbfile; @@ -397,13 +397,16 @@ static int ejs_ldbConnect(MprVarHandle eid, int argc, char **argv) return -1; } - session_info = mprGetThisPtr(eid, "session_info"); - credentials = mprGetProperty(this, "credentials", NULL); if (credentials) { creds = mprGetPtr(credentials, "creds"); } + session = mprGetProperty(this, "session_info", NULL); + if (session) { + session_info = mprGetPtr(session, "session_info"); + } + dbfile = argv[0]; ldb = ldb_wrap_connect(mprMemCtx(), dbfile, |