summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2005-06-12 07:03:32 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:18:01 -0500
commitfb3874bfacb7fb7199e415f8ad16598790ec9c36 (patch)
treedab06e21bebedb37e29e79d06903dc03efa84dcf /source4/scripting
parentdb4fd5c43456c1a9eca5a51f6260400c652168d9 (diff)
downloadsamba-fb3874bfacb7fb7199e415f8ad16598790ec9c36.tar.gz
samba-fb3874bfacb7fb7199e415f8ad16598790ec9c36.tar.bz2
samba-fb3874bfacb7fb7199e415f8ad16598790ec9c36.zip
r7505: Add more argument forms for session_setup().
Throw an exception if tree connect fails. (This used to be commit 5b67f2c3d91487fec38b300b4f71792cd9164a78)
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/ejs/smbcalls_cli.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c
index 02459abd4b..b32917515d 100644
--- a/source4/scripting/ejs/smbcalls_cli.c
+++ b/source4/scripting/ejs/smbcalls_cli.c
@@ -89,7 +89,7 @@ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv)
/* Perform a session setup:
- session_setup(conn, "DOMAIN\USERNAME%PASSWORD");
+ session_setup(conn, "DOMAIN\\USERNAME%PASSWORD");
session_setup(conn, USERNAME, PASSWORD);
session_setup(conn, DOMAIN, USERNAME, PASSWORD);
session_setup(conn); // anonymous
@@ -149,6 +149,34 @@ static int ejs_cli_ssetup(MprVarHandle eid, int argc, MprVar **argv)
cli_credentials_set_password(creds, argv[3]->string,
CRED_SPECIFIED);
+ } else if (argc == 3) {
+
+ /* USERNAME, PASSWORD form */
+
+ if (!mprVarIsString(argv[1]->type)) {
+ ejsSetErrorMsg(eid, "arg1 must be a string");
+ goto done;
+ }
+
+ cli_credentials_set_username(creds, argv[1]->string,
+ CRED_SPECIFIED);
+
+ if (!mprVarIsString(argv[2]->type)) {
+
+ ejsSetErrorMsg(eid, "arg2 must be a string");
+ goto done;
+ }
+
+ cli_credentials_set_password(creds, argv[2]->string,
+ CRED_SPECIFIED);
+
+ } else if (argc == 2) {
+
+ /* DOMAIN/USERNAME%PASSWORD form */
+
+ cli_credentials_parse_string(creds, argv[1]->string,
+ CRED_SPECIFIED);
+
} else {
/* Anonymous connection */
@@ -255,6 +283,11 @@ static int ejs_cli_tcon(MprVarHandle eid, int argc, MprVar **argv)
status = smb_tree_connect(tree, mem_ctx, &tcon);
+ if (!NT_STATUS_IS_OK(status)) {
+ ejsSetErrorMsg(eid, "session setup: %s", nt_errstr(status));
+ return -1;
+ }
+
tree->tid = tcon.tconx.out.tid;
talloc_free(mem_ctx);