summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2006-11-30 20:29:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:28:43 -0500
commit61cb5f807e3d0a3bbffbc317c882517c724c35da (patch)
tree98060ff2de1be3e02429dbb192a2d404e64abbf4
parentee7924732a067bffbcf4d38158b582d7c587878d (diff)
downloadsamba-61cb5f807e3d0a3bbffbc317c882517c724c35da.tar.gz
samba-61cb5f807e3d0a3bbffbc317c882517c724c35da.tar.bz2
samba-61cb5f807e3d0a3bbffbc317c882517c724c35da.zip
r19972: put a placeholder of a new js function and use error strings
returned by each libnet call. rafal (This used to be commit bc88640bb51db381d91b797693bc04f7b2653eb6)
-rw-r--r--source4/scripting/ejs/ejsnet.c65
1 files changed, 59 insertions, 6 deletions
diff --git a/source4/scripting/ejs/ejsnet.c b/source4/scripting/ejs/ejsnet.c
index 523e0e8a02..cef3b99d05 100644
--- a/source4/scripting/ejs/ejsnet.c
+++ b/source4/scripting/ejs/ejsnet.c
@@ -28,14 +28,16 @@
#include "events/events.h"
#include "auth/credentials/credentials.h"
-static int ejs_net_userman(MprVarHandle, int, struct MprVar**);
-static int ejs_net_createuser(MprVarHandle, int, char**);
+static int ejs_net_userman(MprVarHandle eid, int argc, struct MprVar** argv);
+static int ejs_net_createuser(MprVarHandle eid, int argc, char **argv);
static int ejs_net_deleteuser(MprVarHandle eid, int argc, char **argv);
+static int ejs_net_userinfo(MprVarHandle eid, int argc, char **argv);
static int ejs_net_join_domain(MprVarHandle eid, int argc, struct MprVar **argv);
static int ejs_net_samsync_ldb(MprVarHandle eid, int argc, struct MprVar **argv);
-/* Usage:
- net = NetContext(credentials);
+/*
+ Usage:
+ net = NetContext(credentials);
*/
static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv)
@@ -92,6 +94,7 @@ static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv)
return 0;
}
+
static int ejs_net_join_domain(MprVarHandle eid, int argc, struct MprVar **argv)
{
TALLOC_CTX *mem_ctx;
@@ -150,6 +153,7 @@ static int ejs_net_join_domain(MprVarHandle eid, int argc, struct MprVar **argv)
return 0;
}
+
static int ejs_net_samsync_ldb(MprVarHandle eid, int argc, struct MprVar **argv)
{
TALLOC_CTX *mem_ctx;
@@ -197,6 +201,11 @@ static int ejs_net_samsync_ldb(MprVarHandle eid, int argc, struct MprVar **argv)
return 0;
}
+
+/*
+ Usage:
+ usrCtx = net.UserMgr(domain);
+*/
static int ejs_net_userman(MprVarHandle eid, int argc, struct MprVar **argv)
{
TALLOC_CTX *mem_ctx;
@@ -229,6 +238,7 @@ static int ejs_net_userman(MprVarHandle eid, int argc, struct MprVar **argv)
mprSetStringCFunction(obj, "Create", ejs_net_createuser);
mprSetStringCFunction(obj, "Delete", ejs_net_deleteuser);
+ mprSetStringCFunction(obj, "Info", ejs_net_userinfo);
return 0;
done:
@@ -269,7 +279,7 @@ static int ejs_net_createuser(MprVarHandle eid, int argc, char **argv)
status = libnet_CreateUser(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
- ejsSetErrorMsg(eid, "error when creating user: %s", nt_errstr(status));
+ ejsSetErrorMsg(eid, "%s", req.out.error_string);
}
talloc_free(mem_ctx);
@@ -277,6 +287,7 @@ static int ejs_net_createuser(MprVarHandle eid, int argc, char **argv)
return 0;
}
+
static int ejs_net_deleteuser(MprVarHandle eid, int argc, char **argv)
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
@@ -309,7 +320,7 @@ static int ejs_net_deleteuser(MprVarHandle eid, int argc, char **argv)
status = libnet_DeleteUser(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
- ejsSetErrorMsg(eid, "error when creating user: %s", nt_errstr(status));
+ ejsSetErrorMsg(eid, "%s", req.out.error_string);
}
talloc_free(mem_ctx);
@@ -318,6 +329,48 @@ static int ejs_net_deleteuser(MprVarHandle eid, int argc, char **argv)
}
+static int ejs_net_userinfo(MprVarHandle eid, int argc, char **argv)
+{
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ TALLOC_CTX *mem_ctx;
+ struct libnet_context *ctx;
+ const char *userman_domain = NULL;
+ struct libnet_UserInfo req;
+
+ if (argc != 1) {
+ ejsSetErrorMsg(eid, "argument 1 must be a string");
+ return -1;
+ }
+
+ ctx = mprGetThisPtr(eid, "ctx");
+ if (!ctx) {
+ ejsSetErrorMsg(eid, "ctx property returns null pointer");
+ return -1;
+ }
+
+ userman_domain = mprGetThisPtr(eid, "domain");
+ if (!userman_domain) {
+ ejsSetErrorMsg(eid, "domain property returns null pointer");
+ return -1;
+ }
+
+ mem_ctx = talloc_new(mprMemCtx());
+
+ req.in.domain_name = userman_domain;
+ req.in.user_name = argv[0];
+
+ status = libnet_UserInfo(ctx, mem_ctx, &req);
+ if (!NT_STATUS_IS_OK(status)) {
+ ejsSetErrorMsg(eid, "%s", req.out.error_string);
+ }
+
+ /* TODO: create user info object and pass received properties */
+
+ talloc_free(mem_ctx);
+ return 0;
+}
+
+
void ejsnet_setup(void)
{
ejsDefineCFunction(-1, "NetContext", ejs_net_context, NULL, MPR_VAR_SCRIPT_HANDLE);