summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
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);