r19224: Add setting the rng_fault_state to the already converted pipes.
[Samba/bb.git] / source / rpc_server / srv_lsa.c
blob0269e75e4e14fd2d0a36fe81dffa08636aadb6ed
1 /*
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,
8 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002-2003.
9 * Copyright (C) Gerald (Jerry) Carter 2005
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 /* This is the interface to the lsa server code. */
28 #include "includes.h"
30 #undef DBGC_CLASS
31 #define DBGC_CLASS DBGC_RPC_SRV
33 static BOOL proxy_lsa_call(pipes_struct *p, uint8 opnum)
35 struct api_struct *fns;
36 int n_fns;
38 lsarpc_get_pipe_fns(&fns, &n_fns);
40 if (opnum >= n_fns)
41 return False;
43 if (fns[opnum].opnum != opnum) {
44 smb_panic("LSA function table not sorted\n");
47 return fns[opnum].fn(p);
50 /***************************************************************************
51 api_lsa_open_policy2
52 ***************************************************************************/
54 static BOOL api_lsa_open_policy2(pipes_struct *p)
56 LSA_Q_OPEN_POL2 q_u;
57 LSA_R_OPEN_POL2 r_u;
58 prs_struct *data = &p->in_data.data;
59 prs_struct *rdata = &p->out_data.rdata;
61 ZERO_STRUCT(q_u);
62 ZERO_STRUCT(r_u);
64 /* grab the server, object attributes and desired access flag...*/
65 if(!lsa_io_q_open_pol2("", &q_u, data, 0)) {
66 DEBUG(0,("api_lsa_open_policy2: unable to unmarshall LSA_Q_OPEN_POL2.\n"));
67 return False;
70 r_u.status = _lsa_open_policy2(p, &q_u, &r_u);
72 /* store the response in the SMB stream */
73 if(!lsa_io_r_open_pol2("", &r_u, rdata, 0)) {
74 DEBUG(0,("api_lsa_open_policy2: unable to marshall LSA_R_OPEN_POL2.\n"));
75 return False;
78 return True;
81 /***************************************************************************
82 api_lsa_open_policy
83 ***************************************************************************/
85 static BOOL api_lsa_open_policy(pipes_struct *p)
87 LSA_Q_OPEN_POL q_u;
88 LSA_R_OPEN_POL r_u;
89 prs_struct *data = &p->in_data.data;
90 prs_struct *rdata = &p->out_data.rdata;
92 ZERO_STRUCT(q_u);
93 ZERO_STRUCT(r_u);
95 /* grab the server, object attributes and desired access flag...*/
96 if(!lsa_io_q_open_pol("", &q_u, data, 0)) {
97 DEBUG(0,("api_lsa_open_policy: unable to unmarshall LSA_Q_OPEN_POL.\n"));
98 return False;
101 r_u.status = _lsa_open_policy(p, &q_u, &r_u);
103 /* store the response in the SMB stream */
104 if(!lsa_io_r_open_pol("", &r_u, rdata, 0)) {
105 DEBUG(0,("api_lsa_open_policy: unable to marshall LSA_R_OPEN_POL.\n"));
106 return False;
109 return True;
112 /***************************************************************************
113 api_lsa_enum_trust_dom
114 ***************************************************************************/
116 static BOOL api_lsa_enum_trust_dom(pipes_struct *p)
118 LSA_Q_ENUM_TRUST_DOM q_u;
119 LSA_R_ENUM_TRUST_DOM r_u;
120 prs_struct *data = &p->in_data.data;
121 prs_struct *rdata = &p->out_data.rdata;
123 ZERO_STRUCT(q_u);
124 ZERO_STRUCT(r_u);
126 /* grab the enum trust domain context etc. */
127 if(!lsa_io_q_enum_trust_dom("", &q_u, data, 0))
128 return False;
130 /* get required trusted domains information */
131 r_u.status = _lsa_enum_trust_dom(p, &q_u, &r_u);
133 /* prepare the response */
134 if(!lsa_io_r_enum_trust_dom("", &r_u, rdata, 0))
135 return False;
137 return True;
140 /***************************************************************************
141 api_lsa_query_info
142 ***************************************************************************/
144 static BOOL api_lsa_query_info(pipes_struct *p)
146 LSA_Q_QUERY_INFO q_u;
147 LSA_R_QUERY_INFO r_u;
148 prs_struct *data = &p->in_data.data;
149 prs_struct *rdata = &p->out_data.rdata;
151 ZERO_STRUCT(q_u);
152 ZERO_STRUCT(r_u);
154 /* grab the info class and policy handle */
155 if(!lsa_io_q_query("", &q_u, data, 0)) {
156 DEBUG(0,("api_lsa_query_info: failed to unmarshall LSA_Q_QUERY_INFO.\n"));
157 return False;
160 r_u.status = _lsa_query_info(p, &q_u, &r_u);
162 /* store the response in the SMB stream */
163 if(!lsa_io_r_query("", &r_u, rdata, 0)) {
164 DEBUG(0,("api_lsa_query_info: failed to marshall LSA_R_QUERY_INFO.\n"));
165 return False;
168 return True;
171 /***************************************************************************
172 api_lsa_lookup_sids
173 ***************************************************************************/
175 static BOOL api_lsa_lookup_sids(pipes_struct *p)
177 LSA_Q_LOOKUP_SIDS q_u;
178 LSA_R_LOOKUP_SIDS r_u;
179 prs_struct *data = &p->in_data.data;
180 prs_struct *rdata = &p->out_data.rdata;
182 ZERO_STRUCT(q_u);
183 ZERO_STRUCT(r_u);
185 /* grab the info class and policy handle */
186 if(!lsa_io_q_lookup_sids("", &q_u, data, 0)) {
187 DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n"));
188 return False;
191 r_u.status = _lsa_lookup_sids(p, &q_u, &r_u);
193 if(!lsa_io_r_lookup_sids("", &r_u, rdata, 0)) {
194 DEBUG(0,("api_lsa_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n"));
195 return False;
198 return True;
201 /***************************************************************************
202 api_lsa_lookup_names
203 ***************************************************************************/
205 static BOOL api_lsa_lookup_names(pipes_struct *p)
207 LSA_Q_LOOKUP_NAMES q_u;
208 LSA_R_LOOKUP_NAMES r_u;
209 prs_struct *data = &p->in_data.data;
210 prs_struct *rdata = &p->out_data.rdata;
212 ZERO_STRUCT(q_u);
213 ZERO_STRUCT(r_u);
215 /* grab the info class and policy handle */
216 if(!lsa_io_q_lookup_names("", &q_u, data, 0)) {
217 DEBUG(0,("api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES.\n"));
218 return False;
221 r_u.status = _lsa_lookup_names(p, &q_u, &r_u);
223 /* store the response in the SMB stream */
224 if(!lsa_io_r_lookup_names("", &r_u, rdata, 0)) {
225 DEBUG(0,("api_lsa_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n"));
226 return False;
229 return True;
232 /***************************************************************************
233 api_lsa_close.
234 ***************************************************************************/
236 static BOOL api_lsa_close(pipes_struct *p)
238 return proxy_lsa_call(p, DCERPC_LSA_CLOSE);
241 /***************************************************************************
242 api_lsa_open_secret.
243 ***************************************************************************/
245 static BOOL api_lsa_open_secret(pipes_struct *p)
247 return proxy_lsa_call(p, DCERPC_LSA_OPENSECRET);
250 /***************************************************************************
251 api_lsa_open_secret.
252 ***************************************************************************/
254 static BOOL api_lsa_enum_privs(pipes_struct *p)
256 LSA_Q_ENUM_PRIVS q_u;
257 LSA_R_ENUM_PRIVS r_u;
258 prs_struct *data = &p->in_data.data;
259 prs_struct *rdata = &p->out_data.rdata;
261 ZERO_STRUCT(q_u);
262 ZERO_STRUCT(r_u);
264 if(!lsa_io_q_enum_privs("", &q_u, data, 0)) {
265 DEBUG(0,("api_lsa_enum_privs: failed to unmarshall LSA_Q_ENUM_PRIVS.\n"));
266 return False;
269 r_u.status = _lsa_enum_privs(p, &q_u, &r_u);
271 /* store the response in the SMB stream */
272 if(!lsa_io_r_enum_privs("", &r_u, rdata, 0)) {
273 DEBUG(0,("api_lsa_enum_privs: Failed to marshall LSA_R_ENUM_PRIVS.\n"));
274 return False;
277 return True;
280 /***************************************************************************
281 api_lsa_open_secret.
282 ***************************************************************************/
284 static BOOL api_lsa_priv_get_dispname(pipes_struct *p)
286 LSA_Q_PRIV_GET_DISPNAME q_u;
287 LSA_R_PRIV_GET_DISPNAME r_u;
288 prs_struct *data = &p->in_data.data;
289 prs_struct *rdata = &p->out_data.rdata;
291 ZERO_STRUCT(q_u);
292 ZERO_STRUCT(r_u);
294 if(!lsa_io_q_priv_get_dispname("", &q_u, data, 0)) {
295 DEBUG(0,("api_lsa_priv_get_dispname: failed to unmarshall LSA_Q_PRIV_GET_DISPNAME.\n"));
296 return False;
299 r_u.status = _lsa_priv_get_dispname(p, &q_u, &r_u);
301 /* store the response in the SMB stream */
302 if(!lsa_io_r_priv_get_dispname("", &r_u, rdata, 0)) {
303 DEBUG(0,("api_lsa_priv_get_dispname: Failed to marshall LSA_R_PRIV_GET_DISPNAME.\n"));
304 return False;
307 return True;
310 /***************************************************************************
311 api_lsa_open_secret.
312 ***************************************************************************/
314 static BOOL api_lsa_enum_accounts(pipes_struct *p)
316 LSA_Q_ENUM_ACCOUNTS q_u;
317 LSA_R_ENUM_ACCOUNTS r_u;
318 prs_struct *data = &p->in_data.data;
319 prs_struct *rdata = &p->out_data.rdata;
321 ZERO_STRUCT(q_u);
322 ZERO_STRUCT(r_u);
324 if(!lsa_io_q_enum_accounts("", &q_u, data, 0)) {
325 DEBUG(0,("api_lsa_enum_accounts: failed to unmarshall LSA_Q_ENUM_ACCOUNTS.\n"));
326 return False;
329 r_u.status = _lsa_enum_accounts(p, &q_u, &r_u);
331 /* store the response in the SMB stream */
332 if(!lsa_io_r_enum_accounts("", &r_u, rdata, 0)) {
333 DEBUG(0,("api_lsa_enum_accounts: Failed to marshall LSA_R_ENUM_ACCOUNTS.\n"));
334 return False;
337 return True;
340 /***************************************************************************
341 api_lsa_UNK_GET_CONNUSER
342 ***************************************************************************/
344 static BOOL api_lsa_unk_get_connuser(pipes_struct *p)
346 LSA_Q_UNK_GET_CONNUSER q_u;
347 LSA_R_UNK_GET_CONNUSER r_u;
349 prs_struct *data = &p->in_data.data;
350 prs_struct *rdata = &p->out_data.rdata;
352 ZERO_STRUCT(q_u);
353 ZERO_STRUCT(r_u);
355 if(!lsa_io_q_unk_get_connuser("", &q_u, data, 0)) {
356 DEBUG(0,("api_lsa_unk_get_connuser: failed to unmarshall LSA_Q_UNK_GET_CONNUSER.\n"));
357 return False;
360 r_u.status = _lsa_unk_get_connuser(p, &q_u, &r_u);
362 /* store the response in the SMB stream */
363 if(!lsa_io_r_unk_get_connuser("", &r_u, rdata, 0)) {
364 DEBUG(0,("api_lsa_unk_get_connuser: Failed to marshall LSA_R_UNK_GET_CONNUSER.\n"));
365 return False;
368 return True;
371 /***************************************************************************
372 api_lsa_create_user
373 ***************************************************************************/
375 static BOOL api_lsa_create_account(pipes_struct *p)
377 LSA_Q_CREATEACCOUNT q_u;
378 LSA_R_CREATEACCOUNT r_u;
380 prs_struct *data = &p->in_data.data;
381 prs_struct *rdata = &p->out_data.rdata;
383 ZERO_STRUCT(q_u);
384 ZERO_STRUCT(r_u);
386 if(!lsa_io_q_create_account("", &q_u, data, 0)) {
387 DEBUG(0,("api_lsa_create_account: failed to unmarshall LSA_Q_CREATEACCOUNT.\n"));
388 return False;
391 r_u.status = _lsa_create_account(p, &q_u, &r_u);
393 /* store the response in the SMB stream */
394 if(!lsa_io_r_create_account("", &r_u, rdata, 0)) {
395 DEBUG(0,("api_lsa_create_account: Failed to marshall LSA_R_CREATEACCOUNT.\n"));
396 return False;
399 return True;
402 /***************************************************************************
403 api_lsa_open_user
404 ***************************************************************************/
406 static BOOL api_lsa_open_account(pipes_struct *p)
408 LSA_Q_OPENACCOUNT q_u;
409 LSA_R_OPENACCOUNT r_u;
411 prs_struct *data = &p->in_data.data;
412 prs_struct *rdata = &p->out_data.rdata;
414 ZERO_STRUCT(q_u);
415 ZERO_STRUCT(r_u);
417 if(!lsa_io_q_open_account("", &q_u, data, 0)) {
418 DEBUG(0,("api_lsa_open_account: failed to unmarshall LSA_Q_OPENACCOUNT.\n"));
419 return False;
422 r_u.status = _lsa_open_account(p, &q_u, &r_u);
424 /* store the response in the SMB stream */
425 if(!lsa_io_r_open_account("", &r_u, rdata, 0)) {
426 DEBUG(0,("api_lsa_open_account: Failed to marshall LSA_R_OPENACCOUNT.\n"));
427 return False;
430 return True;
433 /***************************************************************************
434 api_lsa_get_privs
435 ***************************************************************************/
437 static BOOL api_lsa_enum_privsaccount(pipes_struct *p)
439 LSA_Q_ENUMPRIVSACCOUNT q_u;
440 LSA_R_ENUMPRIVSACCOUNT r_u;
442 prs_struct *data = &p->in_data.data;
443 prs_struct *rdata = &p->out_data.rdata;
445 ZERO_STRUCT(q_u);
446 ZERO_STRUCT(r_u);
448 if(!lsa_io_q_enum_privsaccount("", &q_u, data, 0)) {
449 DEBUG(0,("api_lsa_enum_privsaccount: failed to unmarshall LSA_Q_ENUMPRIVSACCOUNT.\n"));
450 return False;
453 r_u.status = _lsa_enum_privsaccount(p, rdata, &q_u, &r_u);
455 /* store the response in the SMB stream */
456 if(!lsa_io_r_enum_privsaccount("", &r_u, rdata, 0)) {
457 DEBUG(0,("api_lsa_enum_privsaccount: Failed to marshall LSA_R_ENUMPRIVSACCOUNT.\n"));
458 return False;
461 return True;
464 /***************************************************************************
465 api_lsa_getsystemaccount
466 ***************************************************************************/
468 static BOOL api_lsa_getsystemaccount(pipes_struct *p)
470 LSA_Q_GETSYSTEMACCOUNT q_u;
471 LSA_R_GETSYSTEMACCOUNT r_u;
473 prs_struct *data = &p->in_data.data;
474 prs_struct *rdata = &p->out_data.rdata;
476 ZERO_STRUCT(q_u);
477 ZERO_STRUCT(r_u);
479 if(!lsa_io_q_getsystemaccount("", &q_u, data, 0)) {
480 DEBUG(0,("api_lsa_getsystemaccount: failed to unmarshall LSA_Q_GETSYSTEMACCOUNT.\n"));
481 return False;
484 r_u.status = _lsa_getsystemaccount(p, &q_u, &r_u);
486 /* store the response in the SMB stream */
487 if(!lsa_io_r_getsystemaccount("", &r_u, rdata, 0)) {
488 DEBUG(0,("api_lsa_getsystemaccount: Failed to marshall LSA_R_GETSYSTEMACCOUNT.\n"));
489 return False;
492 return True;
496 /***************************************************************************
497 api_lsa_setsystemaccount
498 ***************************************************************************/
500 static BOOL api_lsa_setsystemaccount(pipes_struct *p)
502 LSA_Q_SETSYSTEMACCOUNT q_u;
503 LSA_R_SETSYSTEMACCOUNT r_u;
505 prs_struct *data = &p->in_data.data;
506 prs_struct *rdata = &p->out_data.rdata;
508 ZERO_STRUCT(q_u);
509 ZERO_STRUCT(r_u);
511 if(!lsa_io_q_setsystemaccount("", &q_u, data, 0)) {
512 DEBUG(0,("api_lsa_setsystemaccount: failed to unmarshall LSA_Q_SETSYSTEMACCOUNT.\n"));
513 return False;
516 r_u.status = _lsa_setsystemaccount(p, &q_u, &r_u);
518 /* store the response in the SMB stream */
519 if(!lsa_io_r_setsystemaccount("", &r_u, rdata, 0)) {
520 DEBUG(0,("api_lsa_setsystemaccount: Failed to marshall LSA_R_SETSYSTEMACCOUNT.\n"));
521 return False;
524 return True;
527 /***************************************************************************
528 api_lsa_addprivs
529 ***************************************************************************/
531 static BOOL api_lsa_addprivs(pipes_struct *p)
533 LSA_Q_ADDPRIVS q_u;
534 LSA_R_ADDPRIVS r_u;
536 prs_struct *data = &p->in_data.data;
537 prs_struct *rdata = &p->out_data.rdata;
539 ZERO_STRUCT(q_u);
540 ZERO_STRUCT(r_u);
542 if(!lsa_io_q_addprivs("", &q_u, data, 0)) {
543 DEBUG(0,("api_lsa_addprivs: failed to unmarshall LSA_Q_ADDPRIVS.\n"));
544 return False;
547 r_u.status = _lsa_addprivs(p, &q_u, &r_u);
549 /* store the response in the SMB stream */
550 if(!lsa_io_r_addprivs("", &r_u, rdata, 0)) {
551 DEBUG(0,("api_lsa_addprivs: Failed to marshall LSA_R_ADDPRIVS.\n"));
552 return False;
555 return True;
558 /***************************************************************************
559 api_lsa_removeprivs
560 ***************************************************************************/
562 static BOOL api_lsa_removeprivs(pipes_struct *p)
564 LSA_Q_REMOVEPRIVS q_u;
565 LSA_R_REMOVEPRIVS r_u;
567 prs_struct *data = &p->in_data.data;
568 prs_struct *rdata = &p->out_data.rdata;
570 ZERO_STRUCT(q_u);
571 ZERO_STRUCT(r_u);
573 if(!lsa_io_q_removeprivs("", &q_u, data, 0)) {
574 DEBUG(0,("api_lsa_removeprivs: failed to unmarshall LSA_Q_REMOVEPRIVS.\n"));
575 return False;
578 r_u.status = _lsa_removeprivs(p, &q_u, &r_u);
580 /* store the response in the SMB stream */
581 if(!lsa_io_r_removeprivs("", &r_u, rdata, 0)) {
582 DEBUG(0,("api_lsa_removeprivs: Failed to marshall LSA_R_REMOVEPRIVS.\n"));
583 return False;
586 return True;
589 /***************************************************************************
590 api_lsa_query_secobj
591 ***************************************************************************/
593 static BOOL api_lsa_query_secobj(pipes_struct *p)
595 LSA_Q_QUERY_SEC_OBJ q_u;
596 LSA_R_QUERY_SEC_OBJ r_u;
598 prs_struct *data = &p->in_data.data;
599 prs_struct *rdata = &p->out_data.rdata;
601 ZERO_STRUCT(q_u);
602 ZERO_STRUCT(r_u);
604 if(!lsa_io_q_query_sec_obj("", &q_u, data, 0)) {
605 DEBUG(0,("api_lsa_query_secobj: failed to unmarshall LSA_Q_QUERY_SEC_OBJ.\n"));
606 return False;
609 r_u.status = _lsa_query_secobj(p, &q_u, &r_u);
611 /* store the response in the SMB stream */
612 if(!lsa_io_r_query_sec_obj("", &r_u, rdata, 0)) {
613 DEBUG(0,("api_lsa_query_secobj: Failed to marshall LSA_R_QUERY_SEC_OBJ.\n"));
614 return False;
617 return True;
620 /***************************************************************************
621 api_lsa_add_acct_rights
622 ***************************************************************************/
624 static BOOL api_lsa_add_acct_rights(pipes_struct *p)
626 LSA_Q_ADD_ACCT_RIGHTS q_u;
627 LSA_R_ADD_ACCT_RIGHTS r_u;
629 prs_struct *data = &p->in_data.data;
630 prs_struct *rdata = &p->out_data.rdata;
632 ZERO_STRUCT(q_u);
633 ZERO_STRUCT(r_u);
635 if(!lsa_io_q_add_acct_rights("", &q_u, data, 0)) {
636 DEBUG(0,("api_lsa_add_acct_rights: failed to unmarshall LSA_Q_ADD_ACCT_RIGHTS.\n"));
637 return False;
640 r_u.status = _lsa_add_acct_rights(p, &q_u, &r_u);
642 /* store the response in the SMB stream */
643 if(!lsa_io_r_add_acct_rights("", &r_u, rdata, 0)) {
644 DEBUG(0,("api_lsa_add_acct_rights: Failed to marshall LSA_R_ADD_ACCT_RIGHTS.\n"));
645 return False;
648 return True;
651 /***************************************************************************
652 api_lsa_remove_acct_rights
653 ***************************************************************************/
655 static BOOL api_lsa_remove_acct_rights(pipes_struct *p)
657 LSA_Q_REMOVE_ACCT_RIGHTS q_u;
658 LSA_R_REMOVE_ACCT_RIGHTS r_u;
660 prs_struct *data = &p->in_data.data;
661 prs_struct *rdata = &p->out_data.rdata;
663 ZERO_STRUCT(q_u);
664 ZERO_STRUCT(r_u);
666 if(!lsa_io_q_remove_acct_rights("", &q_u, data, 0)) {
667 DEBUG(0,("api_lsa_remove_acct_rights: failed to unmarshall LSA_Q_REMOVE_ACCT_RIGHTS.\n"));
668 return False;
671 r_u.status = _lsa_remove_acct_rights(p, &q_u, &r_u);
673 /* store the response in the SMB stream */
674 if(!lsa_io_r_remove_acct_rights("", &r_u, rdata, 0)) {
675 DEBUG(0,("api_lsa_remove_acct_rights: Failed to marshall LSA_R_REMOVE_ACCT_RIGHTS.\n"));
676 return False;
679 return True;
682 /***************************************************************************
683 api_lsa_enum_acct_rights
684 ***************************************************************************/
686 static BOOL api_lsa_enum_acct_rights(pipes_struct *p)
688 LSA_Q_ENUM_ACCT_RIGHTS q_u;
689 LSA_R_ENUM_ACCT_RIGHTS r_u;
691 prs_struct *data = &p->in_data.data;
692 prs_struct *rdata = &p->out_data.rdata;
694 ZERO_STRUCT(q_u);
695 ZERO_STRUCT(r_u);
697 if(!lsa_io_q_enum_acct_rights("", &q_u, data, 0)) {
698 DEBUG(0,("api_lsa_enum_acct_rights: failed to unmarshall LSA_Q_ENUM_ACCT_RIGHTS.\n"));
699 return False;
702 r_u.status = _lsa_enum_acct_rights(p, &q_u, &r_u);
704 /* store the response in the SMB stream */
705 if(!lsa_io_r_enum_acct_rights("", &r_u, rdata, 0)) {
706 DEBUG(0,("api_lsa_enum_acct_rights: Failed to marshall LSA_R_ENUM_ACCT_RIGHTS.\n"));
707 return False;
710 return True;
713 /***************************************************************************
714 api_lsa_lookup_priv_value
715 ***************************************************************************/
717 static BOOL api_lsa_lookup_priv_value(pipes_struct *p)
719 LSA_Q_LOOKUP_PRIV_VALUE q_u;
720 LSA_R_LOOKUP_PRIV_VALUE r_u;
722 prs_struct *data = &p->in_data.data;
723 prs_struct *rdata = &p->out_data.rdata;
725 ZERO_STRUCT(q_u);
726 ZERO_STRUCT(r_u);
728 if(!lsa_io_q_lookup_priv_value("", &q_u, data, 0)) {
729 DEBUG(0,("api_lsa_lookup_priv_value: failed to unmarshall LSA_Q_LOOKUP_PRIV_VALUE .\n"));
730 return False;
733 r_u.status = _lsa_lookup_priv_value(p, &q_u, &r_u);
735 /* store the response in the SMB stream */
736 if(!lsa_io_r_lookup_priv_value("", &r_u, rdata, 0)) {
737 DEBUG(0,("api_lsa_lookup_priv_value: Failed to marshall LSA_R_LOOKUP_PRIV_VALUE.\n"));
738 return False;
741 return True;
744 /***************************************************************************
745 ***************************************************************************/
747 static BOOL api_lsa_open_trust_dom(pipes_struct *p)
749 return proxy_lsa_call(p, DCERPC_LSA_OPENTRUSTEDDOMAIN);
752 /***************************************************************************
753 ***************************************************************************/
755 static BOOL api_lsa_create_trust_dom(pipes_struct *p)
757 return proxy_lsa_call(p, DCERPC_LSA_CREATETRUSTEDDOMAIN);
760 /***************************************************************************
761 ***************************************************************************/
763 static BOOL api_lsa_create_secret(pipes_struct *p)
765 return proxy_lsa_call(p, DCERPC_LSA_CREATESECRET);
768 /***************************************************************************
769 ***************************************************************************/
771 static BOOL api_lsa_set_secret(pipes_struct *p)
773 return proxy_lsa_call(p, DCERPC_LSA_SETSECRET);
776 /***************************************************************************
777 ***************************************************************************/
779 static BOOL api_lsa_delete_object(pipes_struct *p)
781 LSA_Q_DELETE_OBJECT q_u;
782 LSA_R_DELETE_OBJECT r_u;
784 prs_struct *data = &p->in_data.data;
785 prs_struct *rdata = &p->out_data.rdata;
787 ZERO_STRUCT(q_u);
788 ZERO_STRUCT(r_u);
790 if(!lsa_io_q_delete_object("", &q_u, data, 0)) {
791 DEBUG(0,("api_lsa_delete_object: failed to unmarshall LSA_Q_DELETE_OBJECT.\n"));
792 return False;
795 r_u.status = _lsa_delete_object(p, &q_u, &r_u);
797 /* store the response in the SMB stream */
798 if(!lsa_io_r_delete_object("", &r_u, rdata, 0)) {
799 DEBUG(0,("api_lsa_delete_object: Failed to marshall LSA_R_DELETE_OBJECT.\n"));
800 return False;
803 return True;
806 /***************************************************************************
807 api_lsa_lookup_sids2
808 ***************************************************************************/
810 static BOOL api_lsa_lookup_sids2(pipes_struct *p)
812 LSA_Q_LOOKUP_SIDS2 q_u;
813 LSA_R_LOOKUP_SIDS2 r_u;
814 prs_struct *data = &p->in_data.data;
815 prs_struct *rdata = &p->out_data.rdata;
817 ZERO_STRUCT(q_u);
818 ZERO_STRUCT(r_u);
820 /* grab the info class and policy handle */
821 if(!lsa_io_q_lookup_sids2("", &q_u, data, 0)) {
822 DEBUG(0,("api_lsa_lookup_sids2: failed to unmarshall LSA_Q_LOOKUP_SIDS2.\n"));
823 return False;
826 r_u.status = _lsa_lookup_sids2(p, &q_u, &r_u);
828 if(!lsa_io_r_lookup_sids2("", &r_u, rdata, 0)) {
829 DEBUG(0,("api_lsa_lookup_sids2: Failed to marshall LSA_R_LOOKUP_SIDS2.\n"));
830 return False;
833 return True;
836 /***************************************************************************
837 api_lsa_lookup_sids3
838 ***************************************************************************/
840 static BOOL api_lsa_lookup_sids3(pipes_struct *p)
842 LSA_Q_LOOKUP_SIDS3 q_u;
843 LSA_R_LOOKUP_SIDS3 r_u;
844 prs_struct *data = &p->in_data.data;
845 prs_struct *rdata = &p->out_data.rdata;
847 ZERO_STRUCT(q_u);
848 ZERO_STRUCT(r_u);
850 /* grab the info class and policy handle */
851 if(!lsa_io_q_lookup_sids3("", &q_u, data, 0)) {
852 DEBUG(0,("api_lsa_lookup_sids3: failed to unmarshall LSA_Q_LOOKUP_SIDS3.\n"));
853 return False;
856 r_u.status = _lsa_lookup_sids3(p, &q_u, &r_u);
858 if(!lsa_io_r_lookup_sids3("", &r_u, rdata, 0)) {
859 DEBUG(0,("api_lsa_lookup_sids3: Failed to marshall LSA_R_LOOKUP_SIDS3.\n"));
860 return False;
863 return True;
866 /***************************************************************************
867 api_lsa_lookup_names2
868 ***************************************************************************/
870 static BOOL api_lsa_lookup_names2(pipes_struct *p)
872 LSA_Q_LOOKUP_NAMES2 q_u;
873 LSA_R_LOOKUP_NAMES2 r_u;
874 prs_struct *data = &p->in_data.data;
875 prs_struct *rdata = &p->out_data.rdata;
877 ZERO_STRUCT(q_u);
878 ZERO_STRUCT(r_u);
880 /* grab the info class and policy handle */
881 if(!lsa_io_q_lookup_names2("", &q_u, data, 0)) {
882 DEBUG(0,("api_lsa_lookup_names2: failed to unmarshall LSA_Q_LOOKUP_NAMES2.\n"));
883 return False;
886 r_u.status = _lsa_lookup_names2(p, &q_u, &r_u);
888 /* store the response in the SMB stream */
889 if(!lsa_io_r_lookup_names2("", &r_u, rdata, 0)) {
890 DEBUG(0,("api_lsa_lookup_names2: Failed to marshall LSA_R_LOOKUP_NAMES2.\n"));
891 return False;
894 return True;
897 /***************************************************************************
898 api_lsa_lookup_names3
899 ***************************************************************************/
901 static BOOL api_lsa_lookup_names3(pipes_struct *p)
903 LSA_Q_LOOKUP_NAMES3 q_u;
904 LSA_R_LOOKUP_NAMES3 r_u;
905 prs_struct *data = &p->in_data.data;
906 prs_struct *rdata = &p->out_data.rdata;
908 ZERO_STRUCT(q_u);
909 ZERO_STRUCT(r_u);
911 /* grab the info class and policy handle */
912 if(!lsa_io_q_lookup_names3("", &q_u, data, 0)) {
913 DEBUG(0,("api_lsa_lookup_names3: failed to unmarshall LSA_Q_LOOKUP_NAMES3.\n"));
914 return False;
917 r_u.status = _lsa_lookup_names3(p, &q_u, &r_u);
919 /* store the response in the SMB stream */
920 if(!lsa_io_r_lookup_names3("", &r_u, rdata, 0)) {
921 DEBUG(0,("api_lsa_lookup_names3: Failed to marshall LSA_R_LOOKUP_NAMES3.\n"));
922 return False;
925 return True;
928 /***************************************************************************
929 api_lsa_lookup_names4
930 ***************************************************************************/
932 static BOOL api_lsa_lookup_names4(pipes_struct *p)
934 LSA_Q_LOOKUP_NAMES4 q_u;
935 LSA_R_LOOKUP_NAMES4 r_u;
936 prs_struct *data = &p->in_data.data;
937 prs_struct *rdata = &p->out_data.rdata;
939 ZERO_STRUCT(q_u);
940 ZERO_STRUCT(r_u);
942 /* grab the info class and policy handle */
943 if(!lsa_io_q_lookup_names4("", &q_u, data, 0)) {
944 DEBUG(0,("api_lsa_lookup_names4: failed to unmarshall LSA_Q_LOOKUP_NAMES4.\n"));
945 return False;
948 r_u.status = _lsa_lookup_names4(p, &q_u, &r_u);
950 /* store the response in the SMB stream */
951 if(!lsa_io_r_lookup_names4("", &r_u, rdata, 0)) {
952 DEBUG(0,("api_lsa_lookup_names4: Failed to marshall LSA_R_LOOKUP_NAMES4.\n"));
953 return False;
956 return True;
959 #if 0 /* AD DC work in ongoing in Samba 4 */
961 /***************************************************************************
962 api_lsa_query_info2
963 ***************************************************************************/
965 static BOOL api_lsa_query_info2(pipes_struct *p)
967 LSA_Q_QUERY_INFO2 q_u;
968 LSA_R_QUERY_INFO2 r_u;
970 prs_struct *data = &p->in_data.data;
971 prs_struct *rdata = &p->out_data.rdata;
973 ZERO_STRUCT(q_u);
974 ZERO_STRUCT(r_u);
976 if(!lsa_io_q_query_info2("", &q_u, data, 0)) {
977 DEBUG(0,("api_lsa_query_info2: failed to unmarshall LSA_Q_QUERY_INFO2.\n"));
978 return False;
981 r_u.status = _lsa_query_info2(p, &q_u, &r_u);
983 if (!lsa_io_r_query_info2("", &r_u, rdata, 0)) {
984 DEBUG(0,("api_lsa_query_info2: failed to marshall LSA_R_QUERY_INFO2.\n"));
985 return False;
988 return True;
990 #endif /* AD DC work in ongoing in Samba 4 */
992 /***************************************************************************
993 \PIPE\ntlsa commands
994 ***************************************************************************/
996 static struct api_struct api_lsa_cmds[] =
998 { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 },
999 { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy },
1000 { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info },
1001 { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom },
1002 { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close },
1003 { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret },
1004 { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids },
1005 { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names },
1006 { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs },
1007 { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname},
1008 { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts },
1009 { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser },
1010 { "LSA_CREATEACCOUNT" , LSA_CREATEACCOUNT , api_lsa_create_account },
1011 { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account },
1012 { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount},
1013 { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount },
1014 { "LSA_SETSYSTEMACCOUNT", LSA_SETSYSTEMACCOUNT, api_lsa_setsystemaccount },
1015 { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs },
1016 { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs },
1017 { "LSA_ADDACCTRIGHTS" , LSA_ADDACCTRIGHTS , api_lsa_add_acct_rights },
1018 { "LSA_REMOVEACCTRIGHTS", LSA_REMOVEACCTRIGHTS, api_lsa_remove_acct_rights },
1019 { "LSA_ENUMACCTRIGHTS" , LSA_ENUMACCTRIGHTS , api_lsa_enum_acct_rights },
1020 { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj },
1021 { "LSA_LOOKUPPRIVVALUE" , LSA_LOOKUPPRIVVALUE , api_lsa_lookup_priv_value },
1022 { "LSA_OPENTRUSTDOM" , LSA_OPENTRUSTDOM , api_lsa_open_trust_dom },
1023 { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret },
1024 { "LSA_CREATETRUSTDOM" , LSA_CREATETRUSTDOM , api_lsa_create_trust_dom },
1025 { "LSA_CREATSECRET" , LSA_CREATESECRET , api_lsa_create_secret },
1026 { "LSA_SETSECRET" , LSA_SETSECRET , api_lsa_set_secret },
1027 { "LSA_DELETEOBJECT" , LSA_DELETEOBJECT , api_lsa_delete_object },
1028 { "LSA_LOOKUPSIDS2" , LSA_LOOKUPSIDS2 , api_lsa_lookup_sids2 },
1029 { "LSA_LOOKUPNAMES2" , LSA_LOOKUPNAMES2 , api_lsa_lookup_names2 },
1030 { "LSA_LOOKUPNAMES3" , LSA_LOOKUPNAMES3 , api_lsa_lookup_names3 },
1031 { "LSA_LOOKUPSIDS3" , LSA_LOOKUPSIDS3 , api_lsa_lookup_sids3 },
1032 { "LSA_LOOKUPNAMES4" , LSA_LOOKUPNAMES4 , api_lsa_lookup_names4 }
1033 #if 0 /* AD DC work in ongoing in Samba 4 */
1034 /* be careful of the adding of new RPC's. See commentrs below about
1035 ADS DC capabilities */
1036 { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 }
1037 #endif /* AD DC work in ongoing in Samba 4 */
1040 static int count_fns(void)
1042 int funcs = sizeof(api_lsa_cmds) / sizeof(struct api_struct);
1044 #if 0 /* AD DC work is on going in Samba 4 */
1046 * NOTE: Certain calls can not be enabled if we aren't an ADS DC. Make sure
1047 * these calls are always last and that you decrement by the amount of calls
1048 * to disable.
1050 if (!(SEC_ADS == lp_security() && ROLE_DOMAIN_PDC == lp_server_role())) {
1051 funcs -= 1;
1053 #endif /* AD DC work in ongoing in Samba 4 */
1055 return funcs;
1057 void lsa_get_pipe_fns( struct api_struct **fns, int *n_fns )
1059 *fns = api_lsa_cmds;
1060 *n_fns = count_fns();
1064 NTSTATUS rpc_lsa_init(void)
1066 int funcs = count_fns();
1068 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsarpc", "lsass", api_lsa_cmds,
1069 funcs);