2 * Unix SMB/Netbios implementation.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-1997,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7 * Copyright (C) Paul Ashton 1997.
8 * Copyright (C) Jeremy Allison 1998-2001.
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. */
29 /*************************************************************************
31 *************************************************************************/
33 static BOOL api_net_req_chal(pipes_struct *p)
37 prs_struct *data = &p->in_data.data;
38 prs_struct *rdata = &p->out_data.rdata;
43 /* grab the challenge... */
44 if(!net_io_q_req_chal("", &q_u, data, 0)) {
45 DEBUG(0,("api_net_req_chal: Failed to unmarshall NET_Q_REQ_CHAL.\n"));
49 r_u.status = _net_req_chal(p, &q_u, &r_u);
51 /* store the response in the SMB stream */
52 if(!net_io_r_req_chal("", &r_u, rdata, 0)) {
53 DEBUG(0,("api_net_req_chal: Failed to marshall NET_R_REQ_CHAL.\n"));
60 /*************************************************************************
62 *************************************************************************/
64 static BOOL api_net_auth(pipes_struct *p)
68 prs_struct *data = &p->in_data.data;
69 prs_struct *rdata = &p->out_data.rdata;
74 /* grab the challenge... */
75 if(!net_io_q_auth("", &q_u, data, 0)) {
76 DEBUG(0,("api_net_auth: Failed to unmarshall NET_Q_AUTH.\n"));
80 r_u.status = _net_auth(p, &q_u, &r_u);
82 /* store the response in the SMB stream */
83 if(!net_io_r_auth("", &r_u, rdata, 0)) {
84 DEBUG(0,("api_net_auth: Failed to marshall NET_R_AUTH.\n"));
91 /*************************************************************************
93 *************************************************************************/
95 static BOOL api_net_auth_2(pipes_struct *p)
99 prs_struct *data = &p->in_data.data;
100 prs_struct *rdata = &p->out_data.rdata;
105 /* grab the challenge... */
106 if(!net_io_q_auth_2("", &q_u, data, 0)) {
107 DEBUG(0,("api_net_auth_2: Failed to unmarshall NET_Q_AUTH_2.\n"));
111 r_u.status = _net_auth_2(p, &q_u, &r_u);
113 /* store the response in the SMB stream */
114 if(!net_io_r_auth_2("", &r_u, rdata, 0)) {
115 DEBUG(0,("api_net_auth_2: Failed to marshall NET_R_AUTH_2.\n"));
122 /*************************************************************************
124 *************************************************************************/
126 static BOOL api_net_srv_pwset(pipes_struct *p)
130 prs_struct *data = &p->in_data.data;
131 prs_struct *rdata = &p->out_data.rdata;
136 /* grab the challenge and encrypted password ... */
137 if(!net_io_q_srv_pwset("", &q_u, data, 0)) {
138 DEBUG(0,("api_net_srv_pwset: Failed to unmarshall NET_Q_SRV_PWSET.\n"));
142 r_u.status = _net_srv_pwset(p, &q_u, &r_u);
144 /* store the response in the SMB stream */
145 if(!net_io_r_srv_pwset("", &r_u, rdata, 0)) {
146 DEBUG(0,("api_net_srv_pwset: Failed to marshall NET_R_SRV_PWSET.\n"));
153 /*************************************************************************
155 *************************************************************************/
157 static BOOL api_net_sam_logoff(pipes_struct *p)
159 NET_Q_SAM_LOGOFF q_u;
160 NET_R_SAM_LOGOFF r_u;
161 prs_struct *data = &p->in_data.data;
162 prs_struct *rdata = &p->out_data.rdata;
167 if(!net_io_q_sam_logoff("", &q_u, data, 0)) {
168 DEBUG(0,("api_net_sam_logoff: Failed to unmarshall NET_Q_SAM_LOGOFF.\n"));
172 r_u.status = _net_sam_logoff(p, &q_u, &r_u);
174 /* store the response in the SMB stream */
175 if(!net_io_r_sam_logoff("", &r_u, rdata, 0)) {
176 DEBUG(0,("api_net_sam_logoff: Failed to marshall NET_R_SAM_LOGOFF.\n"));
183 /*************************************************************************
185 *************************************************************************/
187 static BOOL api_net_sam_logon(pipes_struct *p)
191 prs_struct *data = &p->in_data.data;
192 prs_struct *rdata = &p->out_data.rdata;
197 if(!net_io_q_sam_logon("", &q_u, data, 0)) {
198 DEBUG(0, ("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n"));
202 r_u.status = _net_sam_logon(p, &q_u, &r_u);
204 /* store the response in the SMB stream */
205 if(!net_io_r_sam_logon("", &r_u, rdata, 0)) {
206 DEBUG(0,("api_net_sam_logon: Failed to marshall NET_R_SAM_LOGON.\n"));
213 /*************************************************************************
214 api_net_trust_dom_list:
215 *************************************************************************/
217 static BOOL api_net_trust_dom_list(pipes_struct *p)
219 NET_Q_TRUST_DOM_LIST q_u;
220 NET_R_TRUST_DOM_LIST r_u;
221 prs_struct *data = &p->in_data.data;
222 prs_struct *rdata = &p->out_data.rdata;
227 DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__));
229 /* grab the lsa trusted domain list query... */
230 if(!net_io_q_trust_dom("", &q_u, data, 0)) {
231 DEBUG(0,("api_net_trust_dom_list: Failed to unmarshall NET_Q_TRUST_DOM_LIST.\n"));
235 /* construct reply. */
236 r_u.status = _net_trust_dom_list(p, &q_u, &r_u);
238 /* store the response in the SMB stream */
239 if(!net_io_r_trust_dom("", &r_u, rdata, 0)) {
240 DEBUG(0,("net_reply_trust_dom_list: Failed to marshall NET_R_TRUST_DOM_LIST.\n"));
244 DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__));
249 /*************************************************************************
251 *************************************************************************/
253 static BOOL api_net_logon_ctrl2(pipes_struct *p)
255 NET_Q_LOGON_CTRL2 q_u;
256 NET_R_LOGON_CTRL2 r_u;
257 prs_struct *data = &p->in_data.data;
258 prs_struct *rdata = &p->out_data.rdata;
263 DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__));
265 /* grab the lsa netlogon ctrl2 query... */
266 if(!net_io_q_logon_ctrl2("", &q_u, data, 0)) {
267 DEBUG(0,("api_net_logon_ctrl2: Failed to unmarshall NET_Q_LOGON_CTRL2.\n"));
271 r_u.status = _net_logon_ctrl2(p, &q_u, &r_u);
273 if(!net_io_r_logon_ctrl2("", &r_u, rdata, 0)) {
274 DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL2.\n"));
278 DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__));
283 /*************************************************************************
285 *************************************************************************/
287 static BOOL api_net_logon_ctrl(pipes_struct *p)
289 NET_Q_LOGON_CTRL q_u;
290 NET_R_LOGON_CTRL r_u;
291 prs_struct *data = &p->in_data.data;
292 prs_struct *rdata = &p->out_data.rdata;
297 DEBUG(6,("api_net_logon_ctrl: %d\n", __LINE__));
299 /* grab the lsa netlogon ctrl query... */
300 if(!net_io_q_logon_ctrl("", &q_u, data, 0)) {
301 DEBUG(0,("api_net_logon_ctrl: Failed to unmarshall NET_Q_LOGON_CTRL.\n"));
305 r_u.status = _net_logon_ctrl(p, &q_u, &r_u);
307 if(!net_io_r_logon_ctrl("", &r_u, rdata, 0)) {
308 DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL2.\n"));
312 DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__));
317 /*******************************************************************
318 array of \PIPE\NETLOGON operations
319 ********************************************************************/
320 static struct api_struct api_net_cmds [] =
322 { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal },
323 { "NET_AUTH" , NET_AUTH , api_net_auth },
324 { "NET_AUTH2" , NET_AUTH2 , api_net_auth_2 },
325 { "NET_SRVPWSET" , NET_SRVPWSET , api_net_srv_pwset },
326 { "NET_SAMLOGON" , NET_SAMLOGON , api_net_sam_logon },
327 { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff },
328 { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 },
329 { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list },
330 { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl },
334 /*******************************************************************
335 receives a netlogon pipe and responds.
336 ********************************************************************/
338 BOOL api_netlog_rpc(pipes_struct *p)
340 return api_rpcTNP(p, "api_netlog_rpc", api_net_cmds);