| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | SMB client password change routine
|
|---|
| 4 | Copyright (C) Andrew Tridgell 1994-1998
|
|---|
| 5 |
|
|---|
| 6 | This program is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 3 of the License, or
|
|---|
| 9 | (at your option) any later version.
|
|---|
| 10 |
|
|---|
| 11 | This program is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | GNU General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 | #include "includes.h"
|
|---|
| 21 |
|
|---|
| 22 | /*************************************************************
|
|---|
| 23 | Change a password on a remote machine using IPC calls.
|
|---|
| 24 | *************************************************************/
|
|---|
| 25 |
|
|---|
| 26 | NTSTATUS remote_password_change(const char *remote_machine, const char *user_name,
|
|---|
| 27 | const char *old_passwd, const char *new_passwd,
|
|---|
| 28 | char **err_str)
|
|---|
| 29 | {
|
|---|
| 30 | struct nmb_name calling, called;
|
|---|
| 31 | struct cli_state *cli;
|
|---|
| 32 | struct rpc_pipe_client *pipe_hnd;
|
|---|
| 33 | struct sockaddr_storage ss;
|
|---|
| 34 |
|
|---|
| 35 | NTSTATUS result;
|
|---|
| 36 | bool pass_must_change = False;
|
|---|
| 37 |
|
|---|
| 38 | *err_str = NULL;
|
|---|
| 39 |
|
|---|
| 40 | if(!resolve_name( remote_machine, &ss, 0x20)) {
|
|---|
| 41 | asprintf(err_str, "Unable to find an IP address for machine "
|
|---|
| 42 | "%s.\n", remote_machine);
|
|---|
| 43 | return NT_STATUS_UNSUCCESSFUL;
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | cli = cli_initialise();
|
|---|
| 47 | if (!cli) {
|
|---|
| 48 | return NT_STATUS_NO_MEMORY;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | result = cli_connect(cli, remote_machine, &ss);
|
|---|
| 52 | if (!NT_STATUS_IS_OK(result)) {
|
|---|
| 53 | asprintf(err_str, "Unable to connect to SMB server on "
|
|---|
| 54 | "machine %s. Error was : %s.\n",
|
|---|
| 55 | remote_machine, nt_errstr(result));
|
|---|
| 56 | cli_shutdown(cli);
|
|---|
| 57 | return result;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | make_nmb_name(&calling, global_myname() , 0x0);
|
|---|
|
|---|