summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2007-03-20 22:44:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:49:37 -0500
commite2f26316cdeba1875be2cd583870ac6127c2be56 (patch)
tree5523b7a29f840ecf54ccfe3b7ab451298e54986e
parentf19637f957590881b54bfa92c4307cd8e3494cc7 (diff)
downloadsamba-e2f26316cdeba1875be2cd583870ac6127c2be56.tar.gz
samba-e2f26316cdeba1875be2cd583870ac6127c2be56.tar.bz2
samba-e2f26316cdeba1875be2cd583870ac6127c2be56.zip
r21896: - Enable creating default NetContext when no explicit credentials are
passed. In such case use what's been provided on swat session logon. - Create a proper NetContext object only once and add it to the resources for later use. rafal (This used to be commit 106779fcf3bf96eaa82adfa020a31a4634afda43)
-rw-r--r--services/samba/ejsnet.esp88
1 files changed, 51 insertions, 37 deletions
diff --git a/services/samba/ejsnet.esp b/services/samba/ejsnet.esp
index 7ab0e02912..15b6b9b907 100644
--- a/services/samba/ejsnet.esp
+++ b/services/samba/ejsnet.esp
@@ -11,53 +11,67 @@ jsonrpc_include("resources.esp");
function _NetContext(params, error)
{
+ var credParams, credentials;
+ var resName;
+
if (params.length < 1)
{
- error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
- "too few parameters(usage: [ <credentials ])");
- return error;
+ /* create default NetContext based on already provided credentials */
+ credentials = session.authinfo.credentials;
+ resName = "netCtx";
}
-
- var creds = params[0];
- if (creds == undefined)
+ else
{
- error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
- "credentials parameter is undefined");
- return error;
- }
+ /* create user specified credentials object */
+ credParams = params[0];
+ if (typeof(credParams) != "object")
+ {
+ error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+ "credentials parameter is expected to be an object");
+ return error;
+ }
- if (creds.domain == undefined ||
- typeof(creds.domain) != "string")
- {
- error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
- "a valid string is expected in credentials.domain");
- return error;
- }
+ if (typeof(credParams.domain) != "string")
+ {
+ error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+ "a valid string is expected in credentials.domain");
+ return error;
+ }
- if (creds.username == undefined ||
- typeof(creds.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.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 (creds.password == undefined ||
- typeof(creds.username) != "string")
+ 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);
+ if (resId != undefined)
{
- error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
- "a valid string is expected in credentials.password");
- return error;
+ /* yes, return its resource id */
+ return resId;
}
-
- var credentials = credentials_init();
- credentials.set_domain(creds.domain);
- credentials.set_username(creds.username);
- credentials.set_password(creds.password);
-
- var netCtx = NetContext(credentials);
- return session.resources.set(netCtx, "netCtx", error);
+ /* no, create the new context and assign it a resource id */
+ var netCtx = NetContext(credentials);
+ resId = session.resources.set(netCtx, resName, error);
+ return resId;
}
jsonrpc.method.NetContext = _NetContext;