2 Unix SMB/Netbios implementation.
4 SMB client password change routine
5 Copyright (C) Andrew Tridgell 1994-1998
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 extern pstring global_myname;
28 /*************************************************************
29 change a password on a remote machine using IPC calls
30 *************************************************************/
31 BOOL remote_password_change(const char *remote_machine, const char *user_name,
32 const char *old_passwd, const char *new_passwd)
34 struct nmb_name calling, called;
38 if(!resolve_name( remote_machine, &ip, 0x20)) {
39 fprintf(stderr, "unable to find an IP address for machine %s.\n",
46 if (!cli_initialise(&cli) || !cli_connect(&cli, remote_machine, &ip)) {
47 fprintf(stderr, "unable to connect to SMB server on machine %s. Error was : %s.\n",
48 remote_machine, cli_errstr(&cli) );
52 make_nmb_name(&calling, global_myname , 0x0 , scope);
53 make_nmb_name(&called , remote_machine, 0x20, scope);
55 if (!cli_session_request(&cli, &calling, &called)) {
56 fprintf(stderr, "machine %s rejected the session setup. Error was : %s.\n",
57 remote_machine, cli_errstr(&cli) );
62 cli.protocol = PROTOCOL_NT1;
64 if (!cli_negprot(&cli)) {
65 fprintf(stderr, "machine %s rejected the negotiate protocol. Error was : %s.\n",
66 remote_machine, cli_errstr(&cli) );
72 * We should connect as the anonymous user here, in case
73 * the server has "must change password" checked...
74 * Thanks to <Nicholas.S.Jenkins@cdc.com> for this fix.
77 if (!cli_session_setup(&cli, "", "", 0, "", 0, "")) {
78 fprintf(stderr, "machine %s rejected the session setup. Error was : %s.\n",
79 remote_machine, cli_errstr(&cli) );
84 if (!cli_send_tconX(&cli, "IPC$", "IPC", "", 1)) {
85 fprintf(stderr, "machine %s rejected the tconX on the IPC$ share. Error was : %s.\n",
86 remote_machine, cli_errstr(&cli) );
91 if(!cli_oem_change_password(&cli, user_name, new_passwd, old_passwd)) {
92 fprintf(stderr, "machine %s rejected the password change: Error was : %s.\n",
93 remote_machine, cli_errstr(&cli) );