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 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 lsa server code. */
29 /***************************************************************************
31 ***************************************************************************/
33 static BOOL
api_lsa_open_policy2(pipes_struct
*p
)
37 prs_struct
*data
= &p
->in_data
.data
;
38 prs_struct
*rdata
= &p
->out_data
.rdata
;
43 /* grab the server, object attributes and desired access flag...*/
44 if(!lsa_io_q_open_pol2("", &q_u
, data
, 0)) {
45 DEBUG(0,("api_lsa_open_policy2: unable to unmarshall LSA_Q_OPEN_POL2.\n"));
49 r_u
.status
= _lsa_open_policy2(p
, &q_u
, &r_u
);
51 /* store the response in the SMB stream */
52 if(!lsa_io_r_open_pol2("", &r_u
, rdata
, 0)) {
53 DEBUG(0,("api_lsa_open_policy2: unable to marshall LSA_R_OPEN_POL2.\n"));
60 /***************************************************************************
62 ***************************************************************************/
64 static BOOL
api_lsa_open_policy(pipes_struct
*p
)
68 prs_struct
*data
= &p
->in_data
.data
;
69 prs_struct
*rdata
= &p
->out_data
.rdata
;
74 /* grab the server, object attributes and desired access flag...*/
75 if(!lsa_io_q_open_pol("", &q_u
, data
, 0)) {
76 DEBUG(0,("api_lsa_open_policy: unable to unmarshall LSA_Q_OPEN_POL.\n"));
80 r_u
.status
= _lsa_open_policy(p
, &q_u
, &r_u
);
82 /* store the response in the SMB stream */
83 if(!lsa_io_r_open_pol("", &r_u
, rdata
, 0)) {
84 DEBUG(0,("api_lsa_open_policy: unable to marshall LSA_R_OPEN_POL.\n"));
91 /***************************************************************************
92 api_lsa_enum_trust_dom
93 ***************************************************************************/
95 static BOOL
api_lsa_enum_trust_dom(pipes_struct
*p
)
97 LSA_Q_ENUM_TRUST_DOM q_u
;
98 LSA_R_ENUM_TRUST_DOM r_u
;
99 prs_struct
*data
= &p
->in_data
.data
;
100 prs_struct
*rdata
= &p
->out_data
.rdata
;
105 /* grab the enum trust domain context etc. */
106 if(!lsa_io_q_enum_trust_dom("", &q_u
, data
, 0))
109 r_u
.status
= _lsa_enum_trust_dom(p
, &q_u
, &r_u
);
111 if(!lsa_io_r_enum_trust_dom("", &r_u
, rdata
, 0))
117 /***************************************************************************
119 ***************************************************************************/
121 static BOOL
api_lsa_query_info(pipes_struct
*p
)
123 LSA_Q_QUERY_INFO q_u
;
124 LSA_R_QUERY_INFO r_u
;
125 prs_struct
*data
= &p
->in_data
.data
;
126 prs_struct
*rdata
= &p
->out_data
.rdata
;
131 /* grab the info class and policy handle */
132 if(!lsa_io_q_query("", &q_u
, data
, 0)) {
133 DEBUG(0,("api_lsa_query_info: failed to unmarshall LSA_Q_QUERY_INFO.\n"));
137 r_u
.status
= _lsa_query_info(p
, &q_u
, &r_u
);
139 /* store the response in the SMB stream */
140 if(!lsa_io_r_query("", &r_u
, rdata
, 0)) {
141 DEBUG(0,("api_lsa_query_info: failed to marshall LSA_R_QUERY_INFO.\n"));
148 /***************************************************************************
150 ***************************************************************************/
152 static BOOL
api_lsa_lookup_sids(pipes_struct
*p
)
154 LSA_Q_LOOKUP_SIDS q_u
;
155 LSA_R_LOOKUP_SIDS r_u
;
156 prs_struct
*data
= &p
->in_data
.data
;
157 prs_struct
*rdata
= &p
->out_data
.rdata
;
162 /* grab the info class and policy handle */
163 if(!lsa_io_q_lookup_sids("", &q_u
, data
, 0)) {
164 DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n"));
168 r_u
.status
= _lsa_lookup_sids(p
, &q_u
, &r_u
);
170 if(!lsa_io_r_lookup_sids("", &r_u
, rdata
, 0)) {
171 DEBUG(0,("api_lsa_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n"));
178 /***************************************************************************
180 ***************************************************************************/
182 static BOOL
api_lsa_lookup_names(pipes_struct
*p
)
184 LSA_Q_LOOKUP_NAMES q_u
;
185 LSA_R_LOOKUP_NAMES r_u
;
186 prs_struct
*data
= &p
->in_data
.data
;
187 prs_struct
*rdata
= &p
->out_data
.rdata
;
192 /* grab the info class and policy handle */
193 if(!lsa_io_q_lookup_names("", &q_u
, data
, 0)) {
194 DEBUG(0,("api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES.\n"));
198 r_u
.status
= _lsa_lookup_names(p
, &q_u
, &r_u
);
200 /* store the response in the SMB stream */
201 if(!lsa_io_r_lookup_names("", &r_u
, rdata
, 0)) {
202 DEBUG(0,("api_lsa_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n"));
209 /***************************************************************************
211 ***************************************************************************/
213 static BOOL
api_lsa_close(pipes_struct
*p
)
217 prs_struct
*data
= &p
->in_data
.data
;
218 prs_struct
*rdata
= &p
->out_data
.rdata
;
223 if (!lsa_io_q_close("", &q_u
, data
, 0)) {
224 DEBUG(0,("api_lsa_close: lsa_io_q_close failed.\n"));
228 r_u
.status
= _lsa_close(p
, &q_u
, &r_u
);
230 /* store the response in the SMB stream */
231 if (!lsa_io_r_close("", &r_u
, rdata
, 0)) {
232 DEBUG(0,("api_lsa_close: lsa_io_r_close failed.\n"));
239 /***************************************************************************
241 ***************************************************************************/
243 static BOOL
api_lsa_open_secret(pipes_struct
*p
)
245 LSA_Q_OPEN_SECRET q_u
;
246 LSA_R_OPEN_SECRET r_u
;
247 prs_struct
*data
= &p
->in_data
.data
;
248 prs_struct
*rdata
= &p
->out_data
.rdata
;
253 if(!lsa_io_q_open_secret("", &q_u
, data
, 0)) {
254 DEBUG(0,("api_lsa_open_secret: failed to unmarshall LSA_Q_OPEN_SECRET.\n"));
258 r_u
.status
= _lsa_open_secret(p
, &q_u
, &r_u
);
260 /* store the response in the SMB stream */
261 if(!lsa_io_r_open_secret("", &r_u
, rdata
, 0)) {
262 DEBUG(0,("api_lsa_open_secret: Failed to marshall LSA_R_OPEN_SECRET.\n"));
269 /***************************************************************************
271 ***************************************************************************/
273 static BOOL
api_lsa_enum_privs(pipes_struct
*p
)
275 LSA_Q_ENUM_PRIVS q_u
;
276 LSA_R_ENUM_PRIVS r_u
;
277 prs_struct
*data
= &p
->in_data
.data
;
278 prs_struct
*rdata
= &p
->out_data
.rdata
;
283 if(!lsa_io_q_enum_privs("", &q_u
, data
, 0)) {
284 DEBUG(0,("api_lsa_enum_privs: failed to unmarshall LSA_Q_ENUM_PRIVS.\n"));
288 r_u
.status
= _lsa_enum_privs(p
, &q_u
, &r_u
);
290 /* store the response in the SMB stream */
291 if(!lsa_io_r_enum_privs("", &r_u
, rdata
, 0)) {
292 DEBUG(0,("api_lsa_enum_privs: Failed to marshall LSA_R_ENUM_PRIVS.\n"));
299 /***************************************************************************
301 ***************************************************************************/
303 static BOOL
api_lsa_priv_get_dispname(pipes_struct
*p
)
305 LSA_Q_PRIV_GET_DISPNAME q_u
;
306 LSA_R_PRIV_GET_DISPNAME r_u
;
307 prs_struct
*data
= &p
->in_data
.data
;
308 prs_struct
*rdata
= &p
->out_data
.rdata
;
313 if(!lsa_io_q_priv_get_dispname("", &q_u
, data
, 0)) {
314 DEBUG(0,("api_lsa_priv_get_dispname: failed to unmarshall LSA_Q_PRIV_GET_DISPNAME.\n"));
318 r_u
.status
= _lsa_priv_get_dispname(p
, &q_u
, &r_u
);
320 /* store the response in the SMB stream */
321 if(!lsa_io_r_priv_get_dispname("", &r_u
, rdata
, 0)) {
322 DEBUG(0,("api_lsa_priv_get_dispname: Failed to marshall LSA_R_PRIV_GET_DISPNAME.\n"));
330 /***************************************************************************
332 ***************************************************************************/
334 static BOOL
api_lsa_enum_accounts(pipes_struct
*p
)
336 LSA_Q_ENUM_ACCOUNTS q_u
;
337 LSA_R_ENUM_ACCOUNTS r_u
;
338 prs_struct
*data
= &p
->in_data
.data
;
339 prs_struct
*rdata
= &p
->out_data
.rdata
;
344 if(!lsa_io_q_enum_accounts("", &q_u
, data
, 0)) {
345 DEBUG(0,("api_lsa_enum_accounts: failed to unmarshall LSA_Q_ENUM_ACCOUNTS.\n"));
349 r_u
.status
= _lsa_enum_accounts(p
, &q_u
, &r_u
);
351 /* store the response in the SMB stream */
352 if(!lsa_io_r_enum_accounts("", &r_u
, rdata
, 0)) {
353 DEBUG(0,("api_lsa_enum_accounts: Failed to marshall LSA_R_ENUM_ACCOUNTS.\n"));
361 /***************************************************************************
362 api_lsa_UNK_GET_CONNUSER
363 ***************************************************************************/
365 static BOOL
api_lsa_unk_get_connuser(pipes_struct
*p
)
367 LSA_Q_UNK_GET_CONNUSER q_u
;
368 LSA_R_UNK_GET_CONNUSER r_u
;
370 prs_struct
*data
= &p
->in_data
.data
;
371 prs_struct
*rdata
= &p
->out_data
.rdata
;
376 if(!lsa_io_q_unk_get_connuser("", &q_u
, data
, 0)) {
377 DEBUG(0,("api_lsa_unk_get_connuser: failed to unmarshall LSA_Q_UNK_GET_CONNUSER.\n"));
381 r_u
.status
= _lsa_unk_get_connuser(p
, &q_u
, &r_u
);
383 /* store the response in the SMB stream */
384 if(!lsa_io_r_unk_get_connuser("", &r_u
, rdata
, 0)) {
385 DEBUG(0,("api_lsa_unk_get_connuser: Failed to marshall LSA_R_UNK_GET_CONNUSER.\n"));
392 /***************************************************************************
394 ***************************************************************************/
396 static BOOL
api_lsa_open_account(pipes_struct
*p
)
398 LSA_Q_OPENACCOUNT q_u
;
399 LSA_R_OPENACCOUNT r_u
;
401 prs_struct
*data
= &p
->in_data
.data
;
402 prs_struct
*rdata
= &p
->out_data
.rdata
;
407 if(!lsa_io_q_open_account("", &q_u
, data
, 0)) {
408 DEBUG(0,("api_lsa_open_account: failed to unmarshall LSA_Q_OPENACCOUNT.\n"));
412 r_u
.status
= _lsa_open_account(p
, &q_u
, &r_u
);
414 /* store the response in the SMB stream */
415 if(!lsa_io_r_open_account("", &r_u
, rdata
, 0)) {
416 DEBUG(0,("api_lsa_open_account: Failed to marshall LSA_R_OPENACCOUNT.\n"));
424 /***************************************************************************
426 ***************************************************************************/
428 static BOOL
api_lsa_enum_privsaccount(pipes_struct
*p
)
430 LSA_Q_ENUMPRIVSACCOUNT q_u
;
431 LSA_R_ENUMPRIVSACCOUNT r_u
;
433 prs_struct
*data
= &p
->in_data
.data
;
434 prs_struct
*rdata
= &p
->out_data
.rdata
;
439 if(!lsa_io_q_enum_privsaccount("", &q_u
, data
, 0)) {
440 DEBUG(0,("api_lsa_enum_privsaccount: failed to unmarshall LSA_Q_ENUMPRIVSACCOUNT.\n"));
444 r_u
.status
= _lsa_enum_privsaccount(p
, &q_u
, &r_u
);
446 /* store the response in the SMB stream */
447 if(!lsa_io_r_enum_privsaccount("", &r_u
, rdata
, 0)) {
448 DEBUG(0,("api_lsa_enum_privsaccount: Failed to marshall LSA_R_ENUMPRIVSACCOUNT.\n"));
456 /***************************************************************************
457 api_lsa_getsystemaccount
458 ***************************************************************************/
460 static BOOL
api_lsa_getsystemaccount(pipes_struct
*p
)
462 LSA_Q_GETSYSTEMACCOUNT q_u
;
463 LSA_R_GETSYSTEMACCOUNT r_u
;
465 prs_struct
*data
= &p
->in_data
.data
;
466 prs_struct
*rdata
= &p
->out_data
.rdata
;
471 if(!lsa_io_q_getsystemaccount("", &q_u
, data
, 0)) {
472 DEBUG(0,("api_lsa_getsystemaccount: failed to unmarshall LSA_Q_GETSYSTEMACCOUNT.\n"));
476 r_u
.status
= _lsa_getsystemaccount(p
, &q_u
, &r_u
);
478 /* store the response in the SMB stream */
479 if(!lsa_io_r_getsystemaccount("", &r_u
, rdata
, 0)) {
480 DEBUG(0,("api_lsa_getsystemaccount: Failed to marshall LSA_R_GETSYSTEMACCOUNT.\n"));
488 /***************************************************************************
490 ***************************************************************************/
492 static struct api_struct api_lsa_cmds
[] =
494 { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2
, api_lsa_open_policy2
},
495 { "LSA_OPENPOLICY" , LSA_OPENPOLICY
, api_lsa_open_policy
},
496 { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY
, api_lsa_query_info
},
497 { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM
, api_lsa_enum_trust_dom
},
498 { "LSA_CLOSE" , LSA_CLOSE
, api_lsa_close
},
499 { "LSA_OPENSECRET" , LSA_OPENSECRET
, api_lsa_open_secret
},
500 { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS
, api_lsa_lookup_sids
},
501 { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES
, api_lsa_lookup_names
},
502 { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS
, api_lsa_enum_privs
},
503 { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME
,api_lsa_priv_get_dispname
},
505 { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS
, api_lsa_enum_accounts
},
507 { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER
, api_lsa_unk_get_connuser
},
508 { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT
, api_lsa_open_account
},
510 { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT
, api_lsa_enum_privsaccount
},
512 { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT
, api_lsa_getsystemaccount
},
516 /***************************************************************************
518 ***************************************************************************/
519 BOOL
api_ntlsa_rpc(pipes_struct
*p
)
521 return api_rpcTNP(p
, "api_ntlsa_rpc", api_lsa_cmds
);