Fixed interface code so that a UUID is transmitted as the following fields :
[Samba/ekacnet.git] / source / rpcclient / cmd_netlogon.c
blob2c8514b43e8def6fbf45b513d35e87033803ab67
1 /*
2 Unix SMB/Netbios implementation.
3 Version 1.9.
4 NT Domain Authentication SMB / MSRPC client
5 Copyright (C) Andrew Tridgell 1994-1997
6 Copyright (C) Luke Kenneth Casson Leighton 1996-1997
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #ifdef SYSLOG
26 #undef SYSLOG
27 #endif
29 #include "includes.h"
30 #include "nterr.h"
32 extern int DEBUGLEVEL;
34 #define DEBUG_TESTING
36 extern struct cli_state *smb_cli;
38 extern FILE* out_hnd;
41 /****************************************************************************
42 experimental nt login.
43 ****************************************************************************/
44 void cmd_netlogon_login_test(struct client_info *info)
46 extern BOOL global_machine_password_needs_changing;
48 fstring nt_user_name;
49 fstring password;
50 BOOL res = True;
51 char *nt_password;
52 unsigned char trust_passwd[16];
54 #if 0
55 /* machine account passwords */
56 pstring new_mach_pwd;
58 /* initialisation */
59 new_mach_pwd[0] = 0;
60 #endif
62 if (!next_token(NULL, nt_user_name, NULL, sizeof(nt_user_name)))
64 fstrcpy(nt_user_name, smb_cli->user_name);
65 if (nt_user_name[0] == 0)
67 fprintf(out_hnd,"ntlogin: must specify username with anonymous connection\n");
68 return;
72 if (next_token(NULL, password, NULL, sizeof(password)))
74 nt_password = password;
76 else
78 nt_password = getpass("Enter NT Login password:");
81 DEBUG(5,("do_nt_login_test: username %s\n", nt_user_name));
83 res = res ? trust_get_passwd(trust_passwd, smb_cli->domain, info->myhostname) : False;
85 #if 0
86 /* check whether the user wants to change their machine password */
87 res = res ? trust_account_check(info->dest_ip, info->dest_host,
88 info->myhostname, smb_cli->domain,
89 info->mach_acct, new_mach_pwd) : False;
90 #endif
91 /* open NETLOGON session. negotiate credentials */
92 res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON) : False;
94 res = res ? cli_nt_setup_creds(smb_cli, trust_passwd) : False;
96 /* change the machine password? */
97 if (global_machine_password_needs_changing)
99 unsigned char new_trust_passwd[16];
100 generate_random_buffer(new_trust_passwd, 16, True);
101 res = res ? cli_nt_srv_pwset(smb_cli, new_trust_passwd) : False;
103 if (res)
105 global_machine_password_needs_changing = !set_trust_account_password(new_trust_passwd);
108 memset(new_trust_passwd, 0, 16);
111 memset(trust_passwd, 0, 16);
113 /* do an NT login */
114 res = res ? cli_nt_login_interactive(smb_cli,
115 smb_cli->domain, nt_user_name,
116 getuid(), nt_password,
117 &info->dom.ctr, &info->dom.user_info3) : False;
119 /*** clear out the password ***/
120 memset(password, 0, sizeof(password));
122 /* ok! you're logged in! do anything you like, then... */
124 /* do an NT logout */
125 res = res ? cli_nt_logoff(smb_cli, &info->dom.ctr) : False;
127 /* close the session */
128 cli_nt_session_close(smb_cli);
130 fprintf(out_hnd,"cmd_nt_login: login (%s) test succeeded: %s\n",
131 nt_user_name, BOOLSTR(res));