summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2007-04-17 23:10:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:51:02 -0500
commit671d785c16f2c5fbd9644ef8f169f66b9517a557 (patch)
treeabd7d42e8d73f711242594d2b1d696e854b9ace2 /services
parent4a23a696b957639a9f9ffbdd0121ce1ff453d20c (diff)
downloadsamba-671d785c16f2c5fbd9644ef8f169f66b9517a557.tar.gz
samba-671d785c16f2c5fbd9644ef8f169f66b9517a557.tar.bz2
samba-671d785c16f2c5fbd9644ef8f169f66b9517a557.zip
r22324: Another step closer to nice listing of user accounts.
rafal (This used to be commit 3f717e7fc7b0876de01cac375ef3151700066e0d)
Diffstat (limited to 'services')
-rw-r--r--services/samba/ejsnet.esp181
1 files changed, 137 insertions, 44 deletions
diff --git a/services/samba/ejsnet.esp b/services/samba/ejsnet.esp
index 15b6b9b907..00424f2cae 100644
--- a/services/samba/ejsnet.esp
+++ b/services/samba/ejsnet.esp
@@ -11,57 +11,67 @@ jsonrpc_include("resources.esp");
function _NetContext(params, error)
{
- var credParams, credentials;
- var resName;
+ var hostName, credParams, credentials;
+ var resName = "netCtx";
- if (params.length < 1)
- {
- /* create default NetContext based on already provided credentials */
- credentials = session.authinfo.credentials;
- resName = "netCtx";
- }
- else
+ credentials = session.authinfo.credentials;
+
+ if (params.length > 0)
{
- /* create user specified credentials object */
- credParams = params[0];
- if (typeof(credParams) != "object")
+ /* first expected argument is host name that this context is going
+ to be attached to */
+ hostName = params[0];
+ if (typeof(hostName) != "string" || hostName == "")
{
error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
- "credentials parameter is expected to be an object");
+ "hostName parameter is expected to be a valid non zero-length string");
return error;
}
-
- if (typeof(credParams.domain) != "string")
+
+ resName = "netCtx[" + hostName + "]";
+
+ /* check whether credentials are supplied as well */
+ if (params.length > 1)
{
- error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
- "a valid string is expected in credentials.domain");
- return error;
- }
+ /* create user specified credentials object */
+ credParams = params[1];
+ if (typeof(credParams) != "object")
+ {
+ error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+ "credentials parameter is expected to be an object");
+ return error;
+ }
+
+ if (typeof(credParams.domain) != "string")
+ {
+ error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+ "a valid string is expected in credentials.domain");
+ return error;
+ }
+
+ if (typeof(credParams.username) != "string")
+ {
+ error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+ "a valid string is expected in credentials.username");
+ return error;
+ }
+
+ if (typeof(credParams.username) != "string")
+ {
+ error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+ "a valid string is expected in credentials.password");
+ return error;
+ }
- if (typeof(credParams.username) != "string")
- {
- error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
- "a valid string is expected in credentials.username");
- return error;
+ credentials = credentials_init();
+ credentials.set_domain(credParams.domain);
+ credentials.set_username(credParams.username);
+ credentials.set_password(credParams.password);
}
-
- if (typeof(credParams.username) != "string")
- {
- error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
- "a valid string is expected in credentials.password");
- return error;
- }
-
- credentials = credentials_init();
- credentials.set_domain(credParams.domain);
- credentials.set_username(credParams.username);
- credentials.set_password(credParams.password);
-
- resName = "netCtx[" + credParams.domain + "/" + credParams.username + "]";
}
/* was this NetContext created yet ? */
- var resId = session.resources.find(key, error);
+ var resId = session.resources.find(resName, error);
if (resId != undefined)
{
/* yes, return its resource id */
@@ -76,10 +86,93 @@ function _NetContext(params, error)
jsonrpc.method.NetContext = _NetContext;
-/*
- * Local Variables:
- * mode: c
- * End:
- */
+function _NetContextCreds(params, error)
+{
+ if (params.length != 1)
+ {
+ error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+ "missing resource id parameter");
+ return error;
+ }
+
+ var resId = params[0];
+ if (typeof(resId) != "number")
+ {
+ error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+ "an integer parameter is required");
+ return error;
+ }
+
+ var netCtx = session.resources.get(resId, error);
+ if (typeof(netCtx) != "object")
+ {
+ return null;
+ }
+
+ var creds = netCtx.credentials;
+ var result = new Object();
+ result.username = creds.get_username();
+ result.domain = creds.get_domain();
+
+ return result;
+}
+jsonrpc.method.NetContextCreds = _NetContextCreds;
+
+
+function _UserMgr(params, error)
+{
+ var domainName = null, netCtxId;
+ var resId = -1;
+ var resName = "usrCtx";
+ var netCtx = undefined;
+ var usrCtx = undefined;
+
+ if (params.length == 0)
+ {
+ error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+ "NetContext parameter missing");
+ return error;
+ }
+
+ /* checking NetContext parameter */
+ netCtxId = params[0];
+ if (netCtxId == undefined || typeof(netCtxId) != "number")
+ {
+ error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+ "NetContext parameter is expected to be a number");
+ }
+
+ netCtx = session.resources.get(netCtxId, error);
+ if (netCtx == undefined || typeof(netCtx) != "object")
+ {
+ error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+ "Incorrect NetContext passed");
+ return error;
+ }
+
+ if (params.length > 1)
+ {
+ domainName = params[1];
+ if (domainName == undefined || typeof(domainName) != "string")
+ {
+ error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+ "domainName parameter is expected to be a valid non zero-length string");
+ return error;
+ }
+ }
+
+ if (domainName == "")
+ {
+ usrCtx = netCtx.UserMgr();
+ }
+ else
+ {
+ usrCtx = netCtx.UserMgr(domainName);
+ }
+
+ resId = session.resources.set(usrCtx, resName, error);
+ return resId;
+}
+jsonrpc.method.UserMgr = _UserMgr;
%>