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. */
28 /***************************************************************************
30 ***************************************************************************/
32 static BOOL api_lsa_open_policy2(pipes_struct *p)
36 prs_struct *data = &p->in_data.data;
37 prs_struct *rdata = &p->out_data.rdata;
42 /* grab the server, object attributes and desired access flag...*/
43 if(!lsa_io_q_open_pol2("", &q_u, data, 0)) {
44 DEBUG(0,("api_lsa_open_policy2: unable to unmarshall LSA_Q_OPEN_POL2.\n"));
48 r_u.status = _lsa_open_policy2(p, &q_u, &r_u);
50 /* store the response in the SMB stream */
51 if(!lsa_io_r_open_pol2("", &r_u, rdata, 0)) {
52 DEBUG(0,("api_lsa_open_policy2: unable to marshall LSA_R_OPEN_POL2.\n"));
59 /***************************************************************************
61 ***************************************************************************/
63 static BOOL api_lsa_open_policy(pipes_struct *p)
67 prs_struct *data = &p->in_data.data;
68 prs_struct *rdata = &p->out_data.rdata;
73 /* grab the server, object attributes and desired access flag...*/
74 if(!lsa_io_q_open_pol("", &q_u, data, 0)) {
75 DEBUG(0,("api_lsa_open_policy: unable to unmarshall LSA_Q_OPEN_POL.\n"));
79 r_u.status = _lsa_open_policy(p, &q_u, &r_u);
81 /* store the response in the SMB stream */
82 if(!lsa_io_r_open_pol("", &r_u, rdata, 0)) {
83 DEBUG(0,("api_lsa_open_policy: unable to marshall LSA_R_OPEN_POL.\n"));
90 /***************************************************************************
91 api_lsa_enum_trust_dom
92 ***************************************************************************/
94 static BOOL api_lsa_enum_trust_dom(pipes_struct *p)
96 LSA_Q_ENUM_TRUST_DOM q_u;
97 LSA_R_ENUM_TRUST_DOM r_u;
98 prs_struct *data = &p->in_data.data;
99 prs_struct *rdata = &p->out_data.rdata;
104 /* grab the enum trust domain context etc. */
105 if(!lsa_io_q_enum_trust_dom("", &q_u, data, 0))
108 r_u.status = _lsa_enum_trust_dom(p, &q_u, &r_u);
110 if(!lsa_io_r_enum_trust_dom("", &r_u, rdata, 0))
116 /***************************************************************************
118 ***************************************************************************/
120 static BOOL api_lsa_query_info(pipes_struct *p)
122 LSA_Q_QUERY_INFO q_u;
123 LSA_R_QUERY_INFO r_u;
124 prs_struct *data = &p->in_data.data;
125 prs_struct *rdata = &p->out_data.rdata;
130 /* grab the info class and policy handle */
131 if(!lsa_io_q_query("", &q_u, data, 0)) {
132 DEBUG(0,("api_lsa_query_info: failed to unmarshall LSA_Q_QUERY_INFO.\n"));
136 r_u.status = _lsa_query_info(p, &q_u, &r_u);
138 /* store the response in the SMB stream */
139 if(!lsa_io_r_query("", &r_u, rdata, 0)) {
140 DEBUG(0,("api_lsa_query_info: failed to marshall LSA_R_QUERY_INFO.\n"));
147 /***************************************************************************
149 ***************************************************************************/
151 static BOOL api_lsa_lookup_sids(pipes_struct *p)
153 LSA_Q_LOOKUP_SIDS q_u;
154 LSA_R_LOOKUP_SIDS r_u;
155 prs_struct *data = &p->in_data.data;
156 prs_struct *rdata = &p->out_data.rdata;
161 /* grab the info class and policy handle */
162 if(!lsa_io_q_lookup_sids("", &q_u, data, 0)) {
163 DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n"));
167 r_u.status = _lsa_lookup_sids(p, &q_u, &r_u);
169 if(!lsa_io_r_lookup_sids("", &r_u, rdata, 0)) {
170 DEBUG(0,("api_lsa_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n"));
177 /***************************************************************************
179 ***************************************************************************/
181 static BOOL api_lsa_lookup_names(pipes_struct *p)
183 LSA_Q_LOOKUP_NAMES q_u;
184 LSA_R_LOOKUP_NAMES r_u;
185 prs_struct *data = &p->in_data.data;
186 prs_struct *rdata = &p->out_data.rdata;
191 /* grab the info class and policy handle */
192 if(!lsa_io_q_lookup_names("", &q_u, data, 0)) {
193 DEBUG(0,("api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES.\n"));
197 r_u.status = _lsa_lookup_names(p, &q_u, &r_u);
199 /* store the response in the SMB stream */
200 if(!lsa_io_r_lookup_names("", &r_u, rdata, 0)) {
201 DEBUG(0,("api_lsa_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n"));
208 /***************************************************************************
210 ***************************************************************************/
212 static BOOL api_lsa_close(pipes_struct *p)
216 prs_struct *data = &p->in_data.data;
217 prs_struct *rdata = &p->out_data.rdata;
222 if (!lsa_io_q_close("", &q_u, data, 0)) {
223 DEBUG(0,("api_lsa_close: lsa_io_q_close failed.\n"));
227 r_u.status = _lsa_close(p, &q_u, &r_u);
229 /* store the response in the SMB stream */
230 if (!lsa_io_r_close("", &r_u, rdata, 0)) {
231 DEBUG(0,("api_lsa_close: lsa_io_r_close failed.\n"));
238 /***************************************************************************
240 ***************************************************************************/
242 static BOOL api_lsa_open_secret(pipes_struct *p)
244 LSA_Q_OPEN_SECRET q_u;
245 LSA_R_OPEN_SECRET r_u;
246 prs_struct *data = &p->in_data.data;
247 prs_struct *rdata = &p->out_data.rdata;
252 if(!lsa_io_q_open_secret("", &q_u, data, 0)) {
253 DEBUG(0,("api_lsa_open_secret: failed to unmarshall LSA_Q_OPEN_SECRET.\n"));
257 r_u.status = _lsa_open_secret(p, &q_u, &r_u);
259 /* store the response in the SMB stream */
260 if(!lsa_io_r_open_secret("", &r_u, rdata, 0)) {
261 DEBUG(0,("api_lsa_open_secret: Failed to marshall LSA_R_OPEN_SECRET.\n"));
268 /***************************************************************************
270 ***************************************************************************/
272 static BOOL api_lsa_enum_privs(pipes_struct *p)
274 LSA_Q_ENUM_PRIVS q_u;
275 LSA_R_ENUM_PRIVS r_u;
276 prs_struct *data = &p->in_data.data;
277 prs_struct *rdata = &p->out_data.rdata;
282 if(!lsa_io_q_enum_privs("", &q_u, data, 0)) {
283 DEBUG(0,("api_lsa_enum_privs: failed to unmarshall LSA_Q_ENUM_PRIVS.\n"));
287 r_u.status = _lsa_enum_privs(p, &q_u, &r_u);
289 /* store the response in the SMB stream */
290 if(!lsa_io_r_enum_privs("", &r_u, rdata, 0)) {
291 DEBUG(0,("api_lsa_enum_privs: Failed to marshall LSA_R_ENUM_PRIVS.\n"));
298 /***************************************************************************
300 ***************************************************************************/
302 static BOOL api_lsa_priv_get_dispname(pipes_struct *p)
304 LSA_Q_PRIV_GET_DISPNAME q_u;
305 LSA_R_PRIV_GET_DISPNAME r_u;
306 prs_struct *data = &p->in_data.data;
307 prs_struct *rdata = &p->out_data.rdata;
312 if(!lsa_io_q_priv_get_dispname("", &q_u, data, 0)) {
313 DEBUG(0,("api_lsa_priv_get_dispname: failed to unmarshall LSA_Q_PRIV_GET_DISPNAME.\n"));
317 r_u.status = _lsa_priv_get_dispname(p, &q_u, &r_u);
319 /* store the response in the SMB stream */
320 if(!lsa_io_r_priv_get_dispname("", &r_u, rdata, 0)) {
321 DEBUG(0,("api_lsa_priv_get_dispname: Failed to marshall LSA_R_PRIV_GET_DISPNAME.\n"));
328 /***************************************************************************
330 ***************************************************************************/
332 static BOOL api_lsa_enum_accounts(pipes_struct *p)
334 LSA_Q_ENUM_ACCOUNTS q_u;
335 LSA_R_ENUM_ACCOUNTS r_u;
336 prs_struct *data = &p->in_data.data;
337 prs_struct *rdata = &p->out_data.rdata;
342 if(!lsa_io_q_enum_accounts("", &q_u, data, 0)) {
343 DEBUG(0,("api_lsa_enum_accounts: failed to unmarshall LSA_Q_ENUM_ACCOUNTS.\n"));
347 r_u.status = _lsa_enum_accounts(p, &q_u, &r_u);
349 /* store the response in the SMB stream */
350 if(!lsa_io_r_enum_accounts("", &r_u, rdata, 0)) {
351 DEBUG(0,("api_lsa_enum_accounts: Failed to marshall LSA_R_ENUM_ACCOUNTS.\n"));
358 /***************************************************************************
359 api_lsa_UNK_GET_CONNUSER
360 ***************************************************************************/
362 static BOOL api_lsa_unk_get_connuser(pipes_struct *p)
364 LSA_Q_UNK_GET_CONNUSER q_u;
365 LSA_R_UNK_GET_CONNUSER r_u;
367 prs_struct *data = &p->in_data.data;
368 prs_struct *rdata = &p->out_data.rdata;
373 if(!lsa_io_q_unk_get_connuser("", &q_u, data, 0)) {
374 DEBUG(0,("api_lsa_unk_get_connuser: failed to unmarshall LSA_Q_UNK_GET_CONNUSER.\n"));
378 r_u.status = _lsa_unk_get_connuser(p, &q_u, &r_u);
380 /* store the response in the SMB stream */
381 if(!lsa_io_r_unk_get_connuser("", &r_u, rdata, 0)) {
382 DEBUG(0,("api_lsa_unk_get_connuser: Failed to marshall LSA_R_UNK_GET_CONNUSER.\n"));
389 /***************************************************************************
391 ***************************************************************************/
393 static BOOL api_lsa_open_account(pipes_struct *p)
395 LSA_Q_OPENACCOUNT q_u;
396 LSA_R_OPENACCOUNT r_u;
398 prs_struct *data = &p->in_data.data;
399 prs_struct *rdata = &p->out_data.rdata;
404 if(!lsa_io_q_open_account("", &q_u, data, 0)) {
405 DEBUG(0,("api_lsa_open_account: failed to unmarshall LSA_Q_OPENACCOUNT.\n"));
409 r_u.status = _lsa_open_account(p, &q_u, &r_u);
411 /* store the response in the SMB stream */
412 if(!lsa_io_r_open_account("", &r_u, rdata, 0)) {
413 DEBUG(0,("api_lsa_open_account: Failed to marshall LSA_R_OPENACCOUNT.\n"));
420 /***************************************************************************
422 ***************************************************************************/
424 static BOOL api_lsa_enum_privsaccount(pipes_struct *p)
426 LSA_Q_ENUMPRIVSACCOUNT q_u;
427 LSA_R_ENUMPRIVSACCOUNT r_u;
429 prs_struct *data = &p->in_data.data;
430 prs_struct *rdata = &p->out_data.rdata;
435 if(!lsa_io_q_enum_privsaccount("", &q_u, data, 0)) {
436 DEBUG(0,("api_lsa_enum_privsaccount: failed to unmarshall LSA_Q_ENUMPRIVSACCOUNT.\n"));
440 r_u.status = _lsa_enum_privsaccount(p, &q_u, &r_u);
442 /* store the response in the SMB stream */
443 if(!lsa_io_r_enum_privsaccount("", &r_u, rdata, 0)) {
444 DEBUG(0,("api_lsa_enum_privsaccount: Failed to marshall LSA_R_ENUMPRIVSACCOUNT.\n"));
451 /***************************************************************************
452 api_lsa_getsystemaccount
453 ***************************************************************************/
455 static BOOL api_lsa_getsystemaccount(pipes_struct *p)
457 LSA_Q_GETSYSTEMACCOUNT q_u;
458 LSA_R_GETSYSTEMACCOUNT r_u;
460 prs_struct *data = &p->in_data.data;
461 prs_struct *rdata = &p->out_data.rdata;
466 if(!lsa_io_q_getsystemaccount("", &q_u, data, 0)) {
467 DEBUG(0,("api_lsa_getsystemaccount: failed to unmarshall LSA_Q_GETSYSTEMACCOUNT.\n"));
471 r_u.status = _lsa_getsystemaccount(p, &q_u, &r_u);
473 /* store the response in the SMB stream */
474 if(!lsa_io_r_getsystemaccount("", &r_u, rdata, 0)) {
475 DEBUG(0,("api_lsa_getsystemaccount: Failed to marshall LSA_R_GETSYSTEMACCOUNT.\n"));
483 /***************************************************************************
484 api_lsa_setsystemaccount
485 ***************************************************************************/
487 static BOOL api_lsa_setsystemaccount(pipes_struct *p)
489 LSA_Q_SETSYSTEMACCOUNT q_u;
490 LSA_R_SETSYSTEMACCOUNT r_u;
492 prs_struct *data = &p->in_data.data;
493 prs_struct *rdata = &p->out_data.rdata;
498 if(!lsa_io_q_setsystemaccount("", &q_u, data, 0)) {
499 DEBUG(0,("api_lsa_setsystemaccount: failed to unmarshall LSA_Q_SETSYSTEMACCOUNT.\n"));
503 r_u.status = _lsa_setsystemaccount(p, &q_u, &r_u);
505 /* store the response in the SMB stream */
506 if(!lsa_io_r_setsystemaccount("", &r_u, rdata, 0)) {
507 DEBUG(0,("api_lsa_setsystemaccount: Failed to marshall LSA_R_SETSYSTEMACCOUNT.\n"));
514 /***************************************************************************
516 ***************************************************************************/
518 static BOOL api_lsa_addprivs(pipes_struct *p)
523 prs_struct *data = &p->in_data.data;
524 prs_struct *rdata = &p->out_data.rdata;
529 if(!lsa_io_q_addprivs("", &q_u, data, 0)) {
530 DEBUG(0,("api_lsa_addprivs: failed to unmarshall LSA_Q_ADDPRIVS.\n"));
534 r_u.status = _lsa_addprivs(p, &q_u, &r_u);
536 /* store the response in the SMB stream */
537 if(!lsa_io_r_addprivs("", &r_u, rdata, 0)) {
538 DEBUG(0,("api_lsa_addprivs: Failed to marshall LSA_R_ADDPRIVS.\n"));
545 /***************************************************************************
547 ***************************************************************************/
549 static BOOL api_lsa_removeprivs(pipes_struct *p)
551 LSA_Q_REMOVEPRIVS q_u;
552 LSA_R_REMOVEPRIVS r_u;
554 prs_struct *data = &p->in_data.data;
555 prs_struct *rdata = &p->out_data.rdata;
560 if(!lsa_io_q_removeprivs("", &q_u, data, 0)) {
561 DEBUG(0,("api_lsa_removeprivs: failed to unmarshall LSA_Q_REMOVEPRIVS.\n"));
565 r_u.status = _lsa_removeprivs(p, &q_u, &r_u);
567 /* store the response in the SMB stream */
568 if(!lsa_io_r_removeprivs("", &r_u, rdata, 0)) {
569 DEBUG(0,("api_lsa_removeprivs: Failed to marshall LSA_R_REMOVEPRIVS.\n"));
576 /***************************************************************************
578 ***************************************************************************/
580 static BOOL api_lsa_query_secobj(pipes_struct *p)
582 LSA_Q_QUERY_SEC_OBJ q_u;
583 LSA_R_QUERY_SEC_OBJ r_u;
585 prs_struct *data = &p->in_data.data;
586 prs_struct *rdata = &p->out_data.rdata;
591 if(!lsa_io_q_query_sec_obj("", &q_u, data, 0)) {
592 DEBUG(0,("api_lsa_query_secobj: failed to unmarshall LSA_Q_QUERY_SEC_OBJ.\n"));
596 r_u.status = _lsa_query_secobj(p, &q_u, &r_u);
598 /* store the response in the SMB stream */
599 if(!lsa_io_r_query_sec_obj("", &r_u, rdata, 0)) {
600 DEBUG(0,("api_lsa_query_secobj: Failed to marshall LSA_R_QUERY_SEC_OBJ.\n"));
607 /***************************************************************************
609 ***************************************************************************/
611 static struct api_struct api_lsa_cmds[] =
613 { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 },
614 { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy },
615 { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info },
616 { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom },
617 { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close },
618 { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret },
619 { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids },
620 { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names },
621 { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs },
622 { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname},
623 { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts },
624 { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser },
625 { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account },
626 { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount},
627 { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount },
628 { "LSA_SETSYSTEMACCOUNT", LSA_SETSYSTEMACCOUNT, api_lsa_setsystemaccount },
629 { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs },
630 { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs },
631 { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj },
635 /***************************************************************************
637 ***************************************************************************/
638 BOOL api_ntlsa_rpc(pipes_struct *p)
640 return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds);