2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-1997,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6 * Copyright (C) Paul Ashton 1997,
7 * Copyright (C) Jeremy Allison 1998-2001,
8 * Copyright (C) Anthony Liguori 2003.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /* This is the interface to the netlogon pipe. */
30 #define DBGC_CLASS DBGC_RPC_SRV
32 /*************************************************************************
34 *************************************************************************/
36 static BOOL api_net_req_chal(pipes_struct *p)
40 prs_struct *data = &p->in_data.data;
41 prs_struct *rdata = &p->out_data.rdata;
46 /* grab the challenge... */
47 if(!net_io_q_req_chal("", &q_u, data, 0)) {
48 DEBUG(0,("api_net_req_chal: Failed to unmarshall NET_Q_REQ_CHAL.\n"));
52 r_u.status = _net_req_chal(p, &q_u, &r_u);
54 /* store the response in the SMB stream */
55 if(!net_io_r_req_chal("", &r_u, rdata, 0)) {
56 DEBUG(0,("api_net_req_chal: Failed to marshall NET_R_REQ_CHAL.\n"));
63 /*************************************************************************
65 *************************************************************************/
67 static BOOL api_net_auth(pipes_struct *p)
71 prs_struct *data = &p->in_data.data;
72 prs_struct *rdata = &p->out_data.rdata;
77 /* grab the challenge... */
78 if(!net_io_q_auth("", &q_u, data, 0)) {
79 DEBUG(0,("api_net_auth: Failed to unmarshall NET_Q_AUTH.\n"));
83 r_u.status = _net_auth(p, &q_u, &r_u);
85 /* store the response in the SMB stream */
86 if(!net_io_r_auth("", &r_u, rdata, 0)) {
87 DEBUG(0,("api_net_auth: Failed to marshall NET_R_AUTH.\n"));
94 /*************************************************************************
96 *************************************************************************/
98 static BOOL api_net_auth_2(pipes_struct *p)
102 prs_struct *data = &p->in_data.data;
103 prs_struct *rdata = &p->out_data.rdata;
108 /* grab the challenge... */
109 if(!net_io_q_auth_2("", &q_u, data, 0)) {
110 DEBUG(0,("api_net_auth_2: Failed to unmarshall NET_Q_AUTH_2.\n"));
114 r_u.status = _net_auth_2(p, &q_u, &r_u);
116 /* store the response in the SMB stream */
117 if(!net_io_r_auth_2("", &r_u, rdata, 0)) {
118 DEBUG(0,("api_net_auth_2: Failed to marshall NET_R_AUTH_2.\n"));
125 /*************************************************************************
127 *************************************************************************/
129 static BOOL api_net_srv_pwset(pipes_struct *p)
133 prs_struct *data = &p->in_data.data;
134 prs_struct *rdata = &p->out_data.rdata;
139 /* grab the challenge and encrypted password ... */
140 if(!net_io_q_srv_pwset("", &q_u, data, 0)) {
141 DEBUG(0,("api_net_srv_pwset: Failed to unmarshall NET_Q_SRV_PWSET.\n"));
145 r_u.status = _net_srv_pwset(p, &q_u, &r_u);
147 /* store the response in the SMB stream */
148 if(!net_io_r_srv_pwset("", &r_u, rdata, 0)) {
149 DEBUG(0,("api_net_srv_pwset: Failed to marshall NET_R_SRV_PWSET.\n"));
156 /*************************************************************************
158 *************************************************************************/
160 static BOOL api_net_sam_logoff(pipes_struct *p)
162 NET_Q_SAM_LOGOFF q_u;
163 NET_R_SAM_LOGOFF r_u;
164 prs_struct *data = &p->in_data.data;
165 prs_struct *rdata = &p->out_data.rdata;
170 if(!net_io_q_sam_logoff("", &q_u, data, 0)) {
171 DEBUG(0,("api_net_sam_logoff: Failed to unmarshall NET_Q_SAM_LOGOFF.\n"));
175 r_u.status = _net_sam_logoff(p, &q_u, &r_u);
177 /* store the response in the SMB stream */
178 if(!net_io_r_sam_logoff("", &r_u, rdata, 0)) {
179 DEBUG(0,("api_net_sam_logoff: Failed to marshall NET_R_SAM_LOGOFF.\n"));
186 /*************************************************************************
188 *************************************************************************/
190 static BOOL api_net_sam_logon(pipes_struct *p)
194 prs_struct *data = &p->in_data.data;
195 prs_struct *rdata = &p->out_data.rdata;
200 if(!net_io_q_sam_logon("", &q_u, data, 0)) {
201 DEBUG(0, ("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n"));
205 r_u.status = _net_sam_logon(p, &q_u, &r_u);
207 /* store the response in the SMB stream */
208 if(!net_io_r_sam_logon("", &r_u, rdata, 0)) {
209 DEBUG(0,("api_net_sam_logon: Failed to marshall NET_R_SAM_LOGON.\n"));
216 /*************************************************************************
217 api_net_trust_dom_list:
218 *************************************************************************/
220 static BOOL api_net_trust_dom_list(pipes_struct *p)
222 NET_Q_TRUST_DOM_LIST q_u;
223 NET_R_TRUST_DOM_LIST r_u;
224 prs_struct *data = &p->in_data.data;
225 prs_struct *rdata = &p->out_data.rdata;
230 DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__));
232 /* grab the lsa trusted domain list query... */
233 if(!net_io_q_trust_dom("", &q_u, data, 0)) {
234 DEBUG(0,("api_net_trust_dom_list: Failed to unmarshall NET_Q_TRUST_DOM_LIST.\n"));
238 /* construct reply. */
239 r_u.status = _net_trust_dom_list(p, &q_u, &r_u);
241 /* store the response in the SMB stream */
242 if(!net_io_r_trust_dom("", &r_u, rdata, 0)) {
243 DEBUG(0,("net_reply_trust_dom_list: Failed to marshall NET_R_TRUST_DOM_LIST.\n"));
247 DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__));
252 /*************************************************************************
254 *************************************************************************/
256 static BOOL api_net_logon_ctrl2(pipes_struct *p)
258 NET_Q_LOGON_CTRL2 q_u;
259 NET_R_LOGON_CTRL2 r_u;
260 prs_struct *data = &p->in_data.data;
261 prs_struct *rdata = &p->out_data.rdata;
266 DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__));
268 /* grab the lsa netlogon ctrl2 query... */
269 if(!net_io_q_logon_ctrl2("", &q_u, data, 0)) {
270 DEBUG(0,("api_net_logon_ctrl2: Failed to unmarshall NET_Q_LOGON_CTRL2.\n"));
274 r_u.status = _net_logon_ctrl2(p, &q_u, &r_u);
276 if(!net_io_r_logon_ctrl2("", &r_u, rdata, 0)) {
277 DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL2.\n"));
281 DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__));
286 /*************************************************************************
288 *************************************************************************/
290 static BOOL api_net_logon_ctrl(pipes_struct *p)
292 NET_Q_LOGON_CTRL q_u;
293 NET_R_LOGON_CTRL r_u;
294 prs_struct *data = &p->in_data.data;
295 prs_struct *rdata = &p->out_data.rdata;
300 DEBUG(6,("api_net_logon_ctrl: %d\n", __LINE__));
302 /* grab the lsa netlogon ctrl query... */
303 if(!net_io_q_logon_ctrl("", &q_u, data, 0)) {
304 DEBUG(0,("api_net_logon_ctrl: Failed to unmarshall NET_Q_LOGON_CTRL.\n"));
308 r_u.status = _net_logon_ctrl(p, &q_u, &r_u);
310 if(!net_io_r_logon_ctrl("", &r_u, rdata, 0)) {
311 DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL2.\n"));
315 DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__));
320 /*******************************************************************
321 array of \PIPE\NETLOGON operations
322 ********************************************************************/
324 #ifdef RPC_NETLOG_DYNAMIC
325 int rpc_pipe_init(void)
327 int rpc_net_init(void)
330 static struct api_struct api_net_cmds [] =
332 { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal },
333 { "NET_AUTH" , NET_AUTH , api_net_auth },
334 { "NET_AUTH2" , NET_AUTH2 , api_net_auth_2 },
335 { "NET_SRVPWSET" , NET_SRVPWSET , api_net_srv_pwset },
336 { "NET_SAMLOGON" , NET_SAMLOGON , api_net_sam_logon },
337 { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff },
338 { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 },
339 { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list },
340 { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl }
343 return rpc_pipe_register_commands("NETLOGON", "lsass", api_net_cmds,
344 sizeof(api_net_cmds) / sizeof(struct api_struct));