r5739: sync for 3.0.12rc1 (current with SAMBA_3_0 r5738)
[Samba.git] / source / rpc_parse / parse_lsa.c
blobbbff258722ae6cdb93e35d52e5a95878fe63be39
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) Andrew Bartlett 2002,
8 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
9 *
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 #include "includes.h"
27 #undef DBGC_CLASS
28 #define DBGC_CLASS DBGC_RPC_PARSE
30 static BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn, prs_struct *ps, int depth);
32 /*******************************************************************
33 Inits a LSA_TRANS_NAME structure.
34 ********************************************************************/
36 void init_lsa_trans_name(LSA_TRANS_NAME *trn, UNISTR2 *uni_name,
37 uint16 sid_name_use, const char *name, uint32 idx)
39 trn->sid_name_use = sid_name_use;
40 init_unistr2(uni_name, name, UNI_FLAGS_NONE);
41 init_uni_hdr(&trn->hdr_name, uni_name);
42 trn->domain_idx = idx;
45 /*******************************************************************
46 Reads or writes a LSA_TRANS_NAME structure.
47 ********************************************************************/
49 static BOOL lsa_io_trans_name(const char *desc, LSA_TRANS_NAME *trn, prs_struct *ps,
50 int depth)
52 prs_debug(ps, depth, desc, "lsa_io_trans_name");
53 depth++;
55 if(!prs_align(ps))
56 return False;
58 if(!prs_uint16("sid_name_use", ps, depth, &trn->sid_name_use))
59 return False;
60 if(!prs_align(ps))
61 return False;
63 if(!smb_io_unihdr ("hdr_name", &trn->hdr_name, ps, depth))
64 return False;
65 if(!prs_uint32("domain_idx ", ps, depth, &trn->domain_idx))
66 return False;
68 return True;
71 /*******************************************************************
72 Reads or writes a DOM_R_REF structure.
73 ********************************************************************/
75 static BOOL lsa_io_dom_r_ref(const char *desc, DOM_R_REF *r_r, prs_struct *ps,
76 int depth)
78 unsigned int i;
80 prs_debug(ps, depth, desc, "lsa_io_dom_r_ref");
81 depth++;
83 if(!prs_align(ps))
84 return False;
86 if(!prs_uint32("num_ref_doms_1", ps, depth, &r_r->num_ref_doms_1)) /* num referenced domains? */
87 return False;
88 if(!prs_uint32("ptr_ref_dom ", ps, depth, &r_r->ptr_ref_dom)) /* undocumented buffer pointer. */
89 return False;
90 if(!prs_uint32("max_entries ", ps, depth, &r_r->max_entries)) /* 32 - max number of entries */
91 return False;
93 SMB_ASSERT_ARRAY(r_r->hdr_ref_dom, r_r->num_ref_doms_1);
95 if (r_r->ptr_ref_dom != 0) {
97 if(!prs_uint32("num_ref_doms_2", ps, depth, &r_r->num_ref_doms_2)) /* 4 - num referenced domains? */
98 return False;
100 SMB_ASSERT_ARRAY(r_r->ref_dom, r_r->num_ref_doms_2);
102 for (i = 0; i < r_r->num_ref_doms_1; i++) {
103 fstring t;
105 slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
106 if(!smb_io_unihdr(t, &r_r->hdr_ref_dom[i].hdr_dom_name, ps, depth))
107 return False;
109 slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i);
110 if(!prs_uint32(t, ps, depth, &r_r->hdr_ref_dom[i].ptr_dom_sid))
111 return False;
114 for (i = 0; i < r_r->num_ref_doms_2; i++) {
115 fstring t;
117 if (r_r->hdr_ref_dom[i].hdr_dom_name.buffer != 0) {
118 slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
119 if(!smb_io_unistr2(t, &r_r->ref_dom[i].uni_dom_name, True, ps, depth)) /* domain name unicode string */
120 return False;
121 if(!prs_align(ps))
122 return False;
125 if (r_r->hdr_ref_dom[i].ptr_dom_sid != 0) {
126 slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i);
127 if(!smb_io_dom_sid2(t, &r_r->ref_dom[i].ref_dom, ps, depth)) /* referenced domain SIDs */
128 return False;
133 return True;
136 /*******************************************************************
137 Inits an LSA_SEC_QOS structure.
138 ********************************************************************/
140 void init_lsa_sec_qos(LSA_SEC_QOS *qos, uint16 imp_lev, uint8 ctxt, uint8 eff)
142 DEBUG(5, ("init_lsa_sec_qos\n"));
144 qos->len = 0x0c; /* length of quality of service block, in bytes */
145 qos->sec_imp_level = imp_lev;
146 qos->sec_ctxt_mode = ctxt;
147 qos->effective_only = eff;
150 /*******************************************************************
151 Reads or writes an LSA_SEC_QOS structure.
152 ********************************************************************/
154 static BOOL lsa_io_sec_qos(const char *desc, LSA_SEC_QOS *qos, prs_struct *ps,
155 int depth)
157 uint32 start;
159 prs_debug(ps, depth, desc, "lsa_io_obj_qos");
160 depth++;
162 if(!prs_align(ps))
163 return False;
165 start = prs_offset(ps);
167 /* these pointers had _better_ be zero, because we don't know
168 what they point to!
170 if(!prs_uint32("len ", ps, depth, &qos->len)) /* 0x18 - length (in bytes) inc. the length field. */
171 return False;
172 if(!prs_uint16("sec_imp_level ", ps, depth, &qos->sec_imp_level ))
173 return False;
174 if(!prs_uint8 ("sec_ctxt_mode ", ps, depth, &qos->sec_ctxt_mode ))
175 return False;
176 if(!prs_uint8 ("effective_only", ps, depth, &qos->effective_only))
177 return False;
179 if (qos->len != prs_offset(ps) - start) {
180 DEBUG(3,("lsa_io_sec_qos: length %x does not match size %x\n",
181 qos->len, prs_offset(ps) - start));
184 return True;
187 /*******************************************************************
188 Inits an LSA_OBJ_ATTR structure.
189 ********************************************************************/
191 static void init_lsa_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, LSA_SEC_QOS *qos)
193 DEBUG(5, ("init_lsa_obj_attr\n"));
195 attr->len = 0x18; /* length of object attribute block, in bytes */
196 attr->ptr_root_dir = 0;
197 attr->ptr_obj_name = 0;
198 attr->attributes = attributes;
199 attr->ptr_sec_desc = 0;
201 if (qos != NULL) {
202 attr->ptr_sec_qos = 1;
203 attr->sec_qos = qos;
204 } else {
205 attr->ptr_sec_qos = 0;
206 attr->sec_qos = NULL;
210 /*******************************************************************
211 Reads or writes an LSA_OBJ_ATTR structure.
212 ********************************************************************/
214 static BOOL lsa_io_obj_attr(const char *desc, LSA_OBJ_ATTR *attr, prs_struct *ps,
215 int depth)
217 prs_debug(ps, depth, desc, "lsa_io_obj_attr");
218 depth++;
220 if(!prs_align(ps))
221 return False;
223 /* these pointers had _better_ be zero, because we don't know
224 what they point to!
226 if(!prs_uint32("len ", ps, depth, &attr->len)) /* 0x18 - length (in bytes) inc. the length field. */
227 return False;
228 if(!prs_uint32("ptr_root_dir", ps, depth, &attr->ptr_root_dir)) /* 0 - root directory (pointer) */
229 return False;
230 if(!prs_uint32("ptr_obj_name", ps, depth, &attr->ptr_obj_name)) /* 0 - object name (pointer) */
231 return False;
232 if(!prs_uint32("attributes ", ps, depth, &attr->attributes)) /* 0 - attributes (undocumented) */
233 return False;
234 if(!prs_uint32("ptr_sec_desc", ps, depth, &attr->ptr_sec_desc)) /* 0 - security descriptior (pointer) */
235 return False;
236 if(!prs_uint32("ptr_sec_qos ", ps, depth, &attr->ptr_sec_qos )) /* security quality of service (pointer) */
237 return False;
239 if (attr->ptr_sec_qos != 0) {
240 if (UNMARSHALLING(ps))
241 if (!(attr->sec_qos = PRS_ALLOC_MEM(ps,LSA_SEC_QOS,1)))
242 return False;
244 if(!lsa_io_sec_qos("sec_qos", attr->sec_qos, ps, depth))
245 return False;
248 return True;
252 /*******************************************************************
253 Inits an LSA_Q_OPEN_POL structure.
254 ********************************************************************/
256 void init_q_open_pol(LSA_Q_OPEN_POL *r_q, uint16 system_name,
257 uint32 attributes, uint32 desired_access,
258 LSA_SEC_QOS *qos)
260 DEBUG(5, ("init_open_pol: attr:%d da:%d\n", attributes,
261 desired_access));
263 r_q->ptr = 1; /* undocumented pointer */
265 r_q->des_access = desired_access;
267 r_q->system_name = system_name;
268 init_lsa_obj_attr(&r_q->attr, attributes, qos);
271 /*******************************************************************
272 Reads or writes an LSA_Q_OPEN_POL structure.
273 ********************************************************************/
275 BOOL lsa_io_q_open_pol(const char *desc, LSA_Q_OPEN_POL *r_q, prs_struct *ps,
276 int depth)
278 prs_debug(ps, depth, desc, "lsa_io_q_open_pol");
279 depth++;
281 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
282 return False;
283 if(!prs_uint16("system_name", ps, depth, &r_q->system_name))
284 return False;
285 if(!prs_align( ps ))
286 return False;
288 if(!lsa_io_obj_attr("", &r_q->attr, ps, depth))
289 return False;
291 if(!prs_uint32("des_access", ps, depth, &r_q->des_access))
292 return False;
294 return True;
297 /*******************************************************************
298 Reads or writes an LSA_R_OPEN_POL structure.
299 ********************************************************************/
301 BOOL lsa_io_r_open_pol(const char *desc, LSA_R_OPEN_POL *r_p, prs_struct *ps,
302 int depth)
304 prs_debug(ps, depth, desc, "lsa_io_r_open_pol");
305 depth++;
307 if(!smb_io_pol_hnd("", &r_p->pol, ps, depth))
308 return False;
310 if(!prs_ntstatus("status", ps, depth, &r_p->status))
311 return False;
313 return True;
316 /*******************************************************************
317 Inits an LSA_Q_OPEN_POL2 structure.
318 ********************************************************************/
320 void init_q_open_pol2(LSA_Q_OPEN_POL2 *r_q, const char *server_name,
321 uint32 attributes, uint32 desired_access,
322 LSA_SEC_QOS *qos)
324 DEBUG(5, ("init_q_open_pol2: attr:%d da:%d\n", attributes,
325 desired_access));
327 r_q->ptr = 1; /* undocumented pointer */
329 r_q->des_access = desired_access;
331 init_unistr2(&r_q->uni_server_name, server_name, UNI_STR_TERMINATE);
333 init_lsa_obj_attr(&r_q->attr, attributes, qos);
336 /*******************************************************************
337 Reads or writes an LSA_Q_OPEN_POL2 structure.
338 ********************************************************************/
340 BOOL lsa_io_q_open_pol2(const char *desc, LSA_Q_OPEN_POL2 *r_q, prs_struct *ps,
341 int depth)
343 prs_debug(ps, depth, desc, "lsa_io_q_open_pol2");
344 depth++;
346 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
347 return False;
349 if(!smb_io_unistr2 ("", &r_q->uni_server_name, r_q->ptr, ps, depth))
350 return False;
351 if(!lsa_io_obj_attr("", &r_q->attr, ps, depth))
352 return False;
354 if(!prs_uint32("des_access", ps, depth, &r_q->des_access))
355 return False;
357 return True;
360 /*******************************************************************
361 Reads or writes an LSA_R_OPEN_POL2 structure.
362 ********************************************************************/
364 BOOL lsa_io_r_open_pol2(const char *desc, LSA_R_OPEN_POL2 *r_p, prs_struct *ps,
365 int depth)
367 prs_debug(ps, depth, desc, "lsa_io_r_open_pol2");
368 depth++;
370 if(!smb_io_pol_hnd("", &r_p->pol, ps, depth))
371 return False;
373 if(!prs_ntstatus("status", ps, depth, &r_p->status))
374 return False;
376 return True;
379 /*******************************************************************
380 makes an LSA_Q_QUERY_SEC_OBJ structure.
381 ********************************************************************/
383 void init_q_query_sec_obj(LSA_Q_QUERY_SEC_OBJ *q_q, const POLICY_HND *hnd,
384 uint32 sec_info)
386 DEBUG(5, ("init_q_query_sec_obj\n"));
388 q_q->pol = *hnd;
389 q_q->sec_info = sec_info;
391 return;
394 /*******************************************************************
395 Reads or writes an LSA_Q_QUERY_SEC_OBJ structure.
396 ********************************************************************/
398 BOOL lsa_io_q_query_sec_obj(const char *desc, LSA_Q_QUERY_SEC_OBJ *q_q,
399 prs_struct *ps, int depth)
401 prs_debug(ps, depth, desc, "lsa_io_q_query_sec_obj");
402 depth++;
404 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
405 return False;
407 if (!prs_uint32("sec_info", ps, depth, &q_q->sec_info))
408 return False;
410 return True;
413 /*******************************************************************
414 Reads or writes a LSA_R_QUERY_SEC_OBJ structure.
415 ********************************************************************/
417 BOOL lsa_io_r_query_sec_obj(const char *desc, LSA_R_QUERY_SEC_OBJ *r_u,
418 prs_struct *ps, int depth)
420 prs_debug(ps, depth, desc, "lsa_io_r_query_sec_obj");
421 depth++;
423 if (!prs_align(ps))
424 return False;
426 if (!prs_uint32("ptr", ps, depth, &r_u->ptr))
427 return False;
429 if (r_u->ptr != 0) {
430 if (!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
431 return False;
434 if (!prs_ntstatus("status", ps, depth, &r_u->status))
435 return False;
437 return True;
440 /*******************************************************************
441 Inits an LSA_Q_QUERY_INFO structure.
442 ********************************************************************/
444 void init_q_query(LSA_Q_QUERY_INFO *q_q, POLICY_HND *hnd, uint16 info_class)
446 DEBUG(5, ("init_q_query\n"));
448 memcpy(&q_q->pol, hnd, sizeof(q_q->pol));
450 q_q->info_class = info_class;
453 /*******************************************************************
454 Reads or writes an LSA_Q_QUERY_INFO structure.
455 ********************************************************************/
457 BOOL lsa_io_q_query(const char *desc, LSA_Q_QUERY_INFO *q_q, prs_struct *ps,
458 int depth)
460 prs_debug(ps, depth, desc, "lsa_io_q_query");
461 depth++;
463 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
464 return False;
466 if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
467 return False;
469 return True;
472 /*******************************************************************
473 makes an LSA_Q_ENUM_TRUST_DOM structure.
474 ********************************************************************/
475 BOOL init_q_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM * q_e, POLICY_HND *pol,
476 uint32 enum_context, uint32 preferred_len)
478 DEBUG(5, ("init_q_enum_trust_dom\n"));
480 q_e->pol = *pol;
481 q_e->enum_context = enum_context;
482 q_e->preferred_len = preferred_len;
484 return True;
487 /*******************************************************************
488 Reads or writes an LSA_Q_ENUM_TRUST_DOM structure.
489 ********************************************************************/
491 BOOL lsa_io_q_enum_trust_dom(const char *desc, LSA_Q_ENUM_TRUST_DOM *q_e,
492 prs_struct *ps, int depth)
494 prs_debug(ps, depth, desc, "lsa_io_q_enum_trust_dom");
495 depth++;
497 if(!smb_io_pol_hnd("", &q_e->pol, ps, depth))
498 return False;
500 if(!prs_uint32("enum_context ", ps, depth, &q_e->enum_context))
501 return False;
502 if(!prs_uint32("preferred_len", ps, depth, &q_e->preferred_len))
503 return False;
505 return True;
508 /*******************************************************************
509 Inits an LSA_R_ENUM_TRUST_DOM structure.
510 ********************************************************************/
512 void init_r_enum_trust_dom(TALLOC_CTX *ctx, LSA_R_ENUM_TRUST_DOM *r_e, uint32 enum_context,
513 uint32 req_num_domains, uint32 num_domains, TRUSTDOM **td)
515 unsigned int i;
517 DEBUG(5, ("init_r_enum_trust_dom\n"));
519 r_e->enum_context = enum_context;
520 r_e->num_domains = num_domains;
521 r_e->ptr_enum_domains = 0;
522 r_e->num_domains2 = num_domains;
524 if (num_domains != 0) {
527 * allocating empty arrays of unicode headers, strings
528 * and sids of enumerated trusted domains
530 if (!(r_e->hdr_domain_name = TALLOC_ARRAY(ctx,UNIHDR2,num_domains))) {
531 r_e->status = NT_STATUS_NO_MEMORY;
532 return;
535 if (!(r_e->uni_domain_name = TALLOC_ARRAY(ctx,UNISTR2,num_domains))) {
536 r_e->status = NT_STATUS_NO_MEMORY;
537 return;
540 if (!(r_e->domain_sid = TALLOC_ARRAY(ctx,DOM_SID2,num_domains))) {
541 r_e->status = NT_STATUS_NO_MEMORY;
542 return;
545 for (i = 0; i < num_domains; i++) {
547 /* don't know what actually is this for */
548 r_e->ptr_enum_domains = 1;
550 init_dom_sid2(&r_e->domain_sid[i], &(td[i])->sid);
552 init_unistr2_w(ctx, &r_e->uni_domain_name[i], (td[i])->name);
553 init_uni_hdr2(&r_e->hdr_domain_name[i], &r_e->uni_domain_name[i]);
560 /*******************************************************************
561 Reads or writes an LSA_R_ENUM_TRUST_DOM structure.
562 ********************************************************************/
564 BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *r_e,
565 prs_struct *ps, int depth)
567 prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom");
568 depth++;
570 if(!prs_uint32("enum_context ", ps, depth, &r_e->enum_context))
571 return False;
572 if(!prs_uint32("num_domains ", ps, depth, &r_e->num_domains))
573 return False;
574 if(!prs_uint32("ptr_enum_domains", ps, depth, &r_e->ptr_enum_domains))
575 return False;
577 if (r_e->ptr_enum_domains) {
578 int i, num_domains;
580 if(!prs_uint32("num_domains2", ps, depth, &r_e->num_domains2))
581 return False;
583 num_domains = r_e->num_domains2;
585 if (UNMARSHALLING(ps)) {
586 if (!(r_e->hdr_domain_name = PRS_ALLOC_MEM(ps,UNIHDR2,num_domains)))
587 return False;
589 if (!(r_e->uni_domain_name = PRS_ALLOC_MEM(ps,UNISTR2,num_domains)))
590 return False;
592 if (!(r_e->domain_sid = PRS_ALLOC_MEM(ps,DOM_SID2,num_domains)))
593 return False;
596 for (i = 0; i < num_domains; i++) {
597 if(!smb_io_unihdr2 ("", &r_e->hdr_domain_name[i], ps,
598 depth))
599 return False;
602 for (i = 0; i < num_domains; i++) {
603 if(!smb_io_unistr2 ("", &r_e->uni_domain_name[i],
604 r_e->hdr_domain_name[i].buffer,
605 ps, depth))
606 return False;
607 if(!smb_io_dom_sid2("", &r_e->domain_sid[i], ps,
608 depth))
609 return False;
613 if(!prs_ntstatus("status", ps, depth, &r_e->status))
614 return False;
616 return True;
619 /*******************************************************************
620 reads or writes a dom query structure.
621 ********************************************************************/
623 static BOOL lsa_io_dom_query(const char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth)
625 if (d_q == NULL)
626 return False;
628 prs_debug(ps, depth, desc, "lsa_io_dom_query");
629 depth++;
631 if(!prs_align(ps))
632 return False;
634 if(!prs_uint16("uni_dom_max_len", ps, depth, &d_q->uni_dom_max_len)) /* domain name string length * 2 */
635 return False;
636 if(!prs_uint16("uni_dom_str_len", ps, depth, &d_q->uni_dom_str_len)) /* domain name string length * 2 */
637 return False;
639 if(!prs_uint32("buffer_dom_name", ps, depth, &d_q->buffer_dom_name)) /* undocumented domain name string buffer pointer */
640 return False;
641 if(!prs_uint32("buffer_dom_sid ", ps, depth, &d_q->buffer_dom_sid)) /* undocumented domain SID string buffer pointer */
642 return False;
644 if(!smb_io_unistr2("unistr2", &d_q->uni_domain_name, d_q->buffer_dom_name, ps, depth)) /* domain name (unicode string) */
645 return False;
647 if(!prs_align(ps))
648 return False;
650 if (d_q->buffer_dom_sid != 0) {
651 if(!smb_io_dom_sid2("", &d_q->dom_sid, ps, depth)) /* domain SID */
652 return False;
653 } else {
654 memset((char *)&d_q->dom_sid, '\0', sizeof(d_q->dom_sid));
657 return True;
660 /*******************************************************************
661 reads or writes a structure.
662 ********************************************************************/
664 static BOOL lsa_io_dom_query_2(const char *desc, DOM_QUERY_2 *d_q, prs_struct *ps, int depth)
666 uint32 ptr = 1;
668 if (d_q == NULL)
669 return False;
671 prs_debug(ps, depth, desc, "lsa_io_dom_query_2");
672 depth++;
674 if (!prs_align(ps))
675 return False;
677 if (!prs_uint32("auditing_enabled", ps, depth, &d_q->auditing_enabled))
678 return False;
679 if (!prs_uint32("ptr ", ps, depth, &ptr))
680 return False;
681 if (!prs_uint32("count1", ps, depth, &d_q->count1))
682 return False;
683 if (!prs_uint32("count2", ps, depth, &d_q->count2))
684 return False;
686 if (UNMARSHALLING(ps)) {
687 d_q->auditsettings = TALLOC_ZERO_ARRAY(ps->mem_ctx, uint32, d_q->count2);
690 if (d_q->auditsettings == NULL) {
691 DEBUG(1, ("lsa_io_dom_query_2: NULL auditsettings!\n"));
692 return False;
695 if (!prs_uint32s(False, "auditsettings", ps, depth, d_q->auditsettings, d_q->count2))
696 return False;
698 return True;
701 /*******************************************************************
702 Reads or writes a dom query structure.
703 ********************************************************************/
705 static BOOL lsa_io_dom_query_3(const char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
707 return lsa_io_dom_query("", d_q, ps, depth);
710 /*******************************************************************
711 Reads or writes a dom query structure.
712 ********************************************************************/
714 static BOOL lsa_io_dom_query_5(const char *desc, DOM_QUERY_5 *d_q, prs_struct *ps, int depth)
716 return lsa_io_dom_query("", d_q, ps, depth);
719 /*******************************************************************
720 Reads or writes a dom query structure.
721 ********************************************************************/
723 static BOOL lsa_io_dom_query_6(const char *desc, DOM_QUERY_6 *d_q, prs_struct *ps, int depth)
725 if (d_q == NULL)
726 return False;
728 prs_debug(ps, depth, desc, "lsa_io_dom_query_6");
729 depth++;
731 if (!prs_uint16("server_role", ps, depth, &d_q->server_role))
732 return False;
734 return True;
737 /*******************************************************************
738 Reads or writes an LSA_R_QUERY_INFO structure.
739 ********************************************************************/
741 BOOL lsa_io_r_query(const char *desc, LSA_R_QUERY_INFO *r_q, prs_struct *ps,
742 int depth)
744 prs_debug(ps, depth, desc, "lsa_io_r_query");
745 depth++;
747 if(!prs_uint32("undoc_buffer", ps, depth, &r_q->undoc_buffer))
748 return False;
750 if (r_q->undoc_buffer != 0) {
751 if(!prs_uint16("info_class", ps, depth, &r_q->info_class))
752 return False;
754 if(!prs_align(ps))
755 return False;
757 switch (r_q->info_class) {
758 case 2:
759 if(!lsa_io_dom_query_2("", &r_q->dom.id2, ps, depth))
760 return False;
761 break;
762 case 3:
763 if(!lsa_io_dom_query_3("", &r_q->dom.id3, ps, depth))
764 return False;
765 break;
766 case 5:
767 if(!lsa_io_dom_query_5("", &r_q->dom.id5, ps, depth))
768 return False;
769 break;
770 case 6:
771 if(!lsa_io_dom_query_6("", &r_q->dom.id6, ps, depth))
772 return False;
773 break;
774 default:
775 /* PANIC! */
776 break;
780 if(!prs_align(ps))
781 return False;
783 if(!prs_ntstatus("status", ps, depth, &r_q->status))
784 return False;
786 return True;
789 /*******************************************************************
790 Inits a LSA_SID_ENUM structure.
791 ********************************************************************/
793 static void init_lsa_sid_enum(TALLOC_CTX *mem_ctx, LSA_SID_ENUM *sen,
794 int num_entries, const DOM_SID *sids)
796 int i;
798 DEBUG(5, ("init_lsa_sid_enum\n"));
800 sen->num_entries = num_entries;
801 sen->ptr_sid_enum = (num_entries != 0);
802 sen->num_entries2 = num_entries;
804 /* Allocate memory for sids and sid pointers */
806 if (num_entries == 0) return;
808 if ((sen->ptr_sid = TALLOC_ZERO_ARRAY(mem_ctx, uint32, num_entries )) == NULL) {
809 DEBUG(3, ("init_lsa_sid_enum(): out of memory for ptr_sid\n"));
810 return;
813 if ((sen->sid = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID2, num_entries)) == NULL) {
814 DEBUG(3, ("init_lsa_sid_enum(): out of memory for sids\n"));
815 return;
818 /* Copy across SIDs and SID pointers */
820 for (i = 0; i < num_entries; i++) {
821 sen->ptr_sid[i] = 1;
822 init_dom_sid2(&sen->sid[i], &sids[i]);
826 /*******************************************************************
827 Reads or writes a LSA_SID_ENUM structure.
828 ********************************************************************/
830 static BOOL lsa_io_sid_enum(const char *desc, LSA_SID_ENUM *sen, prs_struct *ps,
831 int depth)
833 unsigned int i;
835 prs_debug(ps, depth, desc, "lsa_io_sid_enum");
836 depth++;
838 if(!prs_align(ps))
839 return False;
841 if(!prs_uint32("num_entries ", ps, depth, &sen->num_entries))
842 return False;
843 if(!prs_uint32("ptr_sid_enum", ps, depth, &sen->ptr_sid_enum))
844 return False;
847 if the ptr is NULL, leave here. checked from a real w2k trace.
848 JFM, 11/23/2001
851 if (sen->ptr_sid_enum==0)
852 return True;
854 if(!prs_uint32("num_entries2", ps, depth, &sen->num_entries2))
855 return False;
857 /* Mallocate memory if we're unpacking from the wire */
859 if (UNMARSHALLING(ps)) {
860 if ((sen->ptr_sid = PRS_ALLOC_MEM( ps, uint32, sen->num_entries)) == NULL) {
861 DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
862 "ptr_sid\n"));
863 return False;
866 if ((sen->sid = PRS_ALLOC_MEM( ps, DOM_SID2, sen->num_entries)) == NULL) {
867 DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
868 "sids\n"));
869 return False;
873 for (i = 0; i < sen->num_entries; i++) {
874 fstring temp;
876 slprintf(temp, sizeof(temp) - 1, "ptr_sid[%d]", i);
877 if(!prs_uint32(temp, ps, depth, &sen->ptr_sid[i])) {
878 return False;
882 for (i = 0; i < sen->num_entries; i++) {
883 fstring temp;
885 slprintf(temp, sizeof(temp) - 1, "sid[%d]", i);
886 if(!smb_io_dom_sid2(temp, &sen->sid[i], ps, depth)) {
887 return False;
891 return True;
894 /*******************************************************************
895 Inits an LSA_R_ENUM_TRUST_DOM structure.
896 ********************************************************************/
898 void init_q_lookup_sids(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_SIDS *q_l,
899 POLICY_HND *hnd, int num_sids, const DOM_SID *sids,
900 uint16 level)
902 DEBUG(5, ("init_q_lookup_sids\n"));
904 ZERO_STRUCTP(q_l);
906 memcpy(&q_l->pol, hnd, sizeof(q_l->pol));
907 init_lsa_sid_enum(mem_ctx, &q_l->sids, num_sids, sids);
909 q_l->level.value = level;
912 /*******************************************************************
913 Reads or writes a LSA_Q_LOOKUP_SIDS structure.
914 ********************************************************************/
916 BOOL lsa_io_q_lookup_sids(const char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps,
917 int depth)
919 prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids");
920 depth++;
922 if(!prs_align(ps))
923 return False;
925 if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */
926 return False;
927 if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */
928 return False;
929 if(!lsa_io_trans_names("names ", &q_s->names, ps, depth)) /* translated names */
930 return False;
931 if(!smb_io_lookup_level("switch ", &q_s->level, ps, depth)) /* lookup level */
932 return False;
934 if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count))
935 return False;
937 return True;
940 /*******************************************************************
941 Reads or writes a structure.
942 ********************************************************************/
944 static BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn,
945 prs_struct *ps, int depth)
947 unsigned int i;
949 prs_debug(ps, depth, desc, "lsa_io_trans_names");
950 depth++;
952 if(!prs_align(ps))
953 return False;
955 if(!prs_uint32("num_entries ", ps, depth, &trn->num_entries))
956 return False;
957 if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names))
958 return False;
960 if (trn->ptr_trans_names != 0) {
961 if(!prs_uint32("num_entries2 ", ps, depth,
962 &trn->num_entries2))
963 return False;
965 if (UNMARSHALLING(ps)) {
966 if ((trn->name = PRS_ALLOC_MEM(ps, LSA_TRANS_NAME, trn->num_entries)) == NULL) {
967 return False;
970 if ((trn->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, trn->num_entries)) == NULL) {
971 return False;
975 for (i = 0; i < trn->num_entries2; i++) {
976 fstring t;
977 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
979 if(!lsa_io_trans_name(t, &trn->name[i], ps, depth)) /* translated name */
980 return False;
983 for (i = 0; i < trn->num_entries2; i++) {
984 fstring t;
985 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
987 if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth))
988 return False;
989 if(!prs_align(ps))
990 return False;
994 return True;
997 /*******************************************************************
998 Reads or writes a structure.
999 ********************************************************************/
1001 BOOL lsa_io_r_lookup_sids(const char *desc, LSA_R_LOOKUP_SIDS *r_s,
1002 prs_struct *ps, int depth)
1004 prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids");
1005 depth++;
1007 if(!prs_align(ps))
1008 return False;
1010 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref))
1011 return False;
1013 if (r_s->ptr_dom_ref != 0)
1014 if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */
1015 return False;
1017 if(!lsa_io_trans_names("names ", r_s->names, ps, depth)) /* translated names */
1018 return False;
1020 if(!prs_align(ps))
1021 return False;
1023 if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count))
1024 return False;
1026 if(!prs_ntstatus("status ", ps, depth, &r_s->status))
1027 return False;
1029 return True;
1032 /*******************************************************************
1033 makes a structure.
1034 ********************************************************************/
1036 void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l,
1037 POLICY_HND *hnd, int num_names, const char **names)
1039 unsigned int i;
1041 DEBUG(5, ("init_q_lookup_names\n"));
1043 ZERO_STRUCTP(q_l);
1045 q_l->pol = *hnd;
1046 q_l->num_entries = num_names;
1047 q_l->num_entries2 = num_names;
1048 q_l->lookup_level = 1;
1050 if ((q_l->uni_name = TALLOC_ZERO_ARRAY(mem_ctx, UNISTR2, num_names)) == NULL) {
1051 DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1052 return;
1055 if ((q_l->hdr_name = TALLOC_ZERO_ARRAY(mem_ctx, UNIHDR, num_names)) == NULL) {
1056 DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1057 return;
1060 for (i = 0; i < num_names; i++) {
1061 init_unistr2(&q_l->uni_name[i], names[i], UNI_FLAGS_NONE);
1062 init_uni_hdr(&q_l->hdr_name[i], &q_l->uni_name[i]);
1066 /*******************************************************************
1067 reads or writes a structure.
1068 ********************************************************************/
1070 BOOL lsa_io_q_lookup_names(const char *desc, LSA_Q_LOOKUP_NAMES *q_r,
1071 prs_struct *ps, int depth)
1073 unsigned int i;
1075 prs_debug(ps, depth, desc, "lsa_io_q_lookup_names");
1076 depth++;
1078 if(!prs_align(ps))
1079 return False;
1081 if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */
1082 return False;
1084 if(!prs_align(ps))
1085 return False;
1086 if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries))
1087 return False;
1088 if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2))
1089 return False;
1091 if (UNMARSHALLING(ps)) {
1092 if (q_r->num_entries) {
1093 if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)
1094 return False;
1095 if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)
1096 return False;
1100 for (i = 0; i < q_r->num_entries; i++) {
1101 if(!prs_align(ps))
1102 return False;
1103 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1104 return False;
1107 for (i = 0; i < q_r->num_entries; i++) {
1108 if(!prs_align(ps))
1109 return False;
1110 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1111 return False;
1114 if(!prs_align(ps))
1115 return False;
1116 if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1117 return False;
1118 if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1119 return False;
1120 if(!prs_uint32("lookup_level ", ps, depth, &q_r->lookup_level))
1121 return False;
1122 if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count))
1123 return False;
1125 return True;
1128 /*******************************************************************
1129 reads or writes a structure.
1130 ********************************************************************/
1132 BOOL lsa_io_r_lookup_names(const char *desc, LSA_R_LOOKUP_NAMES *r_r,
1133 prs_struct *ps, int depth)
1135 unsigned int i;
1137 prs_debug(ps, depth, desc, "lsa_io_r_lookup_names");
1138 depth++;
1140 if(!prs_align(ps))
1141 return False;
1143 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_r->ptr_dom_ref))
1144 return False;
1146 if (r_r->ptr_dom_ref != 0)
1147 if(!lsa_io_dom_r_ref("", r_r->dom_ref, ps, depth))
1148 return False;
1150 if(!prs_uint32("num_entries", ps, depth, &r_r->num_entries))
1151 return False;
1152 if(!prs_uint32("ptr_entries", ps, depth, &r_r->ptr_entries))
1153 return False;
1155 if (r_r->ptr_entries != 0) {
1156 if(!prs_uint32("num_entries2", ps, depth, &r_r->num_entries2))
1157 return False;
1159 if (r_r->num_entries2 != r_r->num_entries) {
1160 /* RPC fault */
1161 return False;
1164 if (UNMARSHALLING(ps)) {
1165 if ((r_r->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID2, r_r->num_entries2))
1166 == NULL) {
1167 DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n"));
1168 return False;
1172 for (i = 0; i < r_r->num_entries2; i++)
1173 if(!smb_io_dom_rid2("", &r_r->dom_rid[i], ps, depth)) /* domain RIDs being looked up */
1174 return False;
1177 if(!prs_uint32("mapped_count", ps, depth, &r_r->mapped_count))
1178 return False;
1180 if(!prs_ntstatus("status ", ps, depth, &r_r->status))
1181 return False;
1183 return True;
1187 /*******************************************************************
1188 Inits an LSA_Q_CLOSE structure.
1189 ********************************************************************/
1191 void init_lsa_q_close(LSA_Q_CLOSE *q_c, POLICY_HND *hnd)
1193 DEBUG(5, ("init_lsa_q_close\n"));
1195 memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
1198 /*******************************************************************
1199 Reads or writes an LSA_Q_CLOSE structure.
1200 ********************************************************************/
1202 BOOL lsa_io_q_close(const char *desc, LSA_Q_CLOSE *q_c, prs_struct *ps, int depth)
1204 prs_debug(ps, depth, desc, "lsa_io_q_close");
1205 depth++;
1207 if(!smb_io_pol_hnd("", &q_c->pol, ps, depth))
1208 return False;
1210 return True;
1213 /*******************************************************************
1214 Reads or writes an LSA_R_CLOSE structure.
1215 ********************************************************************/
1217 BOOL lsa_io_r_close(const char *desc, LSA_R_CLOSE *r_c, prs_struct *ps, int depth)
1219 prs_debug(ps, depth, desc, "lsa_io_r_close");
1220 depth++;
1222 if(!smb_io_pol_hnd("", &r_c->pol, ps, depth))
1223 return False;
1225 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1226 return False;
1228 return True;
1231 /*******************************************************************
1232 Reads or writes an LSA_Q_OPEN_SECRET structure.
1233 ********************************************************************/
1235 BOOL lsa_io_q_open_secret(const char *desc, LSA_Q_OPEN_SECRET *q_c, prs_struct *ps, int depth)
1237 prs_debug(ps, depth, desc, "lsa_io_q_open_secret");
1238 depth++;
1240 /* Don't bother to read or write at present... */
1241 return True;
1244 /*******************************************************************
1245 Reads or writes an LSA_R_OPEN_SECRET structure.
1246 ********************************************************************/
1248 BOOL lsa_io_r_open_secret(const char *desc, LSA_R_OPEN_SECRET *r_c, prs_struct *ps, int depth)
1250 prs_debug(ps, depth, desc, "lsa_io_r_open_secret");
1251 depth++;
1253 if(!prs_align(ps))
1254 return False;
1256 if(!prs_uint32("dummy1", ps, depth, &r_c->dummy1))
1257 return False;
1258 if(!prs_uint32("dummy2", ps, depth, &r_c->dummy2))
1259 return False;
1260 if(!prs_uint32("dummy3", ps, depth, &r_c->dummy3))
1261 return False;
1262 if(!prs_uint32("dummy4", ps, depth, &r_c->dummy4))
1263 return False;
1264 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1265 return False;
1267 return True;
1270 /*******************************************************************
1271 Inits an LSA_Q_ENUM_PRIVS structure.
1272 ********************************************************************/
1274 void init_q_enum_privs(LSA_Q_ENUM_PRIVS *q_q, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1276 DEBUG(5, ("init_q_enum_privs\n"));
1278 memcpy(&q_q->pol, hnd, sizeof(q_q->pol));
1280 q_q->enum_context = enum_context;
1281 q_q->pref_max_length = pref_max_length;
1284 /*******************************************************************
1285 reads or writes a structure.
1286 ********************************************************************/
1287 BOOL lsa_io_q_enum_privs(const char *desc, LSA_Q_ENUM_PRIVS *q_q, prs_struct *ps, int depth)
1289 if (q_q == NULL)
1290 return False;
1292 prs_debug(ps, depth, desc, "lsa_io_q_enum_privs");
1293 depth++;
1295 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1296 return False;
1298 if(!prs_uint32("enum_context ", ps, depth, &q_q->enum_context))
1299 return False;
1300 if(!prs_uint32("pref_max_length", ps, depth, &q_q->pref_max_length))
1301 return False;
1303 return True;
1306 /*******************************************************************
1307 reads or writes a structure.
1308 ********************************************************************/
1309 static BOOL lsa_io_priv_entries(const char *desc, LSA_PRIV_ENTRY *entries, uint32 count, prs_struct *ps, int depth)
1311 uint32 i;
1313 if (entries == NULL)
1314 return False;
1316 prs_debug(ps, depth, desc, "lsa_io_priv_entries");
1317 depth++;
1319 if(!prs_align(ps))
1320 return False;
1322 for (i = 0; i < count; i++) {
1323 if (!smb_io_unihdr("", &entries[i].hdr_name, ps, depth))
1324 return False;
1325 if(!prs_uint32("luid_low ", ps, depth, &entries[i].luid_low))
1326 return False;
1327 if(!prs_uint32("luid_high", ps, depth, &entries[i].luid_high))
1328 return False;
1331 for (i = 0; i < count; i++)
1332 if (!smb_io_unistr2("", &entries[i].name, entries[i].hdr_name.buffer, ps, depth))
1333 return False;
1335 return True;
1338 /*******************************************************************
1339 Inits an LSA_R_ENUM_PRIVS structure.
1340 ********************************************************************/
1342 void init_lsa_r_enum_privs(LSA_R_ENUM_PRIVS *r_u, uint32 enum_context,
1343 uint32 count, LSA_PRIV_ENTRY *entries)
1345 DEBUG(5, ("init_lsa_r_enum_privs\n"));
1347 r_u->enum_context=enum_context;
1348 r_u->count=count;
1350 if (entries!=NULL) {
1351 r_u->ptr=1;
1352 r_u->count1=count;
1353 r_u->privs=entries;
1354 } else {
1355 r_u->ptr=0;
1356 r_u->count1=0;
1357 r_u->privs=NULL;
1361 /*******************************************************************
1362 reads or writes a structure.
1363 ********************************************************************/
1364 BOOL lsa_io_r_enum_privs(const char *desc, LSA_R_ENUM_PRIVS *r_q, prs_struct *ps, int depth)
1366 if (r_q == NULL)
1367 return False;
1369 prs_debug(ps, depth, desc, "lsa_io_r_enum_privs");
1370 depth++;
1372 if(!prs_align(ps))
1373 return False;
1375 if(!prs_uint32("enum_context", ps, depth, &r_q->enum_context))
1376 return False;
1377 if(!prs_uint32("count", ps, depth, &r_q->count))
1378 return False;
1379 if(!prs_uint32("ptr", ps, depth, &r_q->ptr))
1380 return False;
1382 if (r_q->ptr) {
1383 if(!prs_uint32("count1", ps, depth, &r_q->count1))
1384 return False;
1386 if (UNMARSHALLING(ps))
1387 if (!(r_q->privs = PRS_ALLOC_MEM(ps, LSA_PRIV_ENTRY, r_q->count1)))
1388 return False;
1390 if (!lsa_io_priv_entries("", r_q->privs, r_q->count1, ps, depth))
1391 return False;
1394 if(!prs_align(ps))
1395 return False;
1397 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1398 return False;
1400 return True;
1403 void init_lsa_priv_get_dispname(LSA_Q_PRIV_GET_DISPNAME *trn, POLICY_HND *hnd, const char *name, uint16 lang_id, uint16 lang_id_sys)
1405 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1407 init_unistr2(&trn->name, name, UNI_FLAGS_NONE);
1408 init_uni_hdr(&trn->hdr_name, &trn->name);
1409 trn->lang_id = lang_id;
1410 trn->lang_id_sys = lang_id_sys;
1413 /*******************************************************************
1414 reads or writes a structure.
1415 ********************************************************************/
1416 BOOL lsa_io_q_priv_get_dispname(const char *desc, LSA_Q_PRIV_GET_DISPNAME *q_q, prs_struct *ps, int depth)
1418 if (q_q == NULL)
1419 return False;
1421 prs_debug(ps, depth, desc, "lsa_io_q_priv_get_dispname");
1422 depth++;
1424 if(!prs_align(ps))
1425 return False;
1427 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1428 return False;
1430 if (!smb_io_unihdr("hdr_name", &q_q->hdr_name, ps, depth))
1431 return False;
1433 if (!smb_io_unistr2("name", &q_q->name, q_q->hdr_name.buffer, ps, depth))
1434 return False;
1436 if(!prs_uint16("lang_id ", ps, depth, &q_q->lang_id))
1437 return False;
1438 if(!prs_uint16("lang_id_sys", ps, depth, &q_q->lang_id_sys))
1439 return False;
1441 return True;
1444 /*******************************************************************
1445 reads or writes a structure.
1446 ********************************************************************/
1447 BOOL lsa_io_r_priv_get_dispname(const char *desc, LSA_R_PRIV_GET_DISPNAME *r_q, prs_struct *ps, int depth)
1449 if (r_q == NULL)
1450 return False;
1452 prs_debug(ps, depth, desc, "lsa_io_r_priv_get_dispname");
1453 depth++;
1455 if (!prs_align(ps))
1456 return False;
1458 if (!prs_uint32("ptr_info", ps, depth, &r_q->ptr_info))
1459 return False;
1461 if (r_q->ptr_info){
1462 if (!smb_io_unihdr("hdr_name", &r_q->hdr_desc, ps, depth))
1463 return False;
1465 if (!smb_io_unistr2("desc", &r_q->desc, r_q->hdr_desc.buffer, ps, depth))
1466 return False;
1469 if(!prs_align(ps))
1470 return False;
1472 if(!prs_uint16("lang_id", ps, depth, &r_q->lang_id))
1473 return False;
1475 if(!prs_align(ps))
1476 return False;
1477 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1478 return False;
1480 return True;
1484 initialise a LSA_Q_ENUM_ACCOUNTS structure
1486 void init_lsa_q_enum_accounts(LSA_Q_ENUM_ACCOUNTS *trn, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1488 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1490 trn->enum_context = enum_context;
1491 trn->pref_max_length = pref_max_length;
1494 /*******************************************************************
1495 reads or writes a structure.
1496 ********************************************************************/
1497 BOOL lsa_io_q_enum_accounts(const char *desc, LSA_Q_ENUM_ACCOUNTS *q_q, prs_struct *ps, int depth)
1499 if (q_q == NULL)
1500 return False;
1502 prs_debug(ps, depth, desc, "lsa_io_q_enum_accounts");
1503 depth++;
1505 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1506 return False;
1508 if(!prs_uint32("enum_context ", ps, depth, &q_q->enum_context))
1509 return False;
1510 if(!prs_uint32("pref_max_length", ps, depth, &q_q->pref_max_length))
1511 return False;
1513 return True;
1517 /*******************************************************************
1518 Inits an LSA_R_ENUM_PRIVS structure.
1519 ********************************************************************/
1521 void init_lsa_r_enum_accounts(LSA_R_ENUM_ACCOUNTS *r_u, uint32 enum_context)
1523 DEBUG(5, ("init_lsa_r_enum_accounts\n"));
1525 r_u->enum_context=enum_context;
1526 if (r_u->enum_context!=0) {
1527 r_u->sids.num_entries=enum_context;
1528 r_u->sids.ptr_sid_enum=1;
1529 r_u->sids.num_entries2=enum_context;
1530 } else {
1531 r_u->sids.num_entries=0;
1532 r_u->sids.ptr_sid_enum=0;
1533 r_u->sids.num_entries2=0;
1537 /*******************************************************************
1538 reads or writes a structure.
1539 ********************************************************************/
1540 BOOL lsa_io_r_enum_accounts(const char *desc, LSA_R_ENUM_ACCOUNTS *r_q, prs_struct *ps, int depth)
1542 if (r_q == NULL)
1543 return False;
1545 prs_debug(ps, depth, desc, "lsa_io_r_enum_accounts");
1546 depth++;
1548 if (!prs_align(ps))
1549 return False;
1551 if(!prs_uint32("enum_context", ps, depth, &r_q->enum_context))
1552 return False;
1554 if (!lsa_io_sid_enum("sids", &r_q->sids, ps, depth))
1555 return False;
1557 if (!prs_align(ps))
1558 return False;
1560 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1561 return False;
1563 return True;
1567 /*******************************************************************
1568 Reads or writes an LSA_Q_UNK_GET_CONNUSER structure.
1569 ********************************************************************/
1571 BOOL lsa_io_q_unk_get_connuser(const char *desc, LSA_Q_UNK_GET_CONNUSER *q_c, prs_struct *ps, int depth)
1573 prs_debug(ps, depth, desc, "lsa_io_q_unk_get_connuser");
1574 depth++;
1576 if(!prs_align(ps))
1577 return False;
1579 if(!prs_uint32("ptr_srvname", ps, depth, &q_c->ptr_srvname))
1580 return False;
1582 if(!smb_io_unistr2("uni2_srvname", &q_c->uni2_srvname, q_c->ptr_srvname, ps, depth)) /* server name to be looked up */
1583 return False;
1585 if (!prs_align(ps))
1586 return False;
1588 if(!prs_uint32("unk1", ps, depth, &q_c->unk1))
1589 return False;
1590 if(!prs_uint32("unk2", ps, depth, &q_c->unk2))
1591 return False;
1592 if(!prs_uint32("unk3", ps, depth, &q_c->unk3))
1593 return False;
1595 /* Don't bother to read or write at present... */
1596 return True;
1599 /*******************************************************************
1600 Reads or writes an LSA_R_UNK_GET_CONNUSER structure.
1601 ********************************************************************/
1603 BOOL lsa_io_r_unk_get_connuser(const char *desc, LSA_R_UNK_GET_CONNUSER *r_c, prs_struct *ps, int depth)
1605 prs_debug(ps, depth, desc, "lsa_io_r_unk_get_connuser");
1606 depth++;
1608 if(!prs_align(ps))
1609 return False;
1611 if(!prs_uint32("ptr_user_name", ps, depth, &r_c->ptr_user_name))
1612 return False;
1613 if(!smb_io_unihdr("hdr_user_name", &r_c->hdr_user_name, ps, depth))
1614 return False;
1615 if(!smb_io_unistr2("uni2_user_name", &r_c->uni2_user_name, r_c->ptr_user_name, ps, depth))
1616 return False;
1618 if (!prs_align(ps))
1619 return False;
1621 if(!prs_uint32("unk1", ps, depth, &r_c->unk1))
1622 return False;
1624 if(!prs_uint32("ptr_dom_name", ps, depth, &r_c->ptr_dom_name))
1625 return False;
1626 if(!smb_io_unihdr("hdr_dom_name", &r_c->hdr_dom_name, ps, depth))
1627 return False;
1628 if(!smb_io_unistr2("uni2_dom_name", &r_c->uni2_dom_name, r_c->ptr_dom_name, ps, depth))
1629 return False;
1631 if (!prs_align(ps))
1632 return False;
1634 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1635 return False;
1637 return True;
1640 void init_lsa_q_create_account(LSA_Q_CREATEACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1642 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1644 init_dom_sid2(&trn->sid, sid);
1645 trn->access = desired_access;
1649 /*******************************************************************
1650 Reads or writes an LSA_Q_CREATEACCOUNT structure.
1651 ********************************************************************/
1653 BOOL lsa_io_q_create_account(const char *desc, LSA_Q_CREATEACCOUNT *r_c, prs_struct *ps, int depth)
1655 prs_debug(ps, depth, desc, "lsa_io_q_create_account");
1656 depth++;
1658 if(!prs_align(ps))
1659 return False;
1661 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1662 return False;
1664 if(!smb_io_dom_sid2("sid", &r_c->sid, ps, depth)) /* domain SID */
1665 return False;
1667 if(!prs_uint32("access", ps, depth, &r_c->access))
1668 return False;
1670 return True;
1673 /*******************************************************************
1674 Reads or writes an LSA_R_CREATEACCOUNT structure.
1675 ********************************************************************/
1677 BOOL lsa_io_r_create_account(const char *desc, LSA_R_CREATEACCOUNT *r_c, prs_struct *ps, int depth)
1679 prs_debug(ps, depth, desc, "lsa_io_r_open_account");
1680 depth++;
1682 if(!prs_align(ps))
1683 return False;
1685 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1686 return False;
1688 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1689 return False;
1691 return True;
1695 void init_lsa_q_open_account(LSA_Q_OPENACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1697 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1699 init_dom_sid2(&trn->sid, sid);
1700 trn->access = desired_access;
1703 /*******************************************************************
1704 Reads or writes an LSA_Q_OPENACCOUNT structure.
1705 ********************************************************************/
1707 BOOL lsa_io_q_open_account(const char *desc, LSA_Q_OPENACCOUNT *r_c, prs_struct *ps, int depth)
1709 prs_debug(ps, depth, desc, "lsa_io_q_open_account");
1710 depth++;
1712 if(!prs_align(ps))
1713 return False;
1715 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1716 return False;
1718 if(!smb_io_dom_sid2("sid", &r_c->sid, ps, depth)) /* domain SID */
1719 return False;
1721 if(!prs_uint32("access", ps, depth, &r_c->access))
1722 return False;
1724 return True;
1727 /*******************************************************************
1728 Reads or writes an LSA_R_OPENACCOUNT structure.
1729 ********************************************************************/
1731 BOOL lsa_io_r_open_account(const char *desc, LSA_R_OPENACCOUNT *r_c, prs_struct *ps, int depth)
1733 prs_debug(ps, depth, desc, "lsa_io_r_open_account");
1734 depth++;
1736 if(!prs_align(ps))
1737 return False;
1739 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1740 return False;
1742 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1743 return False;
1745 return True;
1749 void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd)
1751 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1755 /*******************************************************************
1756 Reads or writes an LSA_Q_ENUMPRIVSACCOUNT structure.
1757 ********************************************************************/
1759 BOOL lsa_io_q_enum_privsaccount(const char *desc, LSA_Q_ENUMPRIVSACCOUNT *r_c, prs_struct *ps, int depth)
1761 prs_debug(ps, depth, desc, "lsa_io_q_enum_privsaccount");
1762 depth++;
1764 if(!prs_align(ps))
1765 return False;
1767 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1768 return False;
1770 return True;
1773 /*******************************************************************
1774 Reads or writes an LUID structure.
1775 ********************************************************************/
1777 static BOOL lsa_io_luid(const char *desc, LUID *r_c, prs_struct *ps, int depth)
1779 prs_debug(ps, depth, desc, "lsa_io_luid");
1780 depth++;
1782 if(!prs_align(ps))
1783 return False;
1785 if(!prs_uint32("low", ps, depth, &r_c->low))
1786 return False;
1788 if(!prs_uint32("high", ps, depth, &r_c->high))
1789 return False;
1791 return True;
1794 /*******************************************************************
1795 Reads or writes an LUID_ATTR structure.
1796 ********************************************************************/
1798 static BOOL lsa_io_luid_attr(const char *desc, LUID_ATTR *r_c, prs_struct *ps, int depth)
1800 prs_debug(ps, depth, desc, "lsa_io_luid_attr");
1801 depth++;
1803 if(!prs_align(ps))
1804 return False;
1806 if (!lsa_io_luid(desc, &r_c->luid, ps, depth))
1807 return False;
1809 if(!prs_uint32("attr", ps, depth, &r_c->attr))
1810 return False;
1812 return True;
1815 /*******************************************************************
1816 Reads or writes an PRIVILEGE_SET structure.
1817 ********************************************************************/
1819 static BOOL lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *r_c, prs_struct *ps, int depth)
1821 uint32 i;
1823 prs_debug(ps, depth, desc, "lsa_io_privilege_set");
1824 depth++;
1826 if(!prs_align(ps))
1827 return False;
1829 if(!prs_uint32("count", ps, depth, &r_c->count))
1830 return False;
1831 if(!prs_uint32("control", ps, depth, &r_c->control))
1832 return False;
1834 for (i=0; i<r_c->count; i++) {
1835 if (!lsa_io_luid_attr(desc, &r_c->set[i], ps, depth))
1836 return False;
1839 return True;
1842 NTSTATUS init_lsa_r_enum_privsaccount(TALLOC_CTX *mem_ctx, LSA_R_ENUMPRIVSACCOUNT *r_u, LUID_ATTR *set, uint32 count, uint32 control)
1844 NTSTATUS ret = NT_STATUS_OK;
1846 r_u->ptr = 1;
1847 r_u->count = count;
1849 if ( !NT_STATUS_IS_OK(ret = privilege_set_init_by_ctx(mem_ctx, &(r_u->set))) )
1850 return ret;
1852 r_u->set.count = count;
1854 if (!NT_STATUS_IS_OK(ret = dup_luid_attr(r_u->set.mem_ctx, &(r_u->set.set), set, count)))
1855 return ret;
1857 DEBUG(10,("init_lsa_r_enum_privsaccount: %d privileges\n", r_u->count));
1859 return ret;
1862 /*******************************************************************
1863 Reads or writes an LSA_R_ENUMPRIVSACCOUNT structure.
1864 ********************************************************************/
1866 BOOL lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *r_c, prs_struct *ps, int depth)
1868 prs_debug(ps, depth, desc, "lsa_io_r_enum_privsaccount");
1869 depth++;
1871 if(!prs_align(ps))
1872 return False;
1874 if(!prs_uint32("ptr", ps, depth, &r_c->ptr))
1875 return False;
1877 if (r_c->ptr!=0) {
1878 if(!prs_uint32("count", ps, depth, &r_c->count))
1879 return False;
1881 /* malloc memory if unmarshalling here */
1883 if (UNMARSHALLING(ps) && r_c->count != 0) {
1884 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(r_c->set))))
1885 return False;
1887 if (!(r_c->set.set = PRS_ALLOC_MEM(ps,LUID_ATTR,r_c->count)))
1888 return False;
1892 if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth))
1893 return False;
1896 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1897 return False;
1899 return True;
1904 /*******************************************************************
1905 Reads or writes an LSA_Q_GETSYSTEMACCOUNTstructure.
1906 ********************************************************************/
1908 BOOL lsa_io_q_getsystemaccount(const char *desc, LSA_Q_GETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1910 prs_debug(ps, depth, desc, "lsa_io_q_getsystemaccount");
1911 depth++;
1913 if(!prs_align(ps))
1914 return False;
1916 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1917 return False;
1919 return True;
1922 /*******************************************************************
1923 Reads or writes an LSA_R_GETSYSTEMACCOUNTstructure.
1924 ********************************************************************/
1926 BOOL lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1928 prs_debug(ps, depth, desc, "lsa_io_r_getsystemaccount");
1929 depth++;
1931 if(!prs_align(ps))
1932 return False;
1934 if(!prs_uint32("access", ps, depth, &r_c->access))
1935 return False;
1937 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1938 return False;
1940 return True;
1944 /*******************************************************************
1945 Reads or writes an LSA_Q_SETSYSTEMACCOUNT structure.
1946 ********************************************************************/
1948 BOOL lsa_io_q_setsystemaccount(const char *desc, LSA_Q_SETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1950 prs_debug(ps, depth, desc, "lsa_io_q_setsystemaccount");
1951 depth++;
1953 if(!prs_align(ps))
1954 return False;
1956 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1957 return False;
1959 if(!prs_uint32("access", ps, depth, &r_c->access))
1960 return False;
1962 return True;
1965 /*******************************************************************
1966 Reads or writes an LSA_R_SETSYSTEMACCOUNT structure.
1967 ********************************************************************/
1969 BOOL lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1971 prs_debug(ps, depth, desc, "lsa_io_r_setsystemaccount");
1972 depth++;
1974 if(!prs_align(ps))
1975 return False;
1977 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1978 return False;
1980 return True;
1984 static void init_lsa_string( LSA_STRING *uni, const char *string )
1986 init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE);
1987 init_uni_hdr(&uni->hdr, &uni->unistring);
1990 void init_lsa_q_lookup_priv_value(LSA_Q_LOOKUP_PRIV_VALUE *q_u, POLICY_HND *hnd, const char *name)
1992 memcpy(&q_u->pol, hnd, sizeof(q_u->pol));
1993 init_lsa_string( &q_u->privname, name );
1996 BOOL smb_io_lsa_string( const char *desc, LSA_STRING *string, prs_struct *ps, int depth )
1998 prs_debug(ps, depth, desc, "smb_io_lsa_string");
1999 depth++;
2001 if(!smb_io_unihdr ("hdr", &string->hdr, ps, depth))
2002 return False;
2003 if(!smb_io_unistr2("unistring", &string->unistring, string->hdr.buffer, ps, depth))
2004 return False;
2006 return True;
2009 /*******************************************************************
2010 Reads or writes an LSA_Q_LOOKUP_PRIV_VALUE structure.
2011 ********************************************************************/
2013 BOOL lsa_io_q_lookup_priv_value(const char *desc, LSA_Q_LOOKUP_PRIV_VALUE *r_c, prs_struct *ps, int depth)
2015 prs_debug(ps, depth, desc, "lsa_io_q_lookup_priv_value");
2016 depth++;
2018 if(!prs_align(ps))
2019 return False;
2021 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
2022 return False;
2023 if(!smb_io_lsa_string("privname", &r_c->privname, ps, depth))
2024 return False;
2026 return True;
2029 /*******************************************************************
2030 Reads or writes an LSA_R_LOOKUP_PRIV_VALUE structure.
2031 ********************************************************************/
2033 BOOL lsa_io_r_lookup_priv_value(const char *desc, LSA_R_LOOKUP_PRIV_VALUE *r_c, prs_struct *ps, int depth)
2035 prs_debug(ps, depth, desc, "lsa_io_r_lookup_priv_value");
2036 depth++;
2038 if(!prs_align(ps))
2039 return False;
2041 if(!lsa_io_luid("luid", &r_c->luid, ps, depth))
2042 return False;
2044 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2045 return False;
2047 return True;
2051 /*******************************************************************
2052 Reads or writes an LSA_Q_ADDPRIVS structure.
2053 ********************************************************************/
2055 BOOL lsa_io_q_addprivs(const char *desc, LSA_Q_ADDPRIVS *r_c, prs_struct *ps, int depth)
2057 prs_debug(ps, depth, desc, "lsa_io_q_addprivs");
2058 depth++;
2060 if(!prs_align(ps))
2061 return False;
2063 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
2064 return False;
2066 if(!prs_uint32("count", ps, depth, &r_c->count))
2067 return False;
2069 if (UNMARSHALLING(ps) && r_c->count!=0) {
2070 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(r_c->set))))
2071 return False;
2073 if (!(r_c->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, r_c->count)))
2074 return False;
2077 if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth))
2078 return False;
2080 return True;
2083 /*******************************************************************
2084 Reads or writes an LSA_R_ADDPRIVS structure.
2085 ********************************************************************/
2087 BOOL lsa_io_r_addprivs(const char *desc, LSA_R_ADDPRIVS *r_c, prs_struct *ps, int depth)
2089 prs_debug(ps, depth, desc, "lsa_io_r_addprivs");
2090 depth++;
2092 if(!prs_align(ps))
2093 return False;
2095 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2096 return False;
2098 return True;
2101 /*******************************************************************
2102 Reads or writes an LSA_Q_REMOVEPRIVS structure.
2103 ********************************************************************/
2105 BOOL lsa_io_q_removeprivs(const char *desc, LSA_Q_REMOVEPRIVS *r_c, prs_struct *ps, int depth)
2107 prs_debug(ps, depth, desc, "lsa_io_q_removeprivs");
2108 depth++;
2110 if(!prs_align(ps))
2111 return False;
2113 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
2114 return False;
2116 if(!prs_uint32("allrights", ps, depth, &r_c->allrights))
2117 return False;
2119 if(!prs_uint32("ptr", ps, depth, &r_c->ptr))
2120 return False;
2123 * JFM: I'm not sure at all if the count is inside the ptr
2124 * never seen one with ptr=0
2127 if (r_c->ptr!=0) {
2128 if(!prs_uint32("count", ps, depth, &r_c->count))
2129 return False;
2131 if (UNMARSHALLING(ps) && r_c->count!=0) {
2132 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(r_c->set))))
2133 return False;
2135 if (!(r_c->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, r_c->count)))
2136 return False;
2139 if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth))
2140 return False;
2143 return True;
2146 /*******************************************************************
2147 Reads or writes an LSA_R_REMOVEPRIVS structure.
2148 ********************************************************************/
2150 BOOL lsa_io_r_removeprivs(const char *desc, LSA_R_REMOVEPRIVS *r_c, prs_struct *ps, int depth)
2152 prs_debug(ps, depth, desc, "lsa_io_r_removeprivs");
2153 depth++;
2155 if(!prs_align(ps))
2156 return False;
2158 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2159 return False;
2161 return True;
2164 BOOL policy_handle_is_valid(const POLICY_HND *hnd)
2166 POLICY_HND zero_pol;
2168 ZERO_STRUCT(zero_pol);
2169 return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True );
2172 /*******************************************************************
2173 Reads or writes an LSA_DNS_DOM_INFO structure.
2174 ********************************************************************/
2176 BOOL lsa_io_dns_dom_info(const char *desc, LSA_DNS_DOM_INFO *info,
2177 prs_struct *ps, int depth)
2179 prs_debug(ps, depth, desc, "lsa_io_dns_dom_info");
2180 depth++;
2182 if(!prs_align(ps))
2183 return False;
2184 if(!smb_io_unihdr("nb_name", &info->hdr_nb_dom_name, ps, depth))
2185 return False;
2186 if(!smb_io_unihdr("dns_name", &info->hdr_dns_dom_name, ps, depth))
2187 return False;
2188 if(!smb_io_unihdr("forest", &info->hdr_forest_name, ps, depth))
2189 return False;
2191 if(!prs_align(ps))
2192 return False;
2193 if ( !smb_io_uuid("dom_guid", &info->dom_guid, ps, depth) )
2194 return False;
2196 if(!prs_align(ps))
2197 return False;
2198 if(!prs_uint32("dom_sid", ps, depth, &info->ptr_dom_sid))
2199 return False;
2201 if(!smb_io_unistr2("nb_name", &info->uni_nb_dom_name,
2202 info->hdr_nb_dom_name.buffer, ps, depth))
2203 return False;
2204 if(!smb_io_unistr2("dns_name", &info->uni_dns_dom_name,
2205 info->hdr_dns_dom_name.buffer, ps, depth))
2206 return False;
2207 if(!smb_io_unistr2("forest", &info->uni_forest_name,
2208 info->hdr_forest_name.buffer, ps, depth))
2209 return False;
2211 if(!smb_io_dom_sid2("dom_sid", &info->dom_sid, ps, depth))
2212 return False;
2214 return True;
2218 /*******************************************************************
2219 Inits an LSA_Q_QUERY_INFO2 structure.
2220 ********************************************************************/
2222 void init_q_query2(LSA_Q_QUERY_INFO2 *q_q, POLICY_HND *hnd, uint16 info_class)
2224 DEBUG(5, ("init_q_query2\n"));
2226 memcpy(&q_q->pol, hnd, sizeof(q_q->pol));
2228 q_q->info_class = info_class;
2231 /*******************************************************************
2232 Reads or writes an LSA_Q_QUERY_DNSDOMINFO structure.
2233 ********************************************************************/
2235 BOOL lsa_io_q_query_info2(const char *desc, LSA_Q_QUERY_INFO2 *q_c,
2236 prs_struct *ps, int depth)
2238 prs_debug(ps, depth, desc, "lsa_io_q_query_info2");
2239 depth++;
2241 if(!prs_align(ps))
2242 return False;
2244 if(!smb_io_pol_hnd("pol", &q_c->pol, ps, depth))
2245 return False;
2247 if(!prs_uint16("info_class", ps, depth, &q_c->info_class))
2248 return False;
2250 return True;
2253 /*******************************************************************
2254 Reads or writes an LSA_R_QUERY_DNSDOMINFO structure.
2255 ********************************************************************/
2257 BOOL lsa_io_r_query_info2(const char *desc, LSA_R_QUERY_INFO2 *r_c,
2258 prs_struct *ps, int depth)
2260 prs_debug(ps, depth, desc, "lsa_io_r_query_info2");
2261 depth++;
2263 if(!prs_align(ps))
2264 return False;
2266 if(!prs_uint32("ptr", ps, depth, &r_c->ptr))
2267 return False;
2268 if(!prs_uint16("info_class", ps, depth, &r_c->info_class))
2269 return False;
2270 switch(r_c->info_class) {
2271 case 0x000c:
2272 if (!lsa_io_dns_dom_info("info12", &r_c->info.dns_dom_info,
2273 ps, depth))
2274 return False;
2275 break;
2276 default:
2277 DEBUG(0,("lsa_io_r_query_info2: unknown info class %d\n",
2278 r_c->info_class));
2279 return False;
2282 if(!prs_align(ps))
2283 return False;
2284 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2285 return False;
2287 return True;
2290 /*******************************************************************
2291 Inits an LSA_Q_ENUM_ACCT_RIGHTS structure.
2292 ********************************************************************/
2293 void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS *q_q,
2294 POLICY_HND *hnd,
2295 uint32 count,
2296 DOM_SID *sid)
2298 DEBUG(5, ("init_q_enum_acct_rights\n"));
2300 q_q->pol = *hnd;
2301 init_dom_sid2(&q_q->sid, sid);
2304 /*******************************************************************
2305 ********************************************************************/
2306 NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *r_u, PRIVILEGE_SET *privileges )
2308 uint32 i;
2309 char *privname;
2310 const char **privname_array = NULL;
2311 int num_priv = 0;
2313 for ( i=0; i<privileges->count; i++ ) {
2314 privname = luid_to_privilege_name( &privileges->set[i].luid );
2315 if ( privname ) {
2316 if ( !add_string_to_array( get_talloc_ctx(), privname, &privname_array, &num_priv ) )
2317 return NT_STATUS_NO_MEMORY;
2321 if ( num_priv ) {
2322 if ( !init_unistr2_array( &r_u->rights, num_priv, privname_array ) )
2323 return NT_STATUS_NO_MEMORY;
2325 r_u->count = num_priv;
2328 return NT_STATUS_OK;
2331 /*******************************************************************
2332 reads or writes a LSA_Q_ENUM_ACCT_RIGHTS structure.
2333 ********************************************************************/
2334 BOOL lsa_io_q_enum_acct_rights(const char *desc, LSA_Q_ENUM_ACCT_RIGHTS *q_q, prs_struct *ps, int depth)
2337 if (q_q == NULL)
2338 return False;
2340 prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_rights");
2341 depth++;
2343 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
2344 return False;
2346 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth))
2347 return False;
2349 return True;
2353 /*******************************************************************
2354 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2355 ********************************************************************/
2356 BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *r_c, prs_struct *ps, int depth)
2358 prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_rights");
2359 depth++;
2361 if(!prs_uint32("count ", ps, depth, &r_c->count))
2362 return False;
2364 if(!smb_io_unistr2_array("rights", &r_c->rights, ps, depth))
2365 return False;
2367 if(!prs_align(ps))
2368 return False;
2370 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2371 return False;
2373 return True;
2377 /*******************************************************************
2378 Inits an LSA_Q_ADD_ACCT_RIGHTS structure.
2379 ********************************************************************/
2380 void init_q_add_acct_rights(LSA_Q_ADD_ACCT_RIGHTS *q_q,
2381 POLICY_HND *hnd,
2382 DOM_SID *sid,
2383 uint32 count,
2384 const char **rights)
2386 DEBUG(5, ("init_q_add_acct_rights\n"));
2388 q_q->pol = *hnd;
2389 init_dom_sid2(&q_q->sid, sid);
2390 init_unistr2_array(&q_q->rights, count, rights);
2391 q_q->count = count;
2395 /*******************************************************************
2396 reads or writes a LSA_Q_ADD_ACCT_RIGHTS structure.
2397 ********************************************************************/
2398 BOOL lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *q_q, prs_struct *ps, int depth)
2400 prs_debug(ps, depth, desc, "lsa_io_q_add_acct_rights");
2401 depth++;
2403 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
2404 return False;
2406 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth))
2407 return False;
2409 if(!prs_uint32("count", ps, depth, &q_q->count))
2410 return False;
2412 if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth))
2413 return False;
2415 return True;
2418 /*******************************************************************
2419 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2420 ********************************************************************/
2421 BOOL lsa_io_r_add_acct_rights(const char *desc, LSA_R_ADD_ACCT_RIGHTS *r_c, prs_struct *ps, int depth)
2423 prs_debug(ps, depth, desc, "lsa_io_r_add_acct_rights");
2424 depth++;
2426 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2427 return False;
2429 return True;
2433 /*******************************************************************
2434 Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure.
2435 ********************************************************************/
2436 void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *q_q,
2437 POLICY_HND *hnd,
2438 DOM_SID *sid,
2439 uint32 removeall,
2440 uint32 count,
2441 const char **rights)
2443 DEBUG(5, ("init_q_remove_acct_rights\n"));
2445 q_q->pol = *hnd;
2446 init_dom_sid2(&q_q->sid, sid);
2447 q_q->removeall = removeall;
2448 init_unistr2_array(&q_q->rights, count, rights);
2449 q_q->count = count;
2453 /*******************************************************************
2454 reads or writes a LSA_Q_REMOVE_ACCT_RIGHTS structure.
2455 ********************************************************************/
2456 BOOL lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *q_q, prs_struct *ps, int depth)
2458 prs_debug(ps, depth, desc, "lsa_io_q_remove_acct_rights");
2459 depth++;
2461 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
2462 return False;
2464 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth))
2465 return False;
2467 if(!prs_uint32("removeall", ps, depth, &q_q->removeall))
2468 return False;
2470 if(!prs_uint32("count", ps, depth, &q_q->count))
2471 return False;
2473 if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth))
2474 return False;
2476 return True;
2479 /*******************************************************************
2480 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2481 ********************************************************************/
2482 BOOL lsa_io_r_remove_acct_rights(const char *desc, LSA_R_REMOVE_ACCT_RIGHTS *r_c, prs_struct *ps, int depth)
2484 prs_debug(ps, depth, desc, "lsa_io_r_remove_acct_rights");
2485 depth++;
2487 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2488 return False;
2490 return True;