From 1702f5ba11de18e5566ea8b28c2583ea73ba8b65 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Thu, 4 Aug 2005 19:59:57 +0000 Subject: r9070: More fields in ejs credentials object. rafal (This used to be commit e819c035f79477b5dd8ee62292a18c9e8532c9f7) --- source4/scripting/ejs/smbcalls_creds.c | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'source4') diff --git a/source4/scripting/ejs/smbcalls_creds.c b/source4/scripting/ejs/smbcalls_creds.c index eb937aebb6..546ae84d17 100644 --- a/source4/scripting/ejs/smbcalls_creds.c +++ b/source4/scripting/ejs/smbcalls_creds.c @@ -48,6 +48,26 @@ static int ejs_creds_get_domain(MprVarHandle eid, int argc, struct MprVar **argv } +/* + set a domain +*/ +static int ejs_creds_set_domain(MprVarHandle eid, int argc, char **argv) +{ + struct cli_credentials *creds = ejs_creds_get_credentials(eid); + if (argc != 1) { + ejsSetErrorMsg(eid, "bad arguments to set_domain"); + return -1; + } + + cli_credentials_set_domain(creds, argv[0], CRED_SPECIFIED); + mpr_Return(eid, mprCreateBoolVar(True)); + return 0; +} + + +/* + get a username +*/ static int ejs_creds_get_username(MprVarHandle eid, int argc, struct MprVar **argv) { struct cli_credentials *creds = ejs_creds_get_credentials(eid); @@ -56,6 +76,10 @@ static int ejs_creds_get_username(MprVarHandle eid, int argc, struct MprVar **ar return 0; } + +/* + set a username +*/ static int ejs_creds_set_username(MprVarHandle eid, int argc, char **argv) { struct cli_credentials *creds = ejs_creds_get_credentials(eid); @@ -70,6 +94,35 @@ static int ejs_creds_set_username(MprVarHandle eid, int argc, char **argv) } +/* + get user password +*/ +static int ejs_creds_get_password(MprVarHandle eid, int argc, struct MprVar **argv) +{ + struct cli_credentials *creds = ejs_creds_get_credentials(eid); + + mpr_Return(eid, mprString(cli_credentials_get_password(creds))); + return 0; +} + + +/* + set user password +*/ +static int ejs_creds_set_password(MprVarHandle eid, int argc, char **argv) +{ + struct cli_credentials *creds = ejs_creds_get_credentials(eid); + if (argc != 1) { + ejsSetErrorMsg(eid, "bad arguments to set_password"); + return -1; + } + + cli_credentials_set_password(creds, argv[0], CRED_SPECIFIED); + mpr_Return(eid, mprCreateBoolVar(True)); + return 0; +} + + /* initialise credentials ejs object */ @@ -91,8 +144,11 @@ static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv /* setup our object methods */ mprSetCFunction(obj, "get_domain", ejs_creds_get_domain); + mprSetStringCFunction(obj, "set_domain", ejs_creds_set_domain); mprSetCFunction(obj, "get_username", ejs_creds_get_username); mprSetStringCFunction(obj, "set_username", ejs_creds_set_username); + mprSetCFunction(obj, "get_password", ejs_creds_get_password); + mprSetStringCFunction(obj, "set_password", ejs_creds_set_password); return 0; } -- cgit