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);
84 /***************************************************************************
85 Synchronise SAM Database (requires SEC_CHAN_BDC).
86 ****************************************************************************/
87 BOOL cli_net_sam_sync(struct cli_state *cli, TALLOC_CTX *mem_ctx,
88 char *srv_name, uint32 database_id, uint32 *num_deltas,
89 SAM_DELTA_HDR *hdr_deltas, SAM_DELTA_CTR *deltas)
91 prs_struct qbuf, rbuf;
94 uint32 result = NT_STATUS_UNSUCCESSFUL;
95 DOM_CRED new_clnt_cred;
101 /* Initialise parse structures */
103 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
104 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
106 /* Initialise input parameters */
108 init_q_sam_sync(&q, srv_name, cli->clnt_name_slash, &new_clnt_cred,
111 /* Marshall data and send request */
113 if (!net_io_q_sam_sync("", &q, &qbuf, 0) ||
114 !rpc_api_pipe_req(cli, NET_SAM_SYNC, &qbuf, &rbuf)) {
118 r.hdr_deltas = hdr_deltas;
121 if (!net_io_r_sam_sync("", sess_key, &r, &rbuf, 0)) {
125 if ((result = r.status) != NT_STATUS_NOPROBLEMO) {
130 /* Update the credentials. */
131 if (ok && !cli_con_deal_with_creds(con, &(r_s.srv_creds)))
133 *num_deltas = r_s.num_deltas2;