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"));
329 /***************************************************************************
331 ***************************************************************************/
333 static BOOL api_lsa_enum_accounts(pipes_struct *p)
335 LSA_Q_ENUM_ACCOUNTS q_u;
336 LSA_R_ENUM_ACCOUNTS r_u;
337 prs_struct *data = &p->in_data.data;
338 prs_struct *rdata = &p->out_data.rdata;
343 if(!lsa_io_q_enum_accounts("", &q_u, data, 0)) {
344 DEBUG(0,("api_lsa_enum_accounts: failed to unmarshall LSA_Q_ENUM_ACCOUNTS.\n"));
348 r_u.status = _lsa_enum_accounts(p, &q_u, &r_u);
350 /* store the response in the SMB stream */
351 if(!lsa_io_r_enum_accounts("", &r_u, rdata, 0)) {
352 DEBUG(0,("api_lsa_enum_accounts: Failed to marshall LSA_R_ENUM_ACCOUNTS.\n"));
359 /***************************************************************************
360 api_lsa_UNK_GET_CONNUSER
361 ***************************************************************************/
363 static BOOL api_lsa_unk_get_connuser(pipes_struct *p)
365 LSA_Q_UNK_GET_CONNUSER q_u;
366 LSA_R_UNK_GET_CONNUSER r_u;
368 prs_struct *data = &p->in_data.data;
369 prs_struct *rdata = &p->out_data.rdata;
374 if(!lsa_io_q_unk_get_connuser("", &q_u, data, 0)) {
375 DEBUG(0,("api_lsa_unk_get_connuser: failed to unmarshall LSA_Q_UNK_GET_CONNUSER.\n"));
379 r_u.status = _lsa_unk_get_connuser(p, &q_u, &r_u);
381 /* store the response in the SMB stream */
382 if(!lsa_io_r_unk_get_connuser("", &r_u, rdata, 0)) {
383 DEBUG(0,("api_lsa_unk_get_connuser: Failed to marshall LSA_R_UNK_GET_CONNUSER.\n"));
390 /***************************************************************************
392 ***************************************************************************/
394 static BOOL api_lsa_open_account(pipes_struct *p)
396 LSA_Q_OPENACCOUNT q_u;
397 LSA_R_OPENACCOUNT r_u;
399 prs_struct *data = &p->in_data.data;
400 prs_struct *rdata = &p->out_data.rdata;
405 if(!lsa_io_q_open_account("", &q_u, data, 0)) {
406 DEBUG(0,("api_lsa_open_account: failed to unmarshall LSA_Q_OPENACCOUNT.\n"));
410 r_u.status = _lsa_open_account(p, &q_u, &r_u);
412 /* store the response in the SMB stream */
413 if(!lsa_io_r_open_account("", &r_u, rdata, 0)) {
414 DEBUG(0,("api_lsa_open_account: Failed to marshall LSA_R_OPENACCOUNT.\n"));
421 /***************************************************************************
423 ***************************************************************************/
425 static BOOL api_lsa_enum_privsaccount(pipes_struct *p)
427 LSA_Q_ENUMPRIVSACCOUNT q_u;
428 LSA_R_ENUMPRIVSACCOUNT r_u;
430 prs_struct *data = &p->in_data.data;
431 prs_struct *rdata = &p->out_data.rdata;
436 if(!lsa_io_q_enum_privsaccount("", &q_u, data, 0)) {
437 DEBUG(0,("api_lsa_enum_privsaccount: failed to unmarshall LSA_Q_ENUMPRIVSACCOUNT.\n"));
441 r_u.status = _lsa_enum_privsaccount(p, &q_u, &r_u);
443 /* store the response in the SMB stream */
444 if(!lsa_io_r_enum_privsaccount("", &r_u, rdata, 0)) {
445 DEBUG(0,("api_lsa_enum_privsaccount: Failed to marshall LSA_R_ENUMPRIVSACCOUNT.\n"));
452 /***************************************************************************
453 api_lsa_getsystemaccount
454 ***************************************************************************/
456 static BOOL api_lsa_getsystemaccount(pipes_struct *p)
458 LSA_Q_GETSYSTEMACCOUNT q_u;
459 LSA_R_GETSYSTEMACCOUNT r_u;
461 prs_struct *data = &p->in_data.data;
462 prs_struct *rdata = &p->out_data.rdata;
467 if(!lsa_io_q_getsystemaccount("", &q_u, data, 0)) {
468 DEBUG(0,("api_lsa_getsystemaccount: failed to unmarshall LSA_Q_GETSYSTEMACCOUNT.\n"));
472 r_u.status = _lsa_getsystemaccount(p, &q_u, &r_u);
474 /* store the response in the SMB stream */
475 if(!lsa_io_r_getsystemaccount("", &r_u, rdata, 0)) {
476 DEBUG(0,("api_lsa_getsystemaccount: Failed to marshall LSA_R_GETSYSTEMACCOUNT.\n"));
484 /***************************************************************************
485 api_lsa_setsystemaccount
486 ***************************************************************************/
488 static BOOL api_lsa_setsystemaccount(pipes_struct *p)
490 LSA_Q_SETSYSTEMACCOUNT q_u;
491 LSA_R_SETSYSTEMACCOUNT r_u;
493 prs_struct *data = &p->in_data.data;
494 prs_struct *rdata = &p->out_data.rdata;
499 if(!lsa_io_q_setsystemaccount("", &q_u, data, 0)) {
500 DEBUG(0,("api_lsa_setsystemaccount: failed to unmarshall LSA_Q_SETSYSTEMACCOUNT.\n"));
504 r_u.status = _lsa_setsystemaccount(p, &q_u, &r_u);
506 /* store the response in the SMB stream */
507 if(!lsa_io_r_setsystemaccount("", &r_u, rdata, 0)) {
508 DEBUG(0,("api_lsa_setsystemaccount: Failed to marshall LSA_R_SETSYSTEMACCOUNT.\n"));
515 /***************************************************************************
517 ***************************************************************************/
519 static BOOL api_lsa_addprivs(pipes_struct *p)
524 prs_struct *data = &p->in_data.data;
525 prs_struct *rdata = &p->out_data.rdata;
530 if(!lsa_io_q_addprivs("", &q_u, data, 0)) {
531 DEBUG(0,("api_lsa_addprivs: failed to unmarshall LSA_Q_ADDPRIVS.\n"));
535 r_u.status = _lsa_addprivs(p, &q_u, &r_u);
537 /* store the response in the SMB stream */
538 if(!lsa_io_r_addprivs("", &r_u, rdata, 0)) {
539 DEBUG(0,("api_lsa_addprivs: Failed to marshall LSA_R_ADDPRIVS.\n"));
546 /***************************************************************************
548 ***************************************************************************/
550 static BOOL api_lsa_removeprivs(pipes_struct *p)
552 LSA_Q_REMOVEPRIVS q_u;
553 LSA_R_REMOVEPRIVS r_u;
555 prs_struct *data = &p->in_data.data;
556 prs_struct *rdata = &p->out_data.rdata;
561 if(!lsa_io_q_removeprivs("", &q_u, data, 0)) {
562 DEBUG(0,("api_lsa_removeprivs: failed to unmarshall LSA_Q_REMOVEPRIVS.\n"));
566 r_u.status = _lsa_removeprivs(p, &q_u, &r_u);
568 /* store the response in the SMB stream */
569 if(!lsa_io_r_removeprivs("", &r_u, rdata, 0)) {
570 DEBUG(0,("api_lsa_removeprivs: Failed to marshall LSA_R_REMOVEPRIVS.\n"));
578 /***************************************************************************
580 ***************************************************************************/
582 static struct api_struct api_lsa_cmds[] =
584 { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 },
585 { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy },
586 { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info },
587 { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom },
588 { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close },
589 { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret },
590 { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids },
591 { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names },
592 { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs },
593 { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname},
594 { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts },
595 { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser },
596 { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account },
597 { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount},
598 { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount },
599 { "LSA_SETSYSTEMACCOUNT", LSA_SETSYSTEMACCOUNT, api_lsa_setsystemaccount },
600 { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs },
601 { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs },
605 /***************************************************************************
607 ***************************************************************************/
608 BOOL api_ntlsa_rpc(pipes_struct *p)
610 return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds);