* fix to display correct form information in REG_BINARY information
[Samba.git] / source / rpc_server / srv_lsa.c
blobe5a4d3b46d5937b760ea04f253ab6dab691d6264
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.
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. */
26 #include "includes.h"
28 #undef DBGC_CLASS
29 #define DBGC_CLASS DBGC_RPC_SRV
31 /***************************************************************************
32 api_lsa_open_policy2
33 ***************************************************************************/
35 static BOOL api_lsa_open_policy2(pipes_struct *p)
37 LSA_Q_OPEN_POL2 q_u;
38 LSA_R_OPEN_POL2 r_u;
39 prs_struct *data = &p->in_data.data;
40 prs_struct *rdata = &p->out_data.rdata;
42 ZERO_STRUCT(q_u);
43 ZERO_STRUCT(r_u);
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"));
48 return False;
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"));
56 return False;
59 return True;
62 /***************************************************************************
63 api_lsa_open_policy
64 ***************************************************************************/
66 static BOOL api_lsa_open_policy(pipes_struct *p)
68 LSA_Q_OPEN_POL q_u;
69 LSA_R_OPEN_POL r_u;
70 prs_struct *data = &p->in_data.data;
71 prs_struct *rdata = &p->out_data.rdata;
73 ZERO_STRUCT(q_u);
74 ZERO_STRUCT(r_u);
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"));
79 return False;
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"));
87 return False;
90 return True;
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;
104 ZERO_STRUCT(q_u);
105 ZERO_STRUCT(r_u);
107 /* grab the enum trust domain context etc. */
108 if(!lsa_io_q_enum_trust_dom("", &q_u, data, 0))
109 return False;
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))
116 return False;
118 return True;
121 /***************************************************************************
122 api_lsa_query_info
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;
132 ZERO_STRUCT(q_u);
133 ZERO_STRUCT(r_u);
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"));
138 return False;
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"));
146 return False;
149 return True;
152 /***************************************************************************
153 api_lsa_lookup_sids
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;
163 ZERO_STRUCT(q_u);
164 ZERO_STRUCT(r_u);
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"));
169 return False;
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"));
176 return False;
179 return True;
182 /***************************************************************************
183 api_lsa_lookup_names
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;
193 ZERO_STRUCT(q_u);
194 ZERO_STRUCT(r_u);
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"));
199 return False;
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"));
207 return False;
210 return True;
213 /***************************************************************************
214 api_lsa_close.
215 ***************************************************************************/
217 static BOOL api_lsa_close(pipes_struct *p)
219 LSA_Q_CLOSE q_u;
220 LSA_R_CLOSE 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_close("", &q_u, data, 0)) {
228 DEBUG(0,("api_lsa_close: lsa_io_q_close failed.\n"));
229 return False;
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"));
237 return False;
240 return True;
243 /***************************************************************************
244 api_lsa_open_secret.
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;
254 ZERO_STRUCT(q_u);
255 ZERO_STRUCT(r_u);
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"));
259 return False;
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"));
267 return False;
270 return True;
273 /***************************************************************************
274 api_lsa_open_secret.
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;
284 ZERO_STRUCT(q_u);
285 ZERO_STRUCT(r_u);
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"));
289 return False;
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"));
297 return False;
300 return True;
303 /***************************************************************************
304 api_lsa_open_secret.
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;
314 ZERO_STRUCT(q_u);
315 ZERO_STRUCT(r_u);
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"));
319 return False;
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"));
327 return False;
330 return True;
333 /***************************************************************************
334 api_lsa_open_secret.
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;
344 ZERO_STRUCT(q_u);
345 ZERO_STRUCT(r_u);
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"));
349 return False;
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"));
357 return False;
360 return True;
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;
375 ZERO_STRUCT(q_u);
376 ZERO_STRUCT(r_u);
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"));
380 return False;
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"));
388 return False;
391 return True;
394 /***************************************************************************
395 api_lsa_open_user
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;
406 ZERO_STRUCT(q_u);
407 ZERO_STRUCT(r_u);
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"));
411 return False;
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"));
419 return False;
422 return True;
425 /***************************************************************************
426 api_lsa_get_privs
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;
437 ZERO_STRUCT(q_u);
438 ZERO_STRUCT(r_u);
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"));
442 return False;
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"));
450 return False;
453 return True;
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;
468 ZERO_STRUCT(q_u);
469 ZERO_STRUCT(r_u);
471 if(!lsa_io_q_getsystemaccount("", &q_u, data, 0)) {
472 DEBUG(0,("api_lsa_getsystemaccount: failed to unmarshall LSA_Q_GETSYSTEMACCOUNT.\n"));
473 return False;
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"));
481 return False;
484 return True;
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;
500 ZERO_STRUCT(q_u);
501 ZERO_STRUCT(r_u);
503 if(!lsa_io_q_setsystemaccount("", &q_u, data, 0)) {
504 DEBUG(0,("api_lsa_setsystemaccount: failed to unmarshall LSA_Q_SETSYSTEMACCOUNT.\n"));
505 return False;
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"));
513 return False;
516 return True;
519 /***************************************************************************
520 api_lsa_addprivs
521 ***************************************************************************/
523 static BOOL api_lsa_addprivs(pipes_struct *p)
525 LSA_Q_ADDPRIVS q_u;
526 LSA_R_ADDPRIVS r_u;
528 prs_struct *data = &p->in_data.data;
529 prs_struct *rdata = &p->out_data.rdata;
531 ZERO_STRUCT(q_u);
532 ZERO_STRUCT(r_u);
534 if(!lsa_io_q_addprivs("", &q_u, data, 0)) {
535 DEBUG(0,("api_lsa_addprivs: failed to unmarshall LSA_Q_ADDPRIVS.\n"));
536 return False;
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"));
544 return False;
547 return True;
550 /***************************************************************************
551 api_lsa_removeprivs
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;
562 ZERO_STRUCT(q_u);
563 ZERO_STRUCT(r_u);
565 if(!lsa_io_q_removeprivs("", &q_u, data, 0)) {
566 DEBUG(0,("api_lsa_removeprivs: failed to unmarshall LSA_Q_REMOVEPRIVS.\n"));
567 return False;
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"));
575 return False;
578 return True;
581 /***************************************************************************
582 api_lsa_query_secobj
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;
593 ZERO_STRUCT(q_u);
594 ZERO_STRUCT(r_u);
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"));
598 return False;
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"));
606 return False;
609 return True;
612 /***************************************************************************
613 \PIPE\ntlsa commands
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 },
637 { NULL , 0 , NULL }
640 /***************************************************************************
641 api_ntLsarpcTNP
642 ***************************************************************************/
643 BOOL api_ntlsa_rpc(pipes_struct *p)
645 return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds);