Use pidl for _lsa_GetSystemAccessAccount().
[Samba.git] / source / rpc_server / srv_lsa.c
blob24bc65c51ace955f0bf4718e82c3dc5e214df715
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 3 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, see <http://www.gnu.org/licenses/>.
25 /* This is the interface to the lsa server code. */
27 #include "includes.h"
29 #undef DBGC_CLASS
30 #define DBGC_CLASS DBGC_RPC_SRV
32 static bool proxy_lsa_call(pipes_struct *p, uint8 opnum)
34 struct api_struct *fns;
35 int n_fns;
37 lsarpc_get_pipe_fns(&fns, &n_fns);
39 if (opnum >= n_fns)
40 return False;
42 if (fns[opnum].opnum != opnum) {
43 smb_panic("LSA function table not sorted");
46 return fns[opnum].fn(p);
49 /***************************************************************************
50 api_lsa_open_policy2
51 ***************************************************************************/
53 static bool api_lsa_open_policy2(pipes_struct *p)
55 return proxy_lsa_call(p, NDR_LSA_OPENPOLICY2);
58 /***************************************************************************
59 api_lsa_open_policy
60 ***************************************************************************/
62 static bool api_lsa_open_policy(pipes_struct *p)
64 return proxy_lsa_call(p, NDR_LSA_OPENPOLICY);
67 /***************************************************************************
68 api_lsa_enum_trust_dom
69 ***************************************************************************/
71 static bool api_lsa_enum_trust_dom(pipes_struct *p)
73 LSA_Q_ENUM_TRUST_DOM q_u;
74 LSA_R_ENUM_TRUST_DOM r_u;
75 prs_struct *data = &p->in_data.data;
76 prs_struct *rdata = &p->out_data.rdata;
78 ZERO_STRUCT(q_u);
79 ZERO_STRUCT(r_u);
81 /* grab the enum trust domain context etc. */
82 if(!lsa_io_q_enum_trust_dom("", &q_u, data, 0))
83 return False;
85 /* get required trusted domains information */
86 r_u.status = _lsa_enum_trust_dom(p, &q_u, &r_u);
88 /* prepare the response */
89 if(!lsa_io_r_enum_trust_dom("", &r_u, rdata, 0))
90 return False;
92 return True;
95 /***************************************************************************
96 api_lsa_query_info
97 ***************************************************************************/
99 static bool api_lsa_query_info(pipes_struct *p)
101 return proxy_lsa_call(p, NDR_LSA_QUERYINFOPOLICY);
104 /***************************************************************************
105 api_lsa_lookup_sids
106 ***************************************************************************/
108 static bool api_lsa_lookup_sids(pipes_struct *p)
110 LSA_Q_LOOKUP_SIDS q_u;
111 LSA_R_LOOKUP_SIDS r_u;
112 prs_struct *data = &p->in_data.data;
113 prs_struct *rdata = &p->out_data.rdata;
115 ZERO_STRUCT(q_u);
116 ZERO_STRUCT(r_u);
118 /* grab the info class and policy handle */
119 if(!lsa_io_q_lookup_sids("", &q_u, data, 0)) {
120 DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n"));
121 return False;
124 r_u.status = _lsa_lookup_sids(p, &q_u, &r_u);
126 if(!lsa_io_r_lookup_sids("", &r_u, rdata, 0)) {
127 DEBUG(0,("api_lsa_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n"));
128 return False;
131 return True;
134 /***************************************************************************
135 api_lsa_lookup_names
136 ***************************************************************************/
138 static bool api_lsa_lookup_names(pipes_struct *p)
140 LSA_Q_LOOKUP_NAMES q_u;
141 LSA_R_LOOKUP_NAMES r_u;
142 prs_struct *data = &p->in_data.data;
143 prs_struct *rdata = &p->out_data.rdata;
145 ZERO_STRUCT(q_u);
146 ZERO_STRUCT(r_u);
148 /* grab the info class and policy handle */
149 if(!lsa_io_q_lookup_names("", &q_u, data, 0)) {
150 DEBUG(0,("api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES.\n"));
151 return False;
154 r_u.status = _lsa_lookup_names(p, &q_u, &r_u);
156 /* store the response in the SMB stream */
157 if(!lsa_io_r_lookup_names("", &r_u, rdata, 0)) {
158 DEBUG(0,("api_lsa_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n"));
159 return False;
162 return True;
165 /***************************************************************************
166 api_lsa_close.
167 ***************************************************************************/
169 static bool api_lsa_close(pipes_struct *p)
171 return proxy_lsa_call(p, NDR_LSA_CLOSE);
174 /***************************************************************************
175 api_lsa_open_secret.
176 ***************************************************************************/
178 static bool api_lsa_open_secret(pipes_struct *p)
180 return proxy_lsa_call(p, NDR_LSA_OPENSECRET);
183 /***************************************************************************
184 api_lsa_open_secret.
185 ***************************************************************************/
187 static bool api_lsa_enum_privs(pipes_struct *p)
189 LSA_Q_ENUM_PRIVS q_u;
190 LSA_R_ENUM_PRIVS r_u;
191 prs_struct *data = &p->in_data.data;
192 prs_struct *rdata = &p->out_data.rdata;
194 ZERO_STRUCT(q_u);
195 ZERO_STRUCT(r_u);
197 if(!lsa_io_q_enum_privs("", &q_u, data, 0)) {
198 DEBUG(0,("api_lsa_enum_privs: failed to unmarshall LSA_Q_ENUM_PRIVS.\n"));
199 return False;
202 r_u.status = _lsa_enum_privs(p, &q_u, &r_u);
204 /* store the response in the SMB stream */
205 if(!lsa_io_r_enum_privs("", &r_u, rdata, 0)) {
206 DEBUG(0,("api_lsa_enum_privs: Failed to marshall LSA_R_ENUM_PRIVS.\n"));
207 return False;
210 return True;
213 /***************************************************************************
214 api_lsa_open_secret.
215 ***************************************************************************/
217 static bool api_lsa_priv_get_dispname(pipes_struct *p)
219 LSA_Q_PRIV_GET_DISPNAME q_u;
220 LSA_R_PRIV_GET_DISPNAME r_u;
221 prs_struct *data = &p->in_data.data;
222 prs_struct *rdata = &p->out_data.rdata;
224 ZERO_STRUCT(q_u);
225 ZERO_STRUCT(r_u);
227 if(!lsa_io_q_priv_get_dispname("", &q_u, data, 0)) {
228 DEBUG(0,("api_lsa_priv_get_dispname: failed to unmarshall LSA_Q_PRIV_GET_DISPNAME.\n"));
229 return False;
232 r_u.status = _lsa_priv_get_dispname(p, &q_u, &r_u);
234 /* store the response in the SMB stream */
235 if(!lsa_io_r_priv_get_dispname("", &r_u, rdata, 0)) {
236 DEBUG(0,("api_lsa_priv_get_dispname: Failed to marshall LSA_R_PRIV_GET_DISPNAME.\n"));
237 return False;
240 return True;
243 /***************************************************************************
244 api_lsa_open_secret.
245 ***************************************************************************/
247 static bool api_lsa_enum_accounts(pipes_struct *p)
249 LSA_Q_ENUM_ACCOUNTS q_u;
250 LSA_R_ENUM_ACCOUNTS r_u;
251 prs_struct *data = &p->in_data.data;
252 prs_struct *rdata = &p->out_data.rdata;
254 ZERO_STRUCT(q_u);
255 ZERO_STRUCT(r_u);
257 if(!lsa_io_q_enum_accounts("", &q_u, data, 0)) {
258 DEBUG(0,("api_lsa_enum_accounts: failed to unmarshall LSA_Q_ENUM_ACCOUNTS.\n"));
259 return False;
262 r_u.status = _lsa_enum_accounts(p, &q_u, &r_u);
264 /* store the response in the SMB stream */
265 if(!lsa_io_r_enum_accounts("", &r_u, rdata, 0)) {
266 DEBUG(0,("api_lsa_enum_accounts: Failed to marshall LSA_R_ENUM_ACCOUNTS.\n"));
267 return False;
270 return True;
273 /***************************************************************************
274 api_lsa_UNK_GET_CONNUSER
275 ***************************************************************************/
277 static bool api_lsa_unk_get_connuser(pipes_struct *p)
279 LSA_Q_UNK_GET_CONNUSER q_u;
280 LSA_R_UNK_GET_CONNUSER r_u;
282 prs_struct *data = &p->in_data.data;
283 prs_struct *rdata = &p->out_data.rdata;
285 ZERO_STRUCT(q_u);
286 ZERO_STRUCT(r_u);
288 if(!lsa_io_q_unk_get_connuser("", &q_u, data, 0)) {
289 DEBUG(0,("api_lsa_unk_get_connuser: failed to unmarshall LSA_Q_UNK_GET_CONNUSER.\n"));
290 return False;
293 r_u.status = _lsa_unk_get_connuser(p, &q_u, &r_u);
295 /* store the response in the SMB stream */
296 if(!lsa_io_r_unk_get_connuser("", &r_u, rdata, 0)) {
297 DEBUG(0,("api_lsa_unk_get_connuser: Failed to marshall LSA_R_UNK_GET_CONNUSER.\n"));
298 return False;
301 return True;
304 /***************************************************************************
305 api_lsa_create_user
306 ***************************************************************************/
308 static bool api_lsa_create_account(pipes_struct *p)
310 return proxy_lsa_call(p, NDR_LSA_CREATEACCOUNT);
313 /***************************************************************************
314 api_lsa_open_user
315 ***************************************************************************/
317 static bool api_lsa_open_account(pipes_struct *p)
319 return proxy_lsa_call(p, NDR_LSA_OPENACCOUNT);
322 /***************************************************************************
323 api_lsa_get_privs
324 ***************************************************************************/
326 static bool api_lsa_enum_privsaccount(pipes_struct *p)
328 LSA_Q_ENUMPRIVSACCOUNT q_u;
329 LSA_R_ENUMPRIVSACCOUNT r_u;
331 prs_struct *data = &p->in_data.data;
332 prs_struct *rdata = &p->out_data.rdata;
334 ZERO_STRUCT(q_u);
335 ZERO_STRUCT(r_u);
337 if(!lsa_io_q_enum_privsaccount("", &q_u, data, 0)) {
338 DEBUG(0,("api_lsa_enum_privsaccount: failed to unmarshall LSA_Q_ENUMPRIVSACCOUNT.\n"));
339 return False;
342 r_u.status = _lsa_enum_privsaccount(p, rdata, &q_u, &r_u);
344 /* store the response in the SMB stream */
345 if(!lsa_io_r_enum_privsaccount("", &r_u, rdata, 0)) {
346 DEBUG(0,("api_lsa_enum_privsaccount: Failed to marshall LSA_R_ENUMPRIVSACCOUNT.\n"));
347 return False;
350 return True;
353 /***************************************************************************
354 api_lsa_getsystemaccount
355 ***************************************************************************/
357 static bool api_lsa_getsystemaccount(pipes_struct *p)
359 return proxy_lsa_call(p, NDR_LSA_GETSYSTEMACCESSACCOUNT);
363 /***************************************************************************
364 api_lsa_setsystemaccount
365 ***************************************************************************/
367 static bool api_lsa_setsystemaccount(pipes_struct *p)
369 return proxy_lsa_call(p, NDR_LSA_SETSYSTEMACCESSACCOUNT);
372 /***************************************************************************
373 api_lsa_addprivs
374 ***************************************************************************/
376 static bool api_lsa_addprivs(pipes_struct *p)
378 LSA_Q_ADDPRIVS q_u;
379 LSA_R_ADDPRIVS r_u;
381 prs_struct *data = &p->in_data.data;
382 prs_struct *rdata = &p->out_data.rdata;
384 ZERO_STRUCT(q_u);
385 ZERO_STRUCT(r_u);
387 if(!lsa_io_q_addprivs("", &q_u, data, 0)) {
388 DEBUG(0,("api_lsa_addprivs: failed to unmarshall LSA_Q_ADDPRIVS.\n"));
389 return False;
392 r_u.status = _lsa_addprivs(p, &q_u, &r_u);
394 /* store the response in the SMB stream */
395 if(!lsa_io_r_addprivs("", &r_u, rdata, 0)) {
396 DEBUG(0,("api_lsa_addprivs: Failed to marshall LSA_R_ADDPRIVS.\n"));
397 return False;
400 return True;
403 /***************************************************************************
404 api_lsa_removeprivs
405 ***************************************************************************/
407 static bool api_lsa_removeprivs(pipes_struct *p)
409 LSA_Q_REMOVEPRIVS q_u;
410 LSA_R_REMOVEPRIVS r_u;
412 prs_struct *data = &p->in_data.data;
413 prs_struct *rdata = &p->out_data.rdata;
415 ZERO_STRUCT(q_u);
416 ZERO_STRUCT(r_u);
418 if(!lsa_io_q_removeprivs("", &q_u, data, 0)) {
419 DEBUG(0,("api_lsa_removeprivs: failed to unmarshall LSA_Q_REMOVEPRIVS.\n"));
420 return False;
423 r_u.status = _lsa_removeprivs(p, &q_u, &r_u);
425 /* store the response in the SMB stream */
426 if(!lsa_io_r_removeprivs("", &r_u, rdata, 0)) {
427 DEBUG(0,("api_lsa_removeprivs: Failed to marshall LSA_R_REMOVEPRIVS.\n"));
428 return False;
431 return True;
434 /***************************************************************************
435 api_lsa_query_secobj
436 ***************************************************************************/
438 static bool api_lsa_query_secobj(pipes_struct *p)
440 return proxy_lsa_call(p, NDR_LSA_QUERYSECURITY);
443 /***************************************************************************
444 api_lsa_add_acct_rights
445 ***************************************************************************/
447 static bool api_lsa_add_acct_rights(pipes_struct *p)
449 LSA_Q_ADD_ACCT_RIGHTS q_u;
450 LSA_R_ADD_ACCT_RIGHTS r_u;
452 prs_struct *data = &p->in_data.data;
453 prs_struct *rdata = &p->out_data.rdata;
455 ZERO_STRUCT(q_u);
456 ZERO_STRUCT(r_u);
458 if(!lsa_io_q_add_acct_rights("", &q_u, data, 0)) {
459 DEBUG(0,("api_lsa_add_acct_rights: failed to unmarshall LSA_Q_ADD_ACCT_RIGHTS.\n"));
460 return False;
463 r_u.status = _lsa_add_acct_rights(p, &q_u, &r_u);
465 /* store the response in the SMB stream */
466 if(!lsa_io_r_add_acct_rights("", &r_u, rdata, 0)) {
467 DEBUG(0,("api_lsa_add_acct_rights: Failed to marshall LSA_R_ADD_ACCT_RIGHTS.\n"));
468 return False;
471 return True;
474 /***************************************************************************
475 api_lsa_remove_acct_rights
476 ***************************************************************************/
478 static bool api_lsa_remove_acct_rights(pipes_struct *p)
480 LSA_Q_REMOVE_ACCT_RIGHTS q_u;
481 LSA_R_REMOVE_ACCT_RIGHTS r_u;
483 prs_struct *data = &p->in_data.data;
484 prs_struct *rdata = &p->out_data.rdata;
486 ZERO_STRUCT(q_u);
487 ZERO_STRUCT(r_u);
489 if(!lsa_io_q_remove_acct_rights("", &q_u, data, 0)) {
490 DEBUG(0,("api_lsa_remove_acct_rights: failed to unmarshall LSA_Q_REMOVE_ACCT_RIGHTS.\n"));
491 return False;
494 r_u.status = _lsa_remove_acct_rights(p, &q_u, &r_u);
496 /* store the response in the SMB stream */
497 if(!lsa_io_r_remove_acct_rights("", &r_u, rdata, 0)) {
498 DEBUG(0,("api_lsa_remove_acct_rights: Failed to marshall LSA_R_REMOVE_ACCT_RIGHTS.\n"));
499 return False;
502 return True;
505 /***************************************************************************
506 api_lsa_enum_acct_rights
507 ***************************************************************************/
509 static bool api_lsa_enum_acct_rights(pipes_struct *p)
511 LSA_Q_ENUM_ACCT_RIGHTS q_u;
512 LSA_R_ENUM_ACCT_RIGHTS r_u;
514 prs_struct *data = &p->in_data.data;
515 prs_struct *rdata = &p->out_data.rdata;
517 ZERO_STRUCT(q_u);
518 ZERO_STRUCT(r_u);
520 if(!lsa_io_q_enum_acct_rights("", &q_u, data, 0)) {
521 DEBUG(0,("api_lsa_enum_acct_rights: failed to unmarshall LSA_Q_ENUM_ACCT_RIGHTS.\n"));
522 return False;
525 r_u.status = _lsa_enum_acct_rights(p, &q_u, &r_u);
527 /* store the response in the SMB stream */
528 if(!lsa_io_r_enum_acct_rights("", &r_u, rdata, 0)) {
529 DEBUG(0,("api_lsa_enum_acct_rights: Failed to marshall LSA_R_ENUM_ACCT_RIGHTS.\n"));
530 return False;
533 return True;
536 /***************************************************************************
537 api_lsa_lookup_priv_value
538 ***************************************************************************/
540 static bool api_lsa_lookup_priv_value(pipes_struct *p)
542 LSA_Q_LOOKUP_PRIV_VALUE q_u;
543 LSA_R_LOOKUP_PRIV_VALUE r_u;
545 prs_struct *data = &p->in_data.data;
546 prs_struct *rdata = &p->out_data.rdata;
548 ZERO_STRUCT(q_u);
549 ZERO_STRUCT(r_u);
551 if(!lsa_io_q_lookup_priv_value("", &q_u, data, 0)) {
552 DEBUG(0,("api_lsa_lookup_priv_value: failed to unmarshall LSA_Q_LOOKUP_PRIV_VALUE .\n"));
553 return False;
556 r_u.status = _lsa_lookup_priv_value(p, &q_u, &r_u);
558 /* store the response in the SMB stream */
559 if(!lsa_io_r_lookup_priv_value("", &r_u, rdata, 0)) {
560 DEBUG(0,("api_lsa_lookup_priv_value: Failed to marshall LSA_R_LOOKUP_PRIV_VALUE.\n"));
561 return False;
564 return True;
567 /***************************************************************************
568 ***************************************************************************/
570 static bool api_lsa_open_trust_dom(pipes_struct *p)
572 return proxy_lsa_call(p, NDR_LSA_OPENTRUSTEDDOMAIN);
575 /***************************************************************************
576 ***************************************************************************/
578 static bool api_lsa_create_trust_dom(pipes_struct *p)
580 return proxy_lsa_call(p, NDR_LSA_CREATETRUSTEDDOMAIN);
583 /***************************************************************************
584 ***************************************************************************/
586 static bool api_lsa_create_secret(pipes_struct *p)
588 return proxy_lsa_call(p, NDR_LSA_CREATESECRET);
591 /***************************************************************************
592 ***************************************************************************/
594 static bool api_lsa_set_secret(pipes_struct *p)
596 return proxy_lsa_call(p, NDR_LSA_SETSECRET);
599 /***************************************************************************
600 ***************************************************************************/
602 static bool api_lsa_delete_object(pipes_struct *p)
604 return proxy_lsa_call(p, NDR_LSA_DELETEOBJECT);
607 /***************************************************************************
608 api_lsa_lookup_sids2
609 ***************************************************************************/
611 static bool api_lsa_lookup_sids2(pipes_struct *p)
613 LSA_Q_LOOKUP_SIDS2 q_u;
614 LSA_R_LOOKUP_SIDS2 r_u;
615 prs_struct *data = &p->in_data.data;
616 prs_struct *rdata = &p->out_data.rdata;
618 ZERO_STRUCT(q_u);
619 ZERO_STRUCT(r_u);
621 /* grab the info class and policy handle */
622 if(!lsa_io_q_lookup_sids2("", &q_u, data, 0)) {
623 DEBUG(0,("api_lsa_lookup_sids2: failed to unmarshall LSA_Q_LOOKUP_SIDS2.\n"));
624 return False;
627 r_u.status = _lsa_lookup_sids2(p, &q_u, &r_u);
629 if(!lsa_io_r_lookup_sids2("", &r_u, rdata, 0)) {
630 DEBUG(0,("api_lsa_lookup_sids2: Failed to marshall LSA_R_LOOKUP_SIDS2.\n"));
631 return False;
634 return True;
637 /***************************************************************************
638 api_lsa_lookup_sids3
639 ***************************************************************************/
641 static bool api_lsa_lookup_sids3(pipes_struct *p)
643 LSA_Q_LOOKUP_SIDS3 q_u;
644 LSA_R_LOOKUP_SIDS3 r_u;
645 prs_struct *data = &p->in_data.data;
646 prs_struct *rdata = &p->out_data.rdata;
648 ZERO_STRUCT(q_u);
649 ZERO_STRUCT(r_u);
651 /* grab the info class and policy handle */
652 if(!lsa_io_q_lookup_sids3("", &q_u, data, 0)) {
653 DEBUG(0,("api_lsa_lookup_sids3: failed to unmarshall LSA_Q_LOOKUP_SIDS3.\n"));
654 return False;
657 r_u.status = _lsa_lookup_sids3(p, &q_u, &r_u);
659 if(!lsa_io_r_lookup_sids3("", &r_u, rdata, 0)) {
660 DEBUG(0,("api_lsa_lookup_sids3: Failed to marshall LSA_R_LOOKUP_SIDS3.\n"));
661 return False;
664 return True;
667 /***************************************************************************
668 api_lsa_lookup_names2
669 ***************************************************************************/
671 static bool api_lsa_lookup_names2(pipes_struct *p)
673 LSA_Q_LOOKUP_NAMES2 q_u;
674 LSA_R_LOOKUP_NAMES2 r_u;
675 prs_struct *data = &p->in_data.data;
676 prs_struct *rdata = &p->out_data.rdata;
678 ZERO_STRUCT(q_u);
679 ZERO_STRUCT(r_u);
681 /* grab the info class and policy handle */
682 if(!lsa_io_q_lookup_names2("", &q_u, data, 0)) {
683 DEBUG(0,("api_lsa_lookup_names2: failed to unmarshall LSA_Q_LOOKUP_NAMES2.\n"));
684 return False;
687 r_u.status = _lsa_lookup_names2(p, &q_u, &r_u);
689 /* store the response in the SMB stream */
690 if(!lsa_io_r_lookup_names2("", &r_u, rdata, 0)) {
691 DEBUG(0,("api_lsa_lookup_names2: Failed to marshall LSA_R_LOOKUP_NAMES2.\n"));
692 return False;
695 return True;
698 /***************************************************************************
699 api_lsa_lookup_names3
700 ***************************************************************************/
702 static bool api_lsa_lookup_names3(pipes_struct *p)
704 LSA_Q_LOOKUP_NAMES3 q_u;
705 LSA_R_LOOKUP_NAMES3 r_u;
706 prs_struct *data = &p->in_data.data;
707 prs_struct *rdata = &p->out_data.rdata;
709 ZERO_STRUCT(q_u);
710 ZERO_STRUCT(r_u);
712 /* grab the info class and policy handle */
713 if(!lsa_io_q_lookup_names3("", &q_u, data, 0)) {
714 DEBUG(0,("api_lsa_lookup_names3: failed to unmarshall LSA_Q_LOOKUP_NAMES3.\n"));
715 return False;
718 r_u.status = _lsa_lookup_names3(p, &q_u, &r_u);
720 /* store the response in the SMB stream */
721 if(!lsa_io_r_lookup_names3("", &r_u, rdata, 0)) {
722 DEBUG(0,("api_lsa_lookup_names3: Failed to marshall LSA_R_LOOKUP_NAMES3.\n"));
723 return False;
726 return True;
729 /***************************************************************************
730 api_lsa_lookup_names4
731 ***************************************************************************/
733 static bool api_lsa_lookup_names4(pipes_struct *p)
735 LSA_Q_LOOKUP_NAMES4 q_u;
736 LSA_R_LOOKUP_NAMES4 r_u;
737 prs_struct *data = &p->in_data.data;
738 prs_struct *rdata = &p->out_data.rdata;
740 ZERO_STRUCT(q_u);
741 ZERO_STRUCT(r_u);
743 /* grab the info class and policy handle */
744 if(!lsa_io_q_lookup_names4("", &q_u, data, 0)) {
745 DEBUG(0,("api_lsa_lookup_names4: failed to unmarshall LSA_Q_LOOKUP_NAMES4.\n"));
746 return False;
749 r_u.status = _lsa_lookup_names4(p, &q_u, &r_u);
751 /* store the response in the SMB stream */
752 if(!lsa_io_r_lookup_names4("", &r_u, rdata, 0)) {
753 DEBUG(0,("api_lsa_lookup_names4: Failed to marshall LSA_R_LOOKUP_NAMES4.\n"));
754 return False;
757 return True;
760 #if 0 /* AD DC work in ongoing in Samba 4 */
762 /***************************************************************************
763 api_lsa_query_info2
764 ***************************************************************************/
766 static bool api_lsa_query_info2(pipes_struct *p)
768 LSA_Q_QUERY_INFO2 q_u;
769 LSA_R_QUERY_INFO2 r_u;
771 prs_struct *data = &p->in_data.data;
772 prs_struct *rdata = &p->out_data.rdata;
774 ZERO_STRUCT(q_u);
775 ZERO_STRUCT(r_u);
777 if(!lsa_io_q_query_info2("", &q_u, data, 0)) {
778 DEBUG(0,("api_lsa_query_info2: failed to unmarshall LSA_Q_QUERY_INFO2.\n"));
779 return False;
782 r_u.status = _lsa_query_info2(p, &q_u, &r_u);
784 if (!lsa_io_r_query_info2("", &r_u, rdata, 0)) {
785 DEBUG(0,("api_lsa_query_info2: failed to marshall LSA_R_QUERY_INFO2.\n"));
786 return False;
789 return True;
791 #endif /* AD DC work in ongoing in Samba 4 */
793 /***************************************************************************
794 \PIPE\ntlsa commands
795 ***************************************************************************/
797 static struct api_struct api_lsa_cmds[] =
799 { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 },
800 { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy },
801 { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info },
802 { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom },
803 { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close },
804 { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret },
805 { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids },
806 { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names },
807 { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs },
808 { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname},
809 { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts },
810 { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser },
811 { "LSA_CREATEACCOUNT" , LSA_CREATEACCOUNT , api_lsa_create_account },
812 { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account },
813 { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount},
814 { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount },
815 { "LSA_SETSYSTEMACCOUNT", LSA_SETSYSTEMACCOUNT, api_lsa_setsystemaccount },
816 { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs },
817 { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs },
818 { "LSA_ADDACCTRIGHTS" , LSA_ADDACCTRIGHTS , api_lsa_add_acct_rights },
819 { "LSA_REMOVEACCTRIGHTS", LSA_REMOVEACCTRIGHTS, api_lsa_remove_acct_rights },
820 { "LSA_ENUMACCTRIGHTS" , LSA_ENUMACCTRIGHTS , api_lsa_enum_acct_rights },
821 { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj },
822 { "LSA_LOOKUPPRIVVALUE" , LSA_LOOKUPPRIVVALUE , api_lsa_lookup_priv_value },
823 { "LSA_OPENTRUSTDOM" , LSA_OPENTRUSTDOM , api_lsa_open_trust_dom },
824 { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret },
825 { "LSA_CREATETRUSTDOM" , LSA_CREATETRUSTDOM , api_lsa_create_trust_dom },
826 { "LSA_CREATSECRET" , LSA_CREATESECRET , api_lsa_create_secret },
827 { "LSA_SETSECRET" , LSA_SETSECRET , api_lsa_set_secret },
828 { "LSA_DELETEOBJECT" , LSA_DELETEOBJECT , api_lsa_delete_object },
829 { "LSA_LOOKUPSIDS2" , LSA_LOOKUPSIDS2 , api_lsa_lookup_sids2 },
830 { "LSA_LOOKUPNAMES2" , LSA_LOOKUPNAMES2 , api_lsa_lookup_names2 },
831 { "LSA_LOOKUPNAMES3" , LSA_LOOKUPNAMES3 , api_lsa_lookup_names3 },
832 { "LSA_LOOKUPSIDS3" , LSA_LOOKUPSIDS3 , api_lsa_lookup_sids3 },
833 { "LSA_LOOKUPNAMES4" , LSA_LOOKUPNAMES4 , api_lsa_lookup_names4 }
834 #if 0 /* AD DC work in ongoing in Samba 4 */
835 /* be careful of the adding of new RPC's. See commentrs below about
836 ADS DC capabilities */
837 { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 }
838 #endif /* AD DC work in ongoing in Samba 4 */
841 static int count_fns(void)
843 int funcs = sizeof(api_lsa_cmds) / sizeof(struct api_struct);
845 #if 0 /* AD DC work is on going in Samba 4 */
847 * NOTE: Certain calls can not be enabled if we aren't an ADS DC. Make sure
848 * these calls are always last and that you decrement by the amount of calls
849 * to disable.
851 if (!(SEC_ADS == lp_security() && ROLE_DOMAIN_PDC == lp_server_role())) {
852 funcs -= 1;
854 #endif /* AD DC work in ongoing in Samba 4 */
856 return funcs;
859 void lsa_get_pipe_fns( struct api_struct **fns, int *n_fns )
861 *fns = api_lsa_cmds;
862 *n_fns = count_fns();
866 NTSTATUS rpc_lsa_init(void)
868 int funcs = count_fns();
870 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsarpc", "lsass", api_lsa_cmds,
871 funcs);