summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs/smbcalls_auth.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/ejs/smbcalls_auth.c')
-rw-r--r--source4/scripting/ejs/smbcalls_auth.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/source4/scripting/ejs/smbcalls_auth.c b/source4/scripting/ejs/smbcalls_auth.c
index 10c63fb4dd..4739922e38 100644
--- a/source4/scripting/ejs/smbcalls_auth.c
+++ b/source4/scripting/ejs/smbcalls_auth.c
@@ -26,19 +26,21 @@
#include "auth/auth.h"
#include "scripting/ejs/smbcalls.h"
-static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *username, const char *password, const char *domain, const char *remote_host)
+static int ejs_doauth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *username,
+ const char *password, const char *domain, const char *remote_host,
+ const char *authtype)
{
struct auth_usersupplied_info *user_info = NULL;
struct auth_serversupplied_info *server_info = NULL;
struct auth_context *auth_context;
- const char *auth_unix[] = { "unix", NULL };
+ const char *auth_types[] = { authtype, NULL };
NTSTATUS nt_status;
DATA_BLOB pw_blob;
/*
darn, we need some way to get the right event_context here
*/
- nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context, NULL);
+ nt_status = auth_context_create(tmp_ctx, auth_types, &auth_context, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
mprSetPropertyValue(auth, "report", mprString("Auth System Failure"));
@@ -104,12 +106,9 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv)
auth = mprObject("auth");
if (domain && strcmp("System User", domain) == 0) {
-
- ejs_systemAuth(tmp_ctx, &auth, username, password, domain, remote_host);
- } else {
-
- mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False));
- mprSetPropertyValue(&auth, "report", mprString("Unknown Domain"));
+ ejs_doauth(tmp_ctx, &auth, username, password, domain, remote_host, "unix");
+ } else {
+ ejs_doauth(tmp_ctx, &auth, username, password, domain, remote_host, "sam");
}
mpr_Return(eid, auth);
@@ -117,28 +116,10 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv)
return 0;
}
-static int ejs_domain_list(MprVarHandle eid, int argc, char **argv)
-{
- struct MprVar list;
-
- if (argc != 0) {
- ejsSetErrorMsg(eid, "domList invalid arguments");
- return -1;
- }
-
- list = mprObject("list");
- mprSetVar(&list, "0", mprString("System User"));
-
- mpr_Return(eid, list);
-
- return 0;
-}
-
/*
setup C functions that be called from ejs
*/
void smb_setup_ejs_auth(void)
{
- ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE);
}