2 Unix SMB/Netbios implementation.
4 NT Domain Authentication SMB / MSRPC client
5 Copyright (C) Andrew Tridgell 1994-2000
6 Copyright (C) Luke Kenneth Casson Leighton 1996-2000
7 Copyright (C) Tim Potter 2001
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 /* Opens a SMB connection to the netlogon pipe */
28 struct cli_state
*cli_netlogon_initialise(struct cli_state
*cli
,
30 struct ntuser_creds
*creds
)
32 struct in_addr dest_ip
;
33 struct nmb_name calling
, called
;
35 extern pstring global_myname
;
36 struct ntuser_creds anon
;
38 /* Initialise cli_state information */
40 if (!cli_initialise(cli
)) {
46 anon
.pwd
.null_pwd
= 1;
50 cli_init_creds(cli
, creds
);
52 /* Establish a SMB connection */
54 if (!resolve_srv_name(system_name
, dest_host
, &dest_ip
)) {
58 make_nmb_name(&called
, dns_to_netbios_name(dest_host
), 0x20);
59 make_nmb_name(&calling
, dns_to_netbios_name(global_myname
), 0);
61 if (!cli_establish_connection(cli
, dest_host
, &dest_ip
, &calling
,
62 &called
, "IPC$", "IPC", False
, True
)) {
66 /* Open a NT session thingy */
68 if (!cli_nt_session_open(cli
, PIPE_NETLOGON
)) {
76 /* Shut down a SMB connection to the netlogon pipe */
78 void cli_netlogon_shutdown(struct cli_state
*cli
)
80 if (cli
->fd
!= -1) cli_ulogoff(cli
);
86 uint32
cli_netlogon_logon_ctrl2(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
89 prs_struct qbuf
, rbuf
;
92 uint32 result
= NT_STATUS_UNSUCCESSFUL
;
97 /* Initialise parse structures */
99 prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
);
100 prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
);
102 /* Initialise input parameters */
104 init_net_q_logon_ctrl2(&q
, cli
->srv_name_slash
, query_level
);
106 /* Marshall data and send request */
108 if (!net_io_q_logon_ctrl2("", &q
, &qbuf
, 0) ||
109 !rpc_api_pipe_req(cli
, NET_LOGON_CTRL2
, &qbuf
, &rbuf
)) {
110 result
= NT_STATUS_UNSUCCESSFUL
;
114 /* Unmarshall response */
116 if (!net_io_r_logon_ctrl2("", &r
, &rbuf
, 0)) {
117 result
= NT_STATUS_UNSUCCESSFUL
;