summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/build/pidl/Parse/Pidl/Samba/EJS.pm2
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c88
-rw-r--r--source4/scripting/libjs/management.js25
-rw-r--r--source4/scripting/libjs/samr.js31
-rw-r--r--swat/esptest/samr.esp4
-rwxr-xr-xtestprogs/ejs/echo.js75
-rwxr-xr-xtestprogs/ejs/samr.js48
7 files changed, 134 insertions, 139 deletions
diff --git a/source4/build/pidl/Parse/Pidl/Samba/EJS.pm b/source4/build/pidl/Parse/Pidl/Samba/EJS.pm
index 5cd7b462ae..c528e13a52 100644
--- a/source4/build/pidl/Parse/Pidl/Samba/EJS.pm
+++ b/source4/build/pidl/Parse/Pidl/Samba/EJS.pm
@@ -704,7 +704,7 @@ sub EjsInterface($$)
pidl "mprSetVar(obj, \"$v\", mprCreateNumberVar($value));";
}
}
- pidl "return 0;";
+ pidl "return ejs_rpc_init(obj, \"$name\");";
deindent;
pidl "}\n";
diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
index 8e7bf57972..223ac5c972 100644
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ b/source4/scripting/ejs/smbcalls_rpc.c
@@ -46,33 +46,28 @@ struct ejs_irpc_connection {
/*
setup a context for talking to a irpc server
example:
- var conn = new Object();
- status = irpc_connect(conn, "smb_server");
+ status = irpc.connect("smb_server");
*/
-static int ejs_irpc_connect(MprVarHandle eid, int argc, struct MprVar **argv)
+static int ejs_irpc_connect(MprVarHandle eid, int argc, char **argv)
{
NTSTATUS status;
int i;
- struct MprVar *conn;
struct event_context *ev;
struct ejs_irpc_connection *p;
+ struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0);
/* validate arguments */
- if (argc != 2 ||
- argv[0]->type != MPR_TYPE_OBJECT ||
- argv[1]->type != MPR_TYPE_STRING) {
+ if (argc != 1) {
ejsSetErrorMsg(eid, "rpc_connect invalid arguments");
return -1;
}
- conn = argv[0];
-
- p = talloc(conn, struct ejs_irpc_connection);
+ p = talloc(this, struct ejs_irpc_connection);
if (p == NULL) {
return -1;
}
- p->server_name = mprToString(argv[1]);
+ p->server_name = argv[0];
ev = talloc_find_parent_bytype(mprMemCtx(), struct event_context);
@@ -93,7 +88,7 @@ static int ejs_irpc_connect(MprVarHandle eid, int argc, struct MprVar **argv)
talloc_free(p);
status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
} else {
- mprSetPtrChild(conn, "irpc", p);
+ mprSetPtrChild(this, "irpc", p);
status = NT_STATUS_OK;
}
@@ -104,32 +99,37 @@ static int ejs_irpc_connect(MprVarHandle eid, int argc, struct MprVar **argv)
/*
connect to an rpc server
- example:
- var conn = new Object();
- status = rpc_connect(conn, "ncacn_ip_tcp:localhost", "rpcecho");
+ examples:
+ status = rpc.connect("ncacn_ip_tcp:localhost");
+ status = rpc.connect("ncacn_ip_tcp:localhost", "pipe_name");
*/
-static int ejs_rpc_connect(MprVarHandle eid, int argc, struct MprVar **argv)
+static int ejs_rpc_connect(MprVarHandle eid, int argc, char **argv)
{
const char *binding, *pipe_name;
const struct dcerpc_interface_table *iface;
NTSTATUS status;
struct dcerpc_pipe *p;
- struct MprVar *conn;
struct cli_credentials *creds = cmdline_credentials;
struct event_context *ev;
+ struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0);
/* validate arguments */
- if (argc != 3 ||
- argv[0]->type != MPR_TYPE_OBJECT ||
- argv[1]->type != MPR_TYPE_STRING ||
- argv[2]->type != MPR_TYPE_STRING) {
+ if (argc < 1) {
ejsSetErrorMsg(eid, "rpc_connect invalid arguments");
return -1;
}
- conn = argv[0];
- binding = mprToString(argv[1]);
- pipe_name = mprToString(argv[2]);
+ binding = argv[0];
+ if (strchr(binding, ':') == NULL) {
+ /* its an irpc connect */
+ return ejs_irpc_connect(eid, argc, argv);
+ }
+
+ if (argc > 1) {
+ pipe_name = argv[1];
+ } else {
+ pipe_name = mprToString(mprGetProperty(this, "pipe_name", NULL));
+ }
iface = idl_iface_by_name(pipe_name);
if (iface == NULL) {
@@ -146,7 +146,7 @@ static int ejs_rpc_connect(MprVarHandle eid, int argc, struct MprVar **argv)
ev = talloc_find_parent_bytype(mprMemCtx(), struct event_context);
- status = dcerpc_pipe_connect(conn, &p, binding,
+ status = dcerpc_pipe_connect(this, &p, binding,
iface->uuid, iface->if_version,
creds, ev);
if (!NT_STATUS_IS_OK(status)) goto done;
@@ -156,8 +156,8 @@ static int ejs_rpc_connect(MprVarHandle eid, int argc, struct MprVar **argv)
/* by making the pipe a child of the connection variable, it will
auto close when it goes out of scope in the script */
- mprSetPtrChild(conn, "pipe", p);
- mprSetPtr(conn, "iface", iface);
+ mprSetPtrChild(this, "pipe", p);
+ mprSetPtr(this, "iface", iface);
done:
mpr_Return(eid, mprNTSTATUS(status));
@@ -168,7 +168,7 @@ done:
/*
make an irpc call - called via the same interface as rpc
*/
-static int ejs_irpc_call(int eid, struct MprVar *conn, struct MprVar *io,
+static int ejs_irpc_call(int eid, struct MprVar *io,
const struct dcerpc_interface_table *iface, int callnum,
ejs_pull_function_t ejs_pull, ejs_push_function_t ejs_push)
{
@@ -181,7 +181,7 @@ static int ejs_irpc_call(int eid, struct MprVar *conn, struct MprVar *io,
int i, count;
struct MprVar *results;
- p = mprGetPtr(conn, "irpc");
+ p = mprGetThisPtr(eid, "irpc");
ejs = talloc(mprMemCtx(), struct ejs_rpc);
if (ejs == NULL) {
@@ -273,7 +273,7 @@ done:
const struct dcerpc_interface_table *iface, int callnum,
ejs_pull_function_t ejs_pull, ejs_push_function_t ejs_push)
{
- struct MprVar *conn, *io;
+ struct MprVar *io;
struct dcerpc_pipe *p;
NTSTATUS status;
void *ptr;
@@ -281,23 +281,20 @@ done:
struct ejs_rpc *ejs;
const struct dcerpc_interface_call *call;
- if (argc != 2 ||
- argv[0]->type != MPR_TYPE_OBJECT ||
- argv[1]->type != MPR_TYPE_OBJECT) {
+ if (argc != 1 || argv[0]->type != MPR_TYPE_OBJECT) {
ejsSetErrorMsg(eid, "rpc_call invalid arguments");
return -1;
}
- conn = argv[0];
- io = argv[1];
+ io = argv[0];
- if (mprGetPtr(conn, "irpc")) {
+ if (mprGetThisPtr(eid, "irpc")) {
/* its an irpc call */
- return ejs_irpc_call(eid, conn, io, iface, callnum, ejs_pull, ejs_push);
+ return ejs_irpc_call(eid, io, iface, callnum, ejs_pull, ejs_push);
}
/* get the pipe info */
- p = mprGetPtr(conn, "pipe");
+ p = mprGetThisPtr(eid, "pipe");
if (p == NULL) {
ejsSetErrorMsg(eid, "rpc_call invalid pipe");
return -1;
@@ -389,9 +386,20 @@ void smb_setup_ejs_rpc(void)
{
struct ejs_register *r;
- ejsDefineCFunction(-1, "rpc_connect", ejs_rpc_connect, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "irpc_connect", ejs_irpc_connect, NULL, MPR_VAR_SCRIPT_HANDLE);
for (r=ejs_registered;r;r=r->next) {
ejsDefineCFunction(-1, r->name, r->fn, NULL, MPR_VAR_SCRIPT_HANDLE);
}
}
+
+/*
+ hook called by generated RPC interfaces at the end of their init routines
+ used to add generic operations on the pipe
+*/
+int ejs_rpc_init(struct MprVar *obj, const char *name)
+{
+ mprSetStringCFunction(obj, "connect", ejs_rpc_connect);
+ if (mprGetProperty(obj, "pipe_name", NULL) == NULL) {
+ mprSetVar(obj, "pipe_name", mprString(name));
+ }
+ return 0;
+}
diff --git a/source4/scripting/libjs/management.js b/source4/scripting/libjs/management.js
index e1c68ca1de..26c1c0a34a 100644
--- a/source4/scripting/libjs/management.js
+++ b/source4/scripting/libjs/management.js
@@ -10,16 +10,15 @@
*/
function smbsrv_sessions()
{
- var conn = new Object();
var irpc = irpc_init();
- status = irpc_connect(conn, "smb_server");
+ status = irpc.connect("smb_server");
if (status.is_ok != true) {
return undefined;
}
var io = irpcObj();
io.input.level = irpc.SMBSRV_INFO_SESSIONS;
- status = irpc.smbsrv_information(conn, io);
+ status = irpc.smbsrv_information(io);
if (status.is_ok != true) {
return undefined;
}
@@ -43,16 +42,15 @@ function smbsrv_sessions()
*/
function smbsrv_trees()
{
- var conn = new Object();
var irpc = irpc_init();
- status = irpc_connect(conn, "smb_server");
+ status = irpc.connect("smb_server");
if (status.is_ok != true) {
return undefined;
}
var io = irpcObj();
io.input.level = irpc.SMBSRV_INFO_TREES;
- status = irpc.smbsrv_information(conn, io);
+ status = irpc.smbsrv_information(io);
if (status.is_ok != true) {
return undefined;
}
@@ -76,16 +74,15 @@ function smbsrv_trees()
*/
function nbtd_statistics()
{
- var conn = new Object();
var irpc = irpc_init();
- status = irpc_connect(conn, "nbt_server");
+ status = irpc.connect("nbt_server");
if (status.is_ok != true) {
return undefined;
}
var io = irpcObj();
io.input.level = irpc.NBTD_INFO_STATISTICS;
- status = irpc.nbtd_information(conn, io);
+ status = irpc.nbtd_information(io);
if (status.is_ok != true) {
return undefined;
}
@@ -113,7 +110,6 @@ function service_enabled(name)
*/
function server_status(name)
{
- var conn = new Object();
var i;
var io;
var irpc = irpc_init();
@@ -122,13 +118,13 @@ function server_status(name)
return "DISABLED";
}
- status = irpc_connect(conn, name + "_server");
+ status = irpc.connect(name + "_server");
if (status.is_ok != true) {
return "DOWN";
}
var io = irpcObj();
- status = irpc.irpc_uptime(conn, io);
+ status = irpc.irpc_uptime(io);
if (status.is_ok != true) {
return "NOT RESPONDING";
}
@@ -141,19 +137,18 @@ function server_status(name)
*/
function stream_server_status(name)
{
- var conn = new Object();
var irpc = irpc_init();
if (!service_enabled(name)) {
return "DISABLED";
}
- status = irpc_connect(conn, name + "_server");
+ status = irpc.connect(name + "_server");
if (status.is_ok != true) {
return "0 connections";
}
var io = irpcObj();
- status = irpc.irpc_uptime(conn, io);
+ status = irpc.irpc_uptime(io);
if (status.is_ok != true) {
return "NOT RESPONDING";
}
diff --git a/source4/scripting/libjs/samr.js b/source4/scripting/libjs/samr.js
index 2363dde686..d0c2b89822 100644
--- a/source4/scripting/libjs/samr.js
+++ b/source4/scripting/libjs/samr.js
@@ -32,12 +32,11 @@ function samArray(output)
*/
function samrConnect(conn)
{
- conn.samr = samr_init();
- conn.sec = security_init();
+ security_init(conn);
var io = irpcObj();
io.input.system_name = NULL;
- io.input.access_mask = conn.sec.SEC_FLAG_MAXIMUM_ALLOWED;
- var status = conn.samr.samr_Connect2(conn, io);
+ io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
+ var status = conn.samr_Connect2(io);
check_status_ok(status);
return io.output.connect_handle;
}
@@ -49,7 +48,7 @@ function samrClose(conn, handle)
{
var io = irpcObj();
io.input.handle = handle;
- var status = conn.samr.samr_Close(conn, io);
+ var status = conn.samr_Close(io);
check_status_ok(status);
}
@@ -61,7 +60,7 @@ function samrLookupDomain(conn, handle, domain)
var io = irpcObj();
io.input.connect_handle = handle;
io.input.domain_name = domain;
- var status = conn.samr.samr_LookupDomain(conn, io);
+ var status = conn.samr_LookupDomain(io);
check_status_ok(status);
return io.output.sid;
}
@@ -73,9 +72,9 @@ function samrOpenDomain(conn, handle, sid)
{
var io = irpcObj();
io.input.connect_handle = handle;
- io.input.access_mask = conn.sec.SEC_FLAG_MAXIMUM_ALLOWED;
+ io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
io.input.sid = sid;
- var status = conn.samr.samr_OpenDomain(conn, io);
+ var status = conn.samr_OpenDomain(io);
check_status_ok(status);
return io.output.domain_handle;
}
@@ -87,9 +86,9 @@ function samrOpenUser(conn, handle, rid)
{
var io = irpcObj();
io.input.domain_handle = handle;
- io.input.access_mask = conn.sec.SEC_FLAG_MAXIMUM_ALLOWED;
+ io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
io.input.rid = rid;
- var status = conn.samr.samr_OpenUser(conn, io);
+ var status = conn.samr_OpenUser(io);
check_status_ok(status);
return io.output.user_handle;
}
@@ -104,7 +103,7 @@ function samrEnumDomainUsers(conn, dom_handle)
io.input.resume_handle = 0;
io.input.acct_flags = 0;
io.input.max_size = -1;
- var status = conn.samr.samr_EnumDomainUsers(conn, io);
+ var status = conn.samr_EnumDomainUsers(io);
check_status_ok(status);
return samArray(io.output);
}
@@ -119,7 +118,7 @@ function samrEnumDomainGroups(conn, dom_handle)
io.input.resume_handle = 0;
io.input.acct_flags = 0;
io.input.max_size = -1;
- var status = conn.samr.samr_EnumDomainGroups(conn, io);
+ var status = conn.samr_EnumDomainGroups(io);
check_status_ok(status);
return samArray(io.output);
}
@@ -133,7 +132,7 @@ function samrEnumDomains(conn, handle)
io.input.connect_handle = handle;
io.input.resume_handle = 0;
io.input.buf_size = -1;
- var status = conn.samr.samr_EnumDomains(conn, io);
+ var status = conn.samr_EnumDomains(io);
check_status_ok(status);
return samArray(io.output);
}
@@ -146,7 +145,7 @@ function samrQueryUserInfo(conn, user_handle, level)
var r, io = irpcObj();
io.input.user_handle = user_handle;
io.input.level = level;
- var status = conn.samr.samr_QueryUserInfo(conn, io);
+ var status = conn.samr_QueryUserInfo(io);
check_status_ok(status);
return io.output.info.info3;
}
@@ -160,8 +159,8 @@ function samrFillUserInfo(conn, dom_handle, users, level)
var i;
for (i=0;i<users.length;i++) {
var r, user_handle, info;
- user_handle = samrOpenUser(conn, dom_handle, users[i].idx);
- info = samrQueryUserInfo(conn, user_handle, level);
+ user_handle = samrOpenUser(dom_handle, users[i].idx);
+ info = samrQueryUserInfo(user_handle, level);
info.name = users[i].name;
info.idx = users[i].idx;
users[i] = info;
diff --git a/swat/esptest/samr.esp b/swat/esptest/samr.esp
index 65902e0ce4..a60a02e7c8 100644
--- a/swat/esptest/samr.esp
+++ b/swat/esptest/samr.esp
@@ -7,9 +7,9 @@
<h1>Samba4 samr rpc test</h1>
<%
-var conn = new Object();
+var conn = samr_init();
var binding = "ncalrpc:";
-status = rpc_connect(conn, binding, "samr");
+status = conn.connect(binding);
check_status_ok(status);
handle = samrConnect(conn);
diff --git a/testprogs/ejs/echo.js b/testprogs/ejs/echo.js
index d464f8623e..aa44ca7eb0 100755
--- a/testprogs/ejs/echo.js
+++ b/testprogs/ejs/echo.js
@@ -16,8 +16,6 @@ if (ok == false) {
libinclude("base.js");
-echo = rpcecho_init();
-
/*
generate a ramp as an integer array
*/
@@ -34,7 +32,7 @@ function ramp_array(N)
/*
test the echo_AddOne interface
*/
-function test_AddOne(conn)
+function test_AddOne(echo)
{
var io = irpcObj();
@@ -42,7 +40,7 @@ function test_AddOne(conn)
for (i=0;i<10;i++) {
io.input.in_data = i;
- status = echo.echo_AddOne(conn, io);
+ status = echo.echo_AddOne(io);
check_status_ok(status);
assert(io.output.out_data == i + 1);
}
@@ -51,7 +49,7 @@ function test_AddOne(conn)
/*
test the echo_EchoData interface
*/
-function test_EchoData(conn)
+function test_EchoData(echo)
{
var io = irpcObj();
@@ -60,7 +58,7 @@ function test_EchoData(conn)
for (i=0; i<30; i=i+5) {
io.input.len = i;
io.input.in_data = ramp_array(i);
- status = echo.echo_EchoData(conn, io);
+ status = echo.echo_EchoData(io);
check_status_ok(status);
check_array_equal(io.input.in_data, io.output.out_data);
}
@@ -70,7 +68,7 @@ function test_EchoData(conn)
/*
test the echo_SinkData interface
*/
-function test_SinkData(conn)
+function test_SinkData(echo)
{
var io = irpcObj();
@@ -79,7 +77,7 @@ function test_SinkData(conn)
for (i=0; i<30; i=i+5) {
io.input.len = i;
io.input.data = ramp_array(i);
- status = echo.echo_SinkData(conn, io);
+ status = echo.echo_SinkData(io);
check_status_ok(status);
}
}
@@ -88,7 +86,7 @@ function test_SinkData(conn)
/*
test the echo_SourceData interface
*/
-function test_SourceData(conn)
+function test_SourceData(echo)
{
var io = irpcObj();
@@ -96,7 +94,7 @@ function test_SourceData(conn)
for (i=0; i<30; i=i+5) {
io.input.len = i;
- status = echo.echo_SourceData(conn, io);
+ status = echo.echo_SourceData(io);
check_status_ok(status);
correct = ramp_array(i);
check_array_equal(correct, io.output.data);
@@ -107,14 +105,14 @@ function test_SourceData(conn)
/*
test the echo_TestCall interface
*/
-function test_TestCall(conn)
+function test_TestCall(echo)
{
var io = irpcObj();
print("Testing echo_TestCall\n");
io.input.s1 = "my test string";
- status = echo.echo_TestCall(conn, io);
+ status = echo.echo_TestCall(io);
check_status_ok(status);
assert("this is a test string" == io.output.s2);
}
@@ -122,7 +120,7 @@ function test_TestCall(conn)
/*
test the echo_TestCall2 interface
*/
-function test_TestCall2(conn)
+function test_TestCall2(echo)
{
var io = irpcObj();
@@ -130,7 +128,7 @@ function test_TestCall2(conn)
for (i=1;i<=7;i++) {
io.input.level = i;
- status = echo.echo_TestCall2(conn, io);
+ status = echo.echo_TestCall2(io);
check_status_ok(status);
}
}
@@ -138,21 +136,21 @@ function test_TestCall2(conn)
/*
test the echo_TestSleep interface
*/
-function test_TestSleep(conn)
+function test_TestSleep(echo)
{
var io = irpcObj();
print("Testing echo_TestSleep\n");
io.input.seconds = 1;
- status = echo.echo_TestSleep(conn, io);
+ status = echo.echo_TestSleep(io);
check_status_ok(status);
}
/*
test the echo_TestEnum interface
*/
-function test_TestEnum(conn)
+function test_TestEnum(echo)
{
var io = irpcObj();
@@ -164,7 +162,7 @@ function test_TestEnum(conn)
io.input.foo2.e2 = echo.ECHO_ENUM1_32;
io.input.foo3 = new Object();
io.input.foo3.e1 = echo.ECHO_ENUM2;
- status = echo.echo_TestEnum(conn, io);
+ status = echo.echo_TestEnum(io);
check_status_ok(status);
assert(io.output.foo1 == echo.ECHO_ENUM1);
assert(io.output.foo2.e1 == echo.ECHO_ENUM2);
@@ -175,7 +173,7 @@ function test_TestEnum(conn)
/*
test the echo_TestSurrounding interface
*/
-function test_TestSurrounding(conn)
+function test_TestSurrounding(echo)
{
var io = irpcObj();
@@ -184,7 +182,7 @@ function test_TestSurrounding(conn)
io.input.data = new Object();
io.input.data.x = 10;
io.input.data.surrounding = ramp_array(10);
- status = echo.echo_TestSurrounding(conn, io);
+ status = echo.echo_TestSurrounding(io);
check_status_ok(status);
assert(io.output.data.surrounding.length == 20);
check_array_zero(io.output.data.surrounding);
@@ -193,48 +191,43 @@ function test_TestSurrounding(conn)
/*
test the echo_TestDoublePointer interface
*/
-function test_TestDoublePointer(conn)
+function test_TestDoublePointer(echo)
{
var io = irpcObj();
print("Testing echo_TestDoublePointer\n");
io.input.data = 7;
- status = echo.echo_TestDoublePointer(conn, io);
+ status = echo.echo_TestDoublePointer(io);
check_status_ok(status);
assert(io.input.data == io.input.data);
}
-if (ARGV.length == 0) {
- print("Usage: echo.js <RPCBINDING>\n");
- exit(0);
-}
-
if (options.ARGV.length != 1) {
- println("Usage: samr.js <BINDING>");
+ println("Usage: echo.js <BINDING>");
return -1;
}
var binding = options.ARGV[0];
-var conn = new Object();
+var echo = rpcecho_init();
print("Connecting to " + binding + "\n");
-status = rpc_connect(conn, binding, "rpcecho");
+status = echo.connect(binding);
if (status.is_ok != true) {
- print("Failed to connect to " + binding + " - " + status.errstr + "\n");
+ printf("Failed to connect to %s - %s\n", binding, status.errstr);
return;
}
-test_AddOne(conn);
-test_EchoData(conn);
-test_SinkData(conn);
-test_SourceData(conn);
-test_TestCall(conn);
-test_TestCall2(conn);
-test_TestSleep(conn);
-test_TestEnum(conn);
-test_TestSurrounding(conn);
-test_TestDoublePointer(conn);
+test_AddOne(echo);
+test_EchoData(echo);
+test_SinkData(echo);
+test_SourceData(echo);
+test_TestCall(echo);
+test_TestCall2(echo);
+test_TestSleep(echo);
+test_TestEnum(echo);
+test_TestSurrounding(echo);
+test_TestDoublePointer(echo);
print("All OK\n");
return 0;
diff --git a/testprogs/ejs/samr.js b/testprogs/ejs/samr.js
index d0c2990158..b518fea234 100755
--- a/testprogs/ejs/samr.js
+++ b/testprogs/ejs/samr.js
@@ -21,39 +21,39 @@ libinclude("samr.js");
/*
test the samr_Connect interface
*/
-function test_Connect(conn)
+function test_Connect(samr)
{
print("Testing samr_Connect\n");
- return samrConnect(conn);
+ return samrConnect(samr);
}
/*
test the samr_LookupDomain interface
*/
-function test_LookupDomain(conn, handle, domain)
+function test_LookupDomain(samr, handle, domain)
{
print("Testing samr_LookupDomain\n");
- return samrLookupDomain(conn, handle, domain);
+ return samrLookupDomain(samr, handle, domain);
}
/*
test the samr_OpenDomain interface
*/
-function test_OpenDomain(conn, handle, sid)
+function test_OpenDomain(samr, handle, sid)
{
print("Testing samr_OpenDomain\n");
- return samrOpenDomain(conn, handle, sid);
+ return samrOpenDomain(samr, handle, sid);
}
/*
test the samr_EnumDomainUsers interface
*/
-function test_EnumDomainUsers(conn, dom_handle)
+function test_EnumDomainUsers(samr, dom_handle)
{
var i, users;
print("Testing samr_EnumDomainUsers\n");
- users = samrEnumDomainUsers(conn, dom_handle);
+ users = samrEnumDomainUsers(samr, dom_handle);
print("Found " + users.length + " users\n");
for (i=0;i<users.length;i++) {
println("\t" + users[i].name + "\t(" + users[i].idx + ")");
@@ -63,10 +63,10 @@ function test_EnumDomainUsers(conn, dom_handle)
/*
test the samr_EnumDomainGroups interface
*/
-function test_EnumDomainGroups(conn, dom_handle)
+function test_EnumDomainGroups(samr, dom_handle)
{
print("Testing samr_EnumDomainGroups\n");
- var i, groups = samrEnumDomainGroups(conn, dom_handle);
+ var i, groups = samrEnumDomainGroups(samr, dom_handle);
print("Found " + groups.length + " groups\n");
for (i=0;i<groups.length;i++) {
println("\t" + groups[i].name + "\t(" + groups[i].idx + ")");
@@ -76,10 +76,10 @@ function test_EnumDomainGroups(conn, dom_handle)
/*
test domain specific ops
*/
-function test_domain_ops(conn, dom_handle)
+function test_domain_ops(samr, dom_handle)
{
- test_EnumDomainUsers(conn, dom_handle);
- test_EnumDomainGroups(conn, dom_handle);
+ test_EnumDomainUsers(samr, dom_handle);
+ test_EnumDomainGroups(samr, dom_handle);
}
@@ -87,22 +87,22 @@ function test_domain_ops(conn, dom_handle)
/*
test the samr_EnumDomains interface
*/
-function test_EnumDomains(conn, handle)
+function test_EnumDomains(samr, handle)
{
var i, domains;
print("Testing samr_EnumDomains\n");
- domains = samrEnumDomains(conn, handle);
+ domains = samrEnumDomains(samr, handle);
print("Found " + domains.length + " domains\n");
for (i=0;i<domains.length;i++) {
print("\t" + domains[i].name + "\n");
}
for (i=0;i<domains.length;i++) {
print("Testing domain " + domains[i].name + "\n");
- sid = samrLookupDomain(conn, handle, domains[i].name);
- dom_handle = test_OpenDomain(conn, handle, sid);
- test_domain_ops(conn, dom_handle);
- samrClose(conn, dom_handle);
+ sid = samrLookupDomain(samr, handle, domains[i].name);
+ dom_handle = test_OpenDomain(samr, handle, sid);
+ test_domain_ops(samr, dom_handle);
+ samrClose(samr, dom_handle);
}
}
@@ -111,18 +111,18 @@ if (options.ARGV.length != 1) {
return -1;
}
var binding = options.ARGV[0];
-var conn = new Object();
+var samr = samr_init();
print("Connecting to " + binding + "\n");
-status = rpc_connect(conn, binding, "samr");
+status = samr.connect(binding);
if (status.is_ok != true) {
print("Failed to connect to " + binding + " - " + status.errstr + "\n");
return -1;
}
-handle = test_Connect(conn);
-test_EnumDomains(conn, handle);
-samrClose(conn, handle);
+handle = test_Connect(samr);
+test_EnumDomains(samr, handle);
+samrClose(samr, handle);
print("All OK\n");
return 0;