diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-06-24 16:26:23 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-06-24 16:26:23 +1000 |
commit | 6da26870e0ae5acd6ff49a30ec2f6886b44d095e (patch) | |
tree | 850c71039563c16a5d563c47e7ba2ab645baf198 /source3/libsmb/passchange.c | |
parent | 6925a799d04c6fa59dd2ddef1f5510f9bb7d17d1 (diff) | |
parent | 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 (diff) | |
download | samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.tar.gz samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.tar.bz2 samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.zip |
Merge 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 as Samba-4.0alpha16
Diffstat (limited to 'source3/libsmb/passchange.c')
-rw-r--r-- | source3/libsmb/passchange.c | 53 |
1 files changed, 13 insertions, 40 deletions
diff --git a/source3/libsmb/passchange.c b/source3/libsmb/passchange.c index d37389a485..bf2103db68 100644 --- a/source3/libsmb/passchange.c +++ b/source3/libsmb/passchange.c @@ -2,17 +2,17 @@ Unix SMB/CIFS implementation. SMB client password change routine Copyright (C) Andrew Tridgell 1994-1998 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -21,6 +21,7 @@ #include "../librpc/gen_ndr/ndr_samr.h" #include "rpc_client/cli_pipe.h" #include "rpc_client/cli_samr.h" +#include "libsmb/libsmb.h" #include "libsmb/clirap.h" #include "libsmb/nmblib.h" @@ -32,10 +33,8 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam const char *old_passwd, const char *new_passwd, char **err_str) { - struct nmb_name calling, called; struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_hnd = NULL; - struct sockaddr_storage ss; char *user, *domain, *p; NTSTATUS result; @@ -56,41 +55,14 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam *err_str = NULL; - if(!resolve_name( remote_machine, &ss, 0x20, false)) { - if (asprintf(err_str, "Unable to find an IP address for machine " - "%s.\n", remote_machine) == -1) { - *err_str = NULL; - } - return NT_STATUS_UNSUCCESSFUL; - } - - cli = cli_initialise(); - if (!cli) { - return NT_STATUS_NO_MEMORY; - } - - result = cli_connect(cli, remote_machine, &ss); + result = cli_connect_nb(remote_machine, NULL, 0, 0x20, NULL, + Undefined, &cli); if (!NT_STATUS_IS_OK(result)) { if (asprintf(err_str, "Unable to connect to SMB server on " "machine %s. Error was : %s.\n", remote_machine, nt_errstr(result))==-1) { *err_str = NULL; } - cli_shutdown(cli); - return result; - } - - make_nmb_name(&calling, global_myname() , 0x0); - make_nmb_name(&called , remote_machine, 0x20); - - if (!cli_session_request(cli, &calling, &called)) { - if (asprintf(err_str, "machine %s rejected the session setup. " - "Error was : %s.\n", - remote_machine, cli_errstr(cli)) == -1) { - *err_str = NULL; - } - result = cli_nt_error(cli); - cli_shutdown(cli); return result; } @@ -125,7 +97,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam if (!NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_MUST_CHANGE) && !NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_EXPIRED)) { if (asprintf(err_str, "Could not connect to machine %s: " - "%s\n", remote_machine, cli_errstr(cli)) == -1) { + "%s\n", remote_machine, nt_errstr(result)) == -1) { *err_str = NULL; } cli_shutdown(cli); @@ -145,7 +117,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam if (!NT_STATUS_IS_OK(result)) { if (asprintf(err_str, "machine %s rejected the session " "setup. Error was : %s.\n", - remote_machine, cli_errstr(cli)) == -1) { + remote_machine, nt_errstr(result)) == -1) { *err_str = NULL; } cli_shutdown(cli); @@ -203,12 +175,12 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam if (lp_client_lanman_auth()) { /* Use the old RAP method. */ if (!cli_oem_change_password(cli, user_name, new_passwd, old_passwd)) { + result = cli_nt_error(cli); if (asprintf(err_str, "machine %s rejected the " "password change: Error was : %s.\n", - remote_machine, cli_errstr(cli)) == -1) { + remote_machine, nt_errstr(result)) == -1) { *err_str = NULL; } - result = cli_nt_error(cli); cli_shutdown(cli); return result; } @@ -294,12 +266,13 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam cli_shutdown(cli); return NT_STATUS_OK; } + + result = cli_nt_error(cli); if (asprintf(err_str, "machine %s rejected the password " "change: Error was : %s.\n", - remote_machine, cli_errstr(cli)) == -1) { + remote_machine, nt_errstr(result)) == -1) { *err_str = NULL; } - result = cli_nt_error(cli); cli_shutdown(cli); return result; } else { |