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 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.
24 /* This is the interface to the lsa server code. */
29 #define DBGC_CLASS DBGC_RPC_SRV
31 /***************************************************************************
33 ***************************************************************************/
35 static BOOL api_lsa_open_policy2(pipes_struct *p)
39 prs_struct *data = &p->in_data.data;
40 prs_struct *rdata = &p->out_data.rdata;
45 /* grab the server, object attributes and desired access flag...*/
46 if(!lsa_io_q_open_pol2("", &q_u, data, 0)) {
47 DEBUG(0,("api_lsa_open_policy2: unable to unmarshall LSA_Q_OPEN_POL2.\n"));
51 r_u.status = _lsa_open_policy2(p, &q_u, &r_u);
53 /* store the response in the SMB stream */
54 if(!lsa_io_r_open_pol2("", &r_u, rdata, 0)) {
55 DEBUG(0,("api_lsa_open_policy2: unable to marshall LSA_R_OPEN_POL2.\n"));
62 /***************************************************************************
64 ***************************************************************************/
66 static BOOL api_lsa_open_policy(pipes_struct *p)
70 prs_struct *data = &p->in_data.data;
71 prs_struct *rdata = &p->out_data.rdata;
76 /* grab the server, object attributes and desired access flag...*/
77 if(!lsa_io_q_open_pol("", &q_u, data, 0)) {
78 DEBUG(0,("api_lsa_open_policy: unable to unmarshall LSA_Q_OPEN_POL.\n"));
82 r_u.status = _lsa_open_policy(p, &q_u, &r_u);
84 /* store the response in the SMB stream */
85 if(!lsa_io_r_open_pol("", &r_u, rdata, 0)) {
86 DEBUG(0,("api_lsa_open_policy: unable to marshall LSA_R_OPEN_POL.\n"));
93 /***************************************************************************
94 api_lsa_enum_trust_dom
95 ***************************************************************************/
97 static BOOL api_lsa_enum_trust_dom(pipes_struct *p)
99 LSA_Q_ENUM_TRUST_DOM q_u;
100 LSA_R_ENUM_TRUST_DOM r_u;
101 prs_struct *data = &p->in_data.data;
102 prs_struct *rdata = &p->out_data.rdata;
107 /* grab the enum trust domain context etc. */
108 if(!lsa_io_q_enum_trust_dom("", &q_u, data, 0))
111 /* get required trusted domains information */
112 r_u.status = _lsa_enum_trust_dom(p, &q_u, &r_u);
114 /* prepare the response */
115 if(!lsa_io_r_enum_trust_dom("", &r_u, rdata, 0))
121 /***************************************************************************
123 ***************************************************************************/
125 static BOOL api_lsa_query_info(pipes_struct *p)
127 LSA_Q_QUERY_INFO q_u;
128 LSA_R_QUERY_INFO r_u;
129 prs_struct *data = &p->in_data.data;
130 prs_struct *rdata = &p->out_data.rdata;
135 /* grab the info class and policy handle */
136 if(!lsa_io_q_query("", &q_u, data, 0)) {
137 DEBUG(0,("api_lsa_query_info: failed to unmarshall LSA_Q_QUERY_INFO.\n"));
141 r_u.status = _lsa_query_info(p, &q_u, &r_u);
143 /* store the response in the SMB stream */
144 if(!lsa_io_r_query("", &r_u, rdata, 0)) {
145 DEBUG(0,("api_lsa_query_info: failed to marshall LSA_R_QUERY_INFO.\n"));
152 /***************************************************************************
154 ***************************************************************************/
156 static BOOL api_lsa_lookup_sids(pipes_struct *p)
158 LSA_Q_LOOKUP_SIDS q_u;
159 LSA_R_LOOKUP_SIDS r_u;
160 prs_struct *data = &p->in_data.data;
161 prs_struct *rdata = &p->out_data.rdata;
166 /* grab the info class and policy handle */
167 if(!lsa_io_q_lookup_sids("", &q_u, data, 0)) {
168 DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n"));
172 r_u.status = _lsa_lookup_sids(p, &q_u, &r_u);
174 if(!lsa_io_r_lookup_sids("", &r_u, rdata, 0)) {
175 DEBUG(0,("api_lsa_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n"));
182 /***************************************************************************
184 ***************************************************************************/
186 static BOOL api_lsa_lookup_names(pipes_struct *p)
188 LSA_Q_LOOKUP_NAMES q_u;
189 LSA_R_LOOKUP_NAMES r_u;
190 prs_struct *data = &p->in_data.data;
191 prs_struct *rdata = &p->out_data.rdata;
196 /* grab the info class and policy handle */
197 if(!lsa_io_q_lookup_names("", &q_u, data, 0)) {
198 DEBUG(0,("api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES.\n"));
202 r_u.status = _lsa_lookup_names(p, &q_u, &r_u);
204 /* store the response in the SMB stream */
205 if(!lsa_io_r_lookup_names("", &r_u, rdata, 0)) {
206 DEBUG(0,("api_lsa_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n"));
213 /***************************************************************************
215 ***************************************************************************/
217 static BOOL api_lsa_close(pipes_struct *p)
221 prs_struct *data = &p->in_data.data;
222 prs_struct *rdata = &p->out_data.rdata;
227 if (!lsa_io_q_close("", &q_u, data, 0)) {
228 DEBUG(0,("api_lsa_close: lsa_io_q_close failed.\n"));
232 r_u.status = _lsa_close(p, &q_u, &r_u);
234 /* store the response in the SMB stream */
235 if (!lsa_io_r_close("", &r_u, rdata, 0)) {
236 DEBUG(0,("api_lsa_close: lsa_io_r_close failed.\n"));
243 /***************************************************************************
245 ***************************************************************************/
247 static BOOL api_lsa_open_secret(pipes_struct *p)
249 LSA_Q_OPEN_SECRET q_u;
250 LSA_R_OPEN_SECRET r_u;
251 prs_struct *data = &p->in_data.data;
252 prs_struct *rdata = &p->out_data.rdata;
257 if(!lsa_io_q_open_secret("", &q_u, data, 0)) {
258 DEBUG(0,("api_lsa_open_secret: failed to unmarshall LSA_Q_OPEN_SECRET.\n"));
262 r_u.status = _lsa_open_secret(p, &q_u, &r_u);
264 /* store the response in the SMB stream */
265 if(!lsa_io_r_open_secret("", &r_u, rdata, 0)) {
266 DEBUG(0,("api_lsa_open_secret: Failed to marshall LSA_R_OPEN_SECRET.\n"));
273 /***************************************************************************
275 ***************************************************************************/
277 static BOOL api_lsa_enum_privs(pipes_struct *p)
279 LSA_Q_ENUM_PRIVS q_u;
280 LSA_R_ENUM_PRIVS r_u;
281 prs_struct *data = &p->in_data.data;
282 prs_struct *rdata = &p->out_data.rdata;
287 if(!lsa_io_q_enum_privs("", &q_u, data, 0)) {
288 DEBUG(0,("api_lsa_enum_privs: failed to unmarshall LSA_Q_ENUM_PRIVS.\n"));
292 r_u.status = _lsa_enum_privs(p, &q_u, &r_u);
294 /* store the response in the SMB stream */
295 if(!lsa_io_r_enum_privs("", &r_u, rdata, 0)) {
296 DEBUG(0,("api_lsa_enum_privs: Failed to marshall LSA_R_ENUM_PRIVS.\n"));
303 /***************************************************************************
305 ***************************************************************************/
307 static BOOL api_lsa_priv_get_dispname(pipes_struct *p)
309 LSA_Q_PRIV_GET_DISPNAME q_u;
310 LSA_R_PRIV_GET_DISPNAME r_u;
311 prs_struct *data = &p->in_data.data;
312 prs_struct *rdata = &p->out_data.rdata;
317 if(!lsa_io_q_priv_get_dispname("", &q_u, data, 0)) {
318 DEBUG(0,("api_lsa_priv_get_dispname: failed to unmarshall LSA_Q_PRIV_GET_DISPNAME.\n"));
322 r_u.status = _lsa_priv_get_dispname(p, &q_u, &r_u);
324 /* store the response in the SMB stream */
325 if(!lsa_io_r_priv_get_dispname("", &r_u, rdata, 0)) {
326 DEBUG(0,("api_lsa_priv_get_dispname: Failed to marshall LSA_R_PRIV_GET_DISPNAME.\n"));
333 /***************************************************************************
335 ***************************************************************************/
337 static BOOL api_lsa_enum_accounts(pipes_struct *p)
339 LSA_Q_ENUM_ACCOUNTS q_u;
340 LSA_R_ENUM_ACCOUNTS r_u;
341 prs_struct *data = &p->in_data.data;
342 prs_struct *rdata = &p->out_data.rdata;
347 if(!lsa_io_q_enum_accounts("", &q_u, data, 0)) {
348 DEBUG(0,("api_lsa_enum_accounts: failed to unmarshall LSA_Q_ENUM_ACCOUNTS.\n"));
352 r_u.status = _lsa_enum_accounts(p, &q_u, &r_u);
354 /* store the response in the SMB stream */
355 if(!lsa_io_r_enum_accounts("", &r_u, rdata, 0)) {
356 DEBUG(0,("api_lsa_enum_accounts: Failed to marshall LSA_R_ENUM_ACCOUNTS.\n"));
363 /***************************************************************************
364 api_lsa_UNK_GET_CONNUSER
365 ***************************************************************************/
367 static BOOL api_lsa_unk_get_connuser(pipes_struct *p)
369 LSA_Q_UNK_GET_CONNUSER q_u;
370 LSA_R_UNK_GET_CONNUSER r_u;
372 prs_struct *data = &p->in_data.data;
373 prs_struct *rdata = &p->out_data.rdata;
378 if(!lsa_io_q_unk_get_connuser("", &q_u, data, 0)) {
379 DEBUG(0,("api_lsa_unk_get_connuser: failed to unmarshall LSA_Q_UNK_GET_CONNUSER.\n"));
383 r_u.status = _lsa_unk_get_connuser(p, &q_u, &r_u);
385 /* store the response in the SMB stream */
386 if(!lsa_io_r_unk_get_connuser("", &r_u, rdata, 0)) {
387 DEBUG(0,("api_lsa_unk_get_connuser: Failed to marshall LSA_R_UNK_GET_CONNUSER.\n"));
394 /***************************************************************************
396 ***************************************************************************/
398 static BOOL api_lsa_open_account(pipes_struct *p)
400 LSA_Q_OPENACCOUNT q_u;
401 LSA_R_OPENACCOUNT r_u;
403 prs_struct *data = &p->in_data.data;
404 prs_struct *rdata = &p->out_data.rdata;
409 if(!lsa_io_q_open_account("", &q_u, data, 0)) {
410 DEBUG(0,("api_lsa_open_account: failed to unmarshall LSA_Q_OPENACCOUNT.\n"));
414 r_u.status = _lsa_open_account(p, &q_u, &r_u);
416 /* store the response in the SMB stream */
417 if(!lsa_io_r_open_account("", &r_u, rdata, 0)) {
418 DEBUG(0,("api_lsa_open_account: Failed to marshall LSA_R_OPENACCOUNT.\n"));
425 /***************************************************************************
427 ***************************************************************************/
429 static BOOL api_lsa_enum_privsaccount(pipes_struct *p)
431 LSA_Q_ENUMPRIVSACCOUNT q_u;
432 LSA_R_ENUMPRIVSACCOUNT r_u;
434 prs_struct *data = &p->in_data.data;
435 prs_struct *rdata = &p->out_data.rdata;
440 if(!lsa_io_q_enum_privsaccount("", &q_u, data, 0)) {
441 DEBUG(0,("api_lsa_enum_privsaccount: failed to unmarshall LSA_Q_ENUMPRIVSACCOUNT.\n"));
445 r_u.status = _lsa_enum_privsaccount(p, &q_u, &r_u);
447 /* store the response in the SMB stream */
448 if(!lsa_io_r_enum_privsaccount("", &r_u, rdata, 0)) {
449 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 /***************************************************************************
489 api_lsa_setsystemaccount
490 ***************************************************************************/
492 static BOOL api_lsa_setsystemaccount(pipes_struct *p)
494 LSA_Q_SETSYSTEMACCOUNT q_u;
495 LSA_R_SETSYSTEMACCOUNT r_u;
497 prs_struct *data = &p->in_data.data;
498 prs_struct *rdata = &p->out_data.rdata;
503 if(!lsa_io_q_setsystemaccount("", &q_u, data, 0)) {
504 DEBUG(0,("api_lsa_setsystemaccount: failed to unmarshall LSA_Q_SETSYSTEMACCOUNT.\n"));
508 r_u.status = _lsa_setsystemaccount(p, &q_u, &r_u);
510 /* store the response in the SMB stream */
511 if(!lsa_io_r_setsystemaccount("", &r_u, rdata, 0)) {
512 DEBUG(0,("api_lsa_setsystemaccount: Failed to marshall LSA_R_SETSYSTEMACCOUNT.\n"));
519 /***************************************************************************
521 ***************************************************************************/
523 static BOOL api_lsa_addprivs(pipes_struct *p)
528 prs_struct *data = &p->in_data.data;
529 prs_struct *rdata = &p->out_data.rdata;
534 if(!lsa_io_q_addprivs("", &q_u, data, 0)) {
535 DEBUG(0,("api_lsa_addprivs: failed to unmarshall LSA_Q_ADDPRIVS.\n"));
539 r_u.status = _lsa_addprivs(p, &q_u, &r_u);
541 /* store the response in the SMB stream */
542 if(!lsa_io_r_addprivs("", &r_u, rdata, 0)) {
543 DEBUG(0,("api_lsa_addprivs: Failed to marshall LSA_R_ADDPRIVS.\n"));
550 /***************************************************************************
552 ***************************************************************************/
554 static BOOL api_lsa_removeprivs(pipes_struct *p)
556 LSA_Q_REMOVEPRIVS q_u;
557 LSA_R_REMOVEPRIVS r_u;
559 prs_struct *data = &p->in_data.data;
560 prs_struct *rdata = &p->out_data.rdata;
565 if(!lsa_io_q_removeprivs("", &q_u, data, 0)) {
566 DEBUG(0,("api_lsa_removeprivs: failed to unmarshall LSA_Q_REMOVEPRIVS.\n"));
570 r_u.status = _lsa_removeprivs(p, &q_u, &r_u);
572 /* store the response in the SMB stream */
573 if(!lsa_io_r_removeprivs("", &r_u, rdata, 0)) {
574 DEBUG(0,("api_lsa_removeprivs: Failed to marshall LSA_R_REMOVEPRIVS.\n"));
581 /***************************************************************************
583 ***************************************************************************/
585 static BOOL api_lsa_query_secobj(pipes_struct *p)
587 LSA_Q_QUERY_SEC_OBJ q_u;
588 LSA_R_QUERY_SEC_OBJ r_u;
590 prs_struct *data = &p->in_data.data;
591 prs_struct *rdata = &p->out_data.rdata;
596 if(!lsa_io_q_query_sec_obj("", &q_u, data, 0)) {
597 DEBUG(0,("api_lsa_query_secobj: failed to unmarshall LSA_Q_QUERY_SEC_OBJ.\n"));
601 r_u.status = _lsa_query_secobj(p, &q_u, &r_u);
603 /* store the response in the SMB stream */
604 if(!lsa_io_r_query_sec_obj("", &r_u, rdata, 0)) {
605 DEBUG(0,("api_lsa_query_secobj: Failed to marshall LSA_R_QUERY_SEC_OBJ.\n"));
612 /***************************************************************************
614 ***************************************************************************/
616 static struct api_struct api_lsa_cmds[] =
618 { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 },
619 { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy },
620 { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info },
621 { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom },
622 { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close },
623 { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret },
624 { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids },
625 { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names },
626 { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs },
627 { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname},
628 { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts },
629 { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser },
630 { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account },
631 { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount},
632 { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount },
633 { "LSA_SETSYSTEMACCOUNT", LSA_SETSYSTEMACCOUNT, api_lsa_setsystemaccount },
634 { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs },
635 { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs },
636 { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj },
640 /***************************************************************************
642 ***************************************************************************/
643 BOOL api_ntlsa_rpc(pipes_struct *p)
645 return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds);