r21788: Add new JSON-RPC services.
authorRafal Szczesniak <mimir@samba.org>
Sun, 11 Mar 2007 18:37:45 +0000 (18:37 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:49:26 +0000 (14:49 -0500)
rafal

services/samba/config.esp [new file with mode: 0644]
services/samba/ejsnet.esp [new file with mode: 0644]

diff --git a/services/samba/config.esp b/services/samba/config.esp
new file mode 100644 (file)
index 0000000..bf4b789
--- /dev/null
@@ -0,0 +1,26 @@
+<%
+
+/*
+ * Copyright (C)  Rafal Szczesniak 2007
+ */
+
+/* Simple JSON-RPC access to the configuration parameters */
+
+function _lp_get(params, error)
+{
+  if (params.length < 1)
+  {
+    error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+                  "no parameter specified");
+    return error;
+  }
+
+  var lp = loadparm_init();
+  var name = params[0];
+  var value = lp.get(name);
+
+  return value;
+}
+jsonrpc.method.lp_get = _lp_get;
+
+%>
diff --git a/services/samba/ejsnet.esp b/services/samba/ejsnet.esp
new file mode 100644 (file)
index 0000000..9584bec
--- /dev/null
@@ -0,0 +1,68 @@
+<%
+
+/*
+ * Copyright (C)  Rafal Szczesniak 2007
+ */
+
+/* JSON-RPC mappings to the libnet functions */
+
+jsonrpc_include("resources.esp");
+
+
+function _init_ctx(params, error)
+{
+  if (params.length < 1)
+  {
+    error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+                  "too few parameters(usage: [ <credentials ])");
+    return error;
+  }
+  
+  var creds = params[0];
+  if (creds == undefined)
+  {
+    error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+                  "credentials parameter is undefined");
+    return error;
+  }
+  
+  if (creds.domain == undefined)
+  {
+    error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+                  "credentials.domain is undefined");
+    return error;
+  }
+  
+  if (creds.username == undefined)
+  {
+    error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+                  "credentials.username is undefined");
+    return error;
+  }
+  
+  if (creds.password == undefined)
+  {
+    error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
+                  "credentials.password is undefined");
+    return error;
+  }
+  
+  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);
+}
+jsonrpc.method.init_ctx = _init_ctx;
+
+
+/*
+ * Local Variables:
+ * mode: c
+ * End:
+ */
+
+%>