r6369: update release notes
[Samba.git] / source / rpc_parse / parse_lsa.c
blobab3d3fcfe819cc7ba6ecd1368ab869c00618f33b
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 * Copyright (C) Gerald )Jerry) Carter 2005
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "includes.h"
28 #undef DBGC_CLASS
29 #define DBGC_CLASS DBGC_RPC_PARSE
31 static BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn, prs_struct *ps, int depth);
33 /*******************************************************************
34 Inits a LSA_TRANS_NAME structure.
35 ********************************************************************/
37 void init_lsa_trans_name(LSA_TRANS_NAME *trn, UNISTR2 *uni_name,
38 uint16 sid_name_use, const char *name, uint32 idx)
40 trn->sid_name_use = sid_name_use;
41 init_unistr2(uni_name, name, UNI_FLAGS_NONE);
42 init_uni_hdr(&trn->hdr_name, uni_name);
43 trn->domain_idx = idx;
46 /*******************************************************************
47 Reads or writes a LSA_TRANS_NAME structure.
48 ********************************************************************/
50 static BOOL lsa_io_trans_name(const char *desc, LSA_TRANS_NAME *trn, prs_struct *ps,
51 int depth)
53 prs_debug(ps, depth, desc, "lsa_io_trans_name");
54 depth++;
56 if(!prs_align(ps))
57 return False;
59 if(!prs_uint16("sid_name_use", ps, depth, &trn->sid_name_use))
60 return False;
61 if(!prs_align(ps))
62 return False;
64 if(!smb_io_unihdr ("hdr_name", &trn->hdr_name, ps, depth))
65 return False;
66 if(!prs_uint32("domain_idx ", ps, depth, &trn->domain_idx))
67 return False;
69 return True;
72 /*******************************************************************
73 Reads or writes a DOM_R_REF structure.
74 ********************************************************************/
76 static BOOL lsa_io_dom_r_ref(const char *desc, DOM_R_REF *r_r, prs_struct *ps,
77 int depth)
79 unsigned int i;
81 prs_debug(ps, depth, desc, "lsa_io_dom_r_ref");
82 depth++;
84 if(!prs_align(ps))
85 return False;
87 if(!prs_uint32("num_ref_doms_1", ps, depth, &r_r->num_ref_doms_1)) /* num referenced domains? */
88 return False;
89 if(!prs_uint32("ptr_ref_dom ", ps, depth, &r_r->ptr_ref_dom)) /* undocumented buffer pointer. */
90 return False;
91 if(!prs_uint32("max_entries ", ps, depth, &r_r->max_entries)) /* 32 - max number of entries */
92 return False;
94 SMB_ASSERT_ARRAY(r_r->hdr_ref_dom, r_r->num_ref_doms_1);
96 if (r_r->ptr_ref_dom != 0) {
98 if(!prs_uint32("num_ref_doms_2", ps, depth, &r_r->num_ref_doms_2)) /* 4 - num referenced domains? */
99 return False;
101 SMB_ASSERT_ARRAY(r_r->ref_dom, r_r->num_ref_doms_2);
103 for (i = 0; i < r_r->num_ref_doms_1; i++) {
104 fstring t;
106 slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
107 if(!smb_io_unihdr(t, &r_r->hdr_ref_dom[i].hdr_dom_name, ps, depth))
108 return False;
110 slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i);
111 if(!prs_uint32(t, ps, depth, &r_r->hdr_ref_dom[i].ptr_dom_sid))
112 return False;
115 for (i = 0; i < r_r->num_ref_doms_2; i++) {
116 fstring t;
118 if (r_r->hdr_ref_dom[i].hdr_dom_name.buffer != 0) {
119 slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
120 if(!smb_io_unistr2(t, &r_r->ref_dom[i].uni_dom_name, True, ps, depth)) /* domain name unicode string */
121 return False;
122 if(!prs_align(ps))
123 return False;
126 if (r_r->hdr_ref_dom[i].ptr_dom_sid != 0) {
127 slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i);
128 if(!smb_io_dom_sid2(t, &r_r->ref_dom[i].ref_dom, ps, depth)) /* referenced domain SIDs */
129 return False;
134 return True;
137 /*******************************************************************
138 Inits an LSA_SEC_QOS structure.
139 ********************************************************************/
141 void init_lsa_sec_qos(LSA_SEC_QOS *qos, uint16 imp_lev, uint8 ctxt, uint8 eff)
143 DEBUG(5, ("init_lsa_sec_qos\n"));
145 qos->len = 0x0c; /* length of quality of service block, in bytes */
146 qos->sec_imp_level = imp_lev;
147 qos->sec_ctxt_mode = ctxt;
148 qos->effective_only = eff;
151 /*******************************************************************
152 Reads or writes an LSA_SEC_QOS structure.
153 ********************************************************************/
155 static BOOL lsa_io_sec_qos(const char *desc, LSA_SEC_QOS *qos, prs_struct *ps,
156 int depth)
158 uint32 start;
160 prs_debug(ps, depth, desc, "lsa_io_obj_qos");
161 depth++;
163 if(!prs_align(ps))
164 return False;
166 start = prs_offset(ps);
168 /* these pointers had _better_ be zero, because we don't know
169 what they point to!
171 if(!prs_uint32("len ", ps, depth, &qos->len)) /* 0x18 - length (in bytes) inc. the length field. */
172 return False;
173 if(!prs_uint16("sec_imp_level ", ps, depth, &qos->sec_imp_level ))
174 return False;
175 if(!prs_uint8 ("sec_ctxt_mode ", ps, depth, &qos->sec_ctxt_mode ))
176 return False;
177 if(!prs_uint8 ("effective_only", ps, depth, &qos->effective_only))
178 return False;
180 if (qos->len != prs_offset(ps) - start) {
181 DEBUG(3,("lsa_io_sec_qos: length %x does not match size %x\n",
182 qos->len, prs_offset(ps) - start));
185 return True;
188 /*******************************************************************
189 Inits an LSA_OBJ_ATTR structure.
190 ********************************************************************/
192 static void init_lsa_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, LSA_SEC_QOS *qos)
194 DEBUG(5, ("init_lsa_obj_attr\n"));
196 attr->len = 0x18; /* length of object attribute block, in bytes */
197 attr->ptr_root_dir = 0;
198 attr->ptr_obj_name = 0;
199 attr->attributes = attributes;
200 attr->ptr_sec_desc = 0;
202 if (qos != NULL) {
203 attr->ptr_sec_qos = 1;
204 attr->sec_qos = qos;
205 } else {
206 attr->ptr_sec_qos = 0;
207 attr->sec_qos = NULL;
211 /*******************************************************************
212 Reads or writes an LSA_OBJ_ATTR structure.
213 ********************************************************************/
215 static BOOL lsa_io_obj_attr(const char *desc, LSA_OBJ_ATTR *attr, prs_struct *ps,
216 int depth)
218 prs_debug(ps, depth, desc, "lsa_io_obj_attr");
219 depth++;
221 if(!prs_align(ps))
222 return False;
224 /* these pointers had _better_ be zero, because we don't know
225 what they point to!
227 if(!prs_uint32("len ", ps, depth, &attr->len)) /* 0x18 - length (in bytes) inc. the length field. */
228 return False;
229 if(!prs_uint32("ptr_root_dir", ps, depth, &attr->ptr_root_dir)) /* 0 - root directory (pointer) */
230 return False;
231 if(!prs_uint32("ptr_obj_name", ps, depth, &attr->ptr_obj_name)) /* 0 - object name (pointer) */
232 return False;
233 if(!prs_uint32("attributes ", ps, depth, &attr->attributes)) /* 0 - attributes (undocumented) */
234 return False;
235 if(!prs_uint32("ptr_sec_desc", ps, depth, &attr->ptr_sec_desc)) /* 0 - security descriptior (pointer) */
236 return False;
237 if(!prs_uint32("ptr_sec_qos ", ps, depth, &attr->ptr_sec_qos )) /* security quality of service (pointer) */
238 return False;
240 if (attr->ptr_sec_qos != 0) {
241 if (UNMARSHALLING(ps))
242 if (!(attr->sec_qos = PRS_ALLOC_MEM(ps,LSA_SEC_QOS,1)))
243 return False;
245 if(!lsa_io_sec_qos("sec_qos", attr->sec_qos, ps, depth))
246 return False;
249 return True;
253 /*******************************************************************
254 Inits an LSA_Q_OPEN_POL structure.
255 ********************************************************************/
257 void init_q_open_pol(LSA_Q_OPEN_POL *r_q, uint16 system_name,
258 uint32 attributes, uint32 desired_access,
259 LSA_SEC_QOS *qos)
261 DEBUG(5, ("init_open_pol: attr:%d da:%d\n", attributes,
262 desired_access));
264 r_q->ptr = 1; /* undocumented pointer */
266 r_q->des_access = desired_access;
268 r_q->system_name = system_name;
269 init_lsa_obj_attr(&r_q->attr, attributes, qos);
272 /*******************************************************************
273 Reads or writes an LSA_Q_OPEN_POL structure.
274 ********************************************************************/
276 BOOL lsa_io_q_open_pol(const char *desc, LSA_Q_OPEN_POL *r_q, prs_struct *ps,
277 int depth)
279 prs_debug(ps, depth, desc, "lsa_io_q_open_pol");
280 depth++;
282 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
283 return False;
284 if(!prs_uint16("system_name", ps, depth, &r_q->system_name))
285 return False;
286 if(!prs_align( ps ))
287 return False;
289 if(!lsa_io_obj_attr("", &r_q->attr, ps, depth))
290 return False;
292 if(!prs_uint32("des_access", ps, depth, &r_q->des_access))
293 return False;
295 return True;
298 /*******************************************************************
299 Reads or writes an LSA_R_OPEN_POL structure.
300 ********************************************************************/
302 BOOL lsa_io_r_open_pol(const char *desc, LSA_R_OPEN_POL *r_p, prs_struct *ps,
303 int depth)
305 prs_debug(ps, depth, desc, "lsa_io_r_open_pol");
306 depth++;
308 if(!smb_io_pol_hnd("", &r_p->pol, ps, depth))
309 return False;
311 if(!prs_ntstatus("status", ps, depth, &r_p->status))
312 return False;
314 return True;
317 /*******************************************************************
318 Inits an LSA_Q_OPEN_POL2 structure.
319 ********************************************************************/
321 void init_q_open_pol2(LSA_Q_OPEN_POL2 *r_q, const char *server_name,
322 uint32 attributes, uint32 desired_access,
323 LSA_SEC_QOS *qos)
325 DEBUG(5, ("init_q_open_pol2: attr:%d da:%d\n", attributes,
326 desired_access));
328 r_q->ptr = 1; /* undocumented pointer */
330 r_q->des_access = desired_access;
332 init_unistr2(&r_q->uni_server_name, server_name, UNI_STR_TERMINATE);
334 init_lsa_obj_attr(&r_q->attr, attributes, qos);
337 /*******************************************************************
338 Reads or writes an LSA_Q_OPEN_POL2 structure.
339 ********************************************************************/
341 BOOL lsa_io_q_open_pol2(const char *desc, LSA_Q_OPEN_POL2 *r_q, prs_struct *ps,
342 int depth)
344 prs_debug(ps, depth, desc, "lsa_io_q_open_pol2");
345 depth++;
347 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
348 return False;
350 if(!smb_io_unistr2 ("", &r_q->uni_server_name, r_q->ptr, ps, depth))
351 return False;
352 if(!lsa_io_obj_attr("", &r_q->attr, ps, depth))
353 return False;
355 if(!prs_uint32("des_access", ps, depth, &r_q->des_access))
356 return False;
358 return True;
361 /*******************************************************************
362 Reads or writes an LSA_R_OPEN_POL2 structure.
363 ********************************************************************/
365 BOOL lsa_io_r_open_pol2(const char *desc, LSA_R_OPEN_POL2 *r_p, prs_struct *ps,
366 int depth)
368 prs_debug(ps, depth, desc, "lsa_io_r_open_pol2");
369 depth++;
371 if(!smb_io_pol_hnd("", &r_p->pol, ps, depth))
372 return False;
374 if(!prs_ntstatus("status", ps, depth, &r_p->status))
375 return False;
377 return True;
380 /*******************************************************************
381 makes an LSA_Q_QUERY_SEC_OBJ structure.
382 ********************************************************************/
384 void init_q_query_sec_obj(LSA_Q_QUERY_SEC_OBJ *q_q, const POLICY_HND *hnd,
385 uint32 sec_info)
387 DEBUG(5, ("init_q_query_sec_obj\n"));
389 q_q->pol = *hnd;
390 q_q->sec_info = sec_info;
392 return;
395 /*******************************************************************
396 Reads or writes an LSA_Q_QUERY_SEC_OBJ structure.
397 ********************************************************************/
399 BOOL lsa_io_q_query_sec_obj(const char *desc, LSA_Q_QUERY_SEC_OBJ *q_q,
400 prs_struct *ps, int depth)
402 prs_debug(ps, depth, desc, "lsa_io_q_query_sec_obj");
403 depth++;
405 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
406 return False;
408 if (!prs_uint32("sec_info", ps, depth, &q_q->sec_info))
409 return False;
411 return True;
414 /*******************************************************************
415 Reads or writes a LSA_R_QUERY_SEC_OBJ structure.
416 ********************************************************************/
418 BOOL lsa_io_r_query_sec_obj(const char *desc, LSA_R_QUERY_SEC_OBJ *r_u,
419 prs_struct *ps, int depth)
421 prs_debug(ps, depth, desc, "lsa_io_r_query_sec_obj");
422 depth++;
424 if (!prs_align(ps))
425 return False;
427 if (!prs_uint32("ptr", ps, depth, &r_u->ptr))
428 return False;
430 if (r_u->ptr != 0) {
431 if (!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
432 return False;
435 if (!prs_ntstatus("status", ps, depth, &r_u->status))
436 return False;
438 return True;
441 /*******************************************************************
442 Inits an LSA_Q_QUERY_INFO structure.
443 ********************************************************************/
445 void init_q_query(LSA_Q_QUERY_INFO *q_q, POLICY_HND *hnd, uint16 info_class)
447 DEBUG(5, ("init_q_query\n"));
449 memcpy(&q_q->pol, hnd, sizeof(q_q->pol));
451 q_q->info_class = info_class;
454 /*******************************************************************
455 Reads or writes an LSA_Q_QUERY_INFO structure.
456 ********************************************************************/
458 BOOL lsa_io_q_query(const char *desc, LSA_Q_QUERY_INFO *q_q, prs_struct *ps,
459 int depth)
461 prs_debug(ps, depth, desc, "lsa_io_q_query");
462 depth++;
464 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
465 return False;
467 if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
468 return False;
470 return True;
473 /*******************************************************************
474 makes an LSA_Q_ENUM_TRUST_DOM structure.
475 ********************************************************************/
476 BOOL init_q_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM * q_e, POLICY_HND *pol,
477 uint32 enum_context, uint32 preferred_len)
479 DEBUG(5, ("init_q_enum_trust_dom\n"));
481 q_e->pol = *pol;
482 q_e->enum_context = enum_context;
483 q_e->preferred_len = preferred_len;
485 return True;
488 /*******************************************************************
489 Reads or writes an LSA_Q_ENUM_TRUST_DOM structure.
490 ********************************************************************/
492 BOOL lsa_io_q_enum_trust_dom(const char *desc, LSA_Q_ENUM_TRUST_DOM *q_e,
493 prs_struct *ps, int depth)
495 prs_debug(ps, depth, desc, "lsa_io_q_enum_trust_dom");
496 depth++;
498 if(!smb_io_pol_hnd("", &q_e->pol, ps, depth))
499 return False;
501 if(!prs_uint32("enum_context ", ps, depth, &q_e->enum_context))
502 return False;
503 if(!prs_uint32("preferred_len", ps, depth, &q_e->preferred_len))
504 return False;
506 return True;
509 /*******************************************************************
510 Inits an LSA_R_ENUM_TRUST_DOM structure.
511 ********************************************************************/
513 void init_r_enum_trust_dom(TALLOC_CTX *ctx, LSA_R_ENUM_TRUST_DOM *r_e, uint32 enum_context,
514 uint32 req_num_domains, uint32 num_domains, TRUSTDOM **td)
516 unsigned int i;
518 DEBUG(5, ("init_r_enum_trust_dom\n"));
520 r_e->enum_context = enum_context;
521 r_e->count = num_domains;
523 if ( num_domains != 0 ) {
525 /* allocate container memory */
527 r_e->domlist = TALLOC_P( ctx, DOMAIN_LIST );
528 r_e->domlist->domains = TALLOC_ARRAY( ctx, DOMAIN_INFO, r_e->count );
530 if ( !r_e->domlist || !r_e->domlist->domains ) {
531 r_e->status = NT_STATUS_NO_MEMORY;
532 return;
535 r_e->domlist->count = r_e->count;
537 /* initialize the list of domains and their sid */
539 for (i = 0; i < num_domains; i++) {
540 if ( !(r_e->domlist->domains[i].sid = TALLOC_P(ctx, DOM_SID2)) ) {
541 r_e->status = NT_STATUS_NO_MEMORY;
542 return;
545 init_dom_sid2(r_e->domlist->domains[i].sid, &(td[i])->sid);
546 init_unistr4_w(ctx, &r_e->domlist->domains[i].name, (td[i])->name);
552 /*******************************************************************
553 ********************************************************************/
555 BOOL lsa_io_domain_list( const char *desc, prs_struct *ps, int depth, DOMAIN_LIST *domlist )
557 int i;
559 prs_debug(ps, depth, desc, "lsa_io_domain_list");
560 depth++;
562 if(!prs_uint32("count", ps, depth, &domlist->count))
563 return False;
565 if ( domlist->count == 0 )
566 return True;
568 if ( UNMARSHALLING(ps) ) {
569 if ( !(domlist->domains = PRS_ALLOC_MEM( ps, DOMAIN_INFO, domlist->count )) )
570 return False;
573 /* headers */
575 for ( i=0; i<domlist->count; i++ ) {
576 if ( !prs_unistr4_hdr("name_header", ps, depth, &domlist->domains[i].name) )
577 return False;
578 if ( !smb_io_dom_sid2_p("sid_header", ps, depth, &domlist->domains[i].sid) )
579 return False;
582 /* data */
584 for ( i=0; i<domlist->count; i++ ) {
585 if ( !prs_unistr4_str("name", ps, depth, &domlist->domains[i].name) )
586 return False;
587 if( !smb_io_dom_sid2("sid", domlist->domains[i].sid, ps, depth) )
588 return False;
591 return True;
594 /*******************************************************************
595 Reads or writes an LSA_R_ENUM_TRUST_DOM structure.
596 ********************************************************************/
598 BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *r_e,
599 prs_struct *ps, int depth)
601 prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom");
602 depth++;
604 if(!prs_uint32("enum_context", ps, depth, &r_e->enum_context))
605 return False;
607 if(!prs_uint32("count", ps, depth, &r_e->count))
608 return False;
610 if ( !prs_pointer("trusted_domains", ps, depth, (void**)&r_e->domlist, sizeof(DOMAIN_LIST), (PRS_POINTER_CAST)lsa_io_domain_list))
611 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 = 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;
932 if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */
933 return False;
934 if(!prs_align(ps))
935 return False;
937 if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count))
938 return False;
940 return True;
943 /*******************************************************************
944 Reads or writes a structure.
945 ********************************************************************/
947 static BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn,
948 prs_struct *ps, int depth)
950 unsigned int i;
952 prs_debug(ps, depth, desc, "lsa_io_trans_names");
953 depth++;
955 if(!prs_align(ps))
956 return False;
958 if(!prs_uint32("num_entries ", ps, depth, &trn->num_entries))
959 return False;
960 if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names))
961 return False;
963 if (trn->ptr_trans_names != 0) {
964 if(!prs_uint32("num_entries2 ", ps, depth,
965 &trn->num_entries2))
966 return False;
968 if (UNMARSHALLING(ps)) {
969 if ((trn->name = PRS_ALLOC_MEM(ps, LSA_TRANS_NAME, trn->num_entries)) == NULL) {
970 return False;
973 if ((trn->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, trn->num_entries)) == NULL) {
974 return False;
978 for (i = 0; i < trn->num_entries2; i++) {
979 fstring t;
980 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
982 if(!lsa_io_trans_name(t, &trn->name[i], ps, depth)) /* translated name */
983 return False;
986 for (i = 0; i < trn->num_entries2; i++) {
987 fstring t;
988 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
990 if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth))
991 return False;
992 if(!prs_align(ps))
993 return False;
997 return True;
1000 /*******************************************************************
1001 Reads or writes a structure.
1002 ********************************************************************/
1004 BOOL lsa_io_r_lookup_sids(const char *desc, LSA_R_LOOKUP_SIDS *r_s,
1005 prs_struct *ps, int depth)
1007 prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids");
1008 depth++;
1010 if(!prs_align(ps))
1011 return False;
1013 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref))
1014 return False;
1016 if (r_s->ptr_dom_ref != 0)
1017 if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */
1018 return False;
1020 if(!lsa_io_trans_names("names ", r_s->names, ps, depth)) /* translated names */
1021 return False;
1023 if(!prs_align(ps))
1024 return False;
1026 if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count))
1027 return False;
1029 if(!prs_ntstatus("status ", ps, depth, &r_s->status))
1030 return False;
1032 return True;
1035 /*******************************************************************
1036 makes a structure.
1037 ********************************************************************/
1039 void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l,
1040 POLICY_HND *hnd, int num_names, const char **names)
1042 unsigned int i;
1044 DEBUG(5, ("init_q_lookup_names\n"));
1046 ZERO_STRUCTP(q_l);
1048 q_l->pol = *hnd;
1049 q_l->num_entries = num_names;
1050 q_l->num_entries2 = num_names;
1051 q_l->lookup_level = 1;
1053 if ((q_l->uni_name = TALLOC_ZERO_ARRAY(mem_ctx, UNISTR2, num_names)) == NULL) {
1054 DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1055 return;
1058 if ((q_l->hdr_name = TALLOC_ZERO_ARRAY(mem_ctx, UNIHDR, num_names)) == NULL) {
1059 DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1060 return;
1063 for (i = 0; i < num_names; i++) {
1064 init_unistr2(&q_l->uni_name[i], names[i], UNI_FLAGS_NONE);
1065 init_uni_hdr(&q_l->hdr_name[i], &q_l->uni_name[i]);
1069 /*******************************************************************
1070 reads or writes a structure.
1071 ********************************************************************/
1073 BOOL lsa_io_q_lookup_names(const char *desc, LSA_Q_LOOKUP_NAMES *q_r,
1074 prs_struct *ps, int depth)
1076 unsigned int i;
1078 prs_debug(ps, depth, desc, "lsa_io_q_lookup_names");
1079 depth++;
1081 if(!prs_align(ps))
1082 return False;
1084 if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */
1085 return False;
1087 if(!prs_align(ps))
1088 return False;
1089 if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries))
1090 return False;
1091 if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2))
1092 return False;
1094 if (UNMARSHALLING(ps)) {
1095 if (q_r->num_entries) {
1096 if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)
1097 return False;
1098 if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)
1099 return False;
1103 for (i = 0; i < q_r->num_entries; i++) {
1104 if(!prs_align(ps))
1105 return False;
1106 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1107 return False;
1110 for (i = 0; i < q_r->num_entries; i++) {
1111 if(!prs_align(ps))
1112 return False;
1113 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1114 return False;
1117 if(!prs_align(ps))
1118 return False;
1119 if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1120 return False;
1121 if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1122 return False;
1123 if(!prs_uint32("lookup_level ", ps, depth, &q_r->lookup_level))
1124 return False;
1125 if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count))
1126 return False;
1128 return True;
1131 /*******************************************************************
1132 reads or writes a structure.
1133 ********************************************************************/
1135 BOOL lsa_io_r_lookup_names(const char *desc, LSA_R_LOOKUP_NAMES *r_r,
1136 prs_struct *ps, int depth)
1138 unsigned int i;
1140 prs_debug(ps, depth, desc, "lsa_io_r_lookup_names");
1141 depth++;
1143 if(!prs_align(ps))
1144 return False;
1146 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_r->ptr_dom_ref))
1147 return False;
1149 if (r_r->ptr_dom_ref != 0)
1150 if(!lsa_io_dom_r_ref("", r_r->dom_ref, ps, depth))
1151 return False;
1153 if(!prs_uint32("num_entries", ps, depth, &r_r->num_entries))
1154 return False;
1155 if(!prs_uint32("ptr_entries", ps, depth, &r_r->ptr_entries))
1156 return False;
1158 if (r_r->ptr_entries != 0) {
1159 if(!prs_uint32("num_entries2", ps, depth, &r_r->num_entries2))
1160 return False;
1162 if (r_r->num_entries2 != r_r->num_entries) {
1163 /* RPC fault */
1164 return False;
1167 if (UNMARSHALLING(ps)) {
1168 if ((r_r->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID2, r_r->num_entries2))
1169 == NULL) {
1170 DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n"));
1171 return False;
1175 for (i = 0; i < r_r->num_entries2; i++)
1176 if(!smb_io_dom_rid2("", &r_r->dom_rid[i], ps, depth)) /* domain RIDs being looked up */
1177 return False;
1180 if(!prs_uint32("mapped_count", ps, depth, &r_r->mapped_count))
1181 return False;
1183 if(!prs_ntstatus("status ", ps, depth, &r_r->status))
1184 return False;
1186 return True;
1190 /*******************************************************************
1191 Inits an LSA_Q_CLOSE structure.
1192 ********************************************************************/
1194 void init_lsa_q_close(LSA_Q_CLOSE *q_c, POLICY_HND *hnd)
1196 DEBUG(5, ("init_lsa_q_close\n"));
1198 memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
1201 /*******************************************************************
1202 Reads or writes an LSA_Q_CLOSE structure.
1203 ********************************************************************/
1205 BOOL lsa_io_q_close(const char *desc, LSA_Q_CLOSE *q_c, prs_struct *ps, int depth)
1207 prs_debug(ps, depth, desc, "lsa_io_q_close");
1208 depth++;
1210 if(!smb_io_pol_hnd("", &q_c->pol, ps, depth))
1211 return False;
1213 return True;
1216 /*******************************************************************
1217 Reads or writes an LSA_R_CLOSE structure.
1218 ********************************************************************/
1220 BOOL lsa_io_r_close(const char *desc, LSA_R_CLOSE *r_c, prs_struct *ps, int depth)
1222 prs_debug(ps, depth, desc, "lsa_io_r_close");
1223 depth++;
1225 if(!smb_io_pol_hnd("", &r_c->pol, ps, depth))
1226 return False;
1228 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1229 return False;
1231 return True;
1234 /*******************************************************************
1235 Reads or writes an LSA_Q_OPEN_SECRET structure.
1236 ********************************************************************/
1238 BOOL lsa_io_q_open_secret(const char *desc, LSA_Q_OPEN_SECRET *q_c, prs_struct *ps, int depth)
1240 prs_debug(ps, depth, desc, "lsa_io_q_open_secret");
1241 depth++;
1243 /* Don't bother to read or write at present... */
1244 return True;
1247 /*******************************************************************
1248 Reads or writes an LSA_R_OPEN_SECRET structure.
1249 ********************************************************************/
1251 BOOL lsa_io_r_open_secret(const char *desc, LSA_R_OPEN_SECRET *r_c, prs_struct *ps, int depth)
1253 prs_debug(ps, depth, desc, "lsa_io_r_open_secret");
1254 depth++;
1256 if(!prs_align(ps))
1257 return False;
1259 if(!prs_uint32("dummy1", ps, depth, &r_c->dummy1))
1260 return False;
1261 if(!prs_uint32("dummy2", ps, depth, &r_c->dummy2))
1262 return False;
1263 if(!prs_uint32("dummy3", ps, depth, &r_c->dummy3))
1264 return False;
1265 if(!prs_uint32("dummy4", ps, depth, &r_c->dummy4))
1266 return False;
1267 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1268 return False;
1270 return True;
1273 /*******************************************************************
1274 Inits an LSA_Q_ENUM_PRIVS structure.
1275 ********************************************************************/
1277 void init_q_enum_privs(LSA_Q_ENUM_PRIVS *q_q, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1279 DEBUG(5, ("init_q_enum_privs\n"));
1281 memcpy(&q_q->pol, hnd, sizeof(q_q->pol));
1283 q_q->enum_context = enum_context;
1284 q_q->pref_max_length = pref_max_length;
1287 /*******************************************************************
1288 reads or writes a structure.
1289 ********************************************************************/
1290 BOOL lsa_io_q_enum_privs(const char *desc, LSA_Q_ENUM_PRIVS *q_q, prs_struct *ps, int depth)
1292 if (q_q == NULL)
1293 return False;
1295 prs_debug(ps, depth, desc, "lsa_io_q_enum_privs");
1296 depth++;
1298 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1299 return False;
1301 if(!prs_uint32("enum_context ", ps, depth, &q_q->enum_context))
1302 return False;
1303 if(!prs_uint32("pref_max_length", ps, depth, &q_q->pref_max_length))
1304 return False;
1306 return True;
1309 /*******************************************************************
1310 reads or writes a structure.
1311 ********************************************************************/
1312 static BOOL lsa_io_priv_entries(const char *desc, LSA_PRIV_ENTRY *entries, uint32 count, prs_struct *ps, int depth)
1314 uint32 i;
1316 if (entries == NULL)
1317 return False;
1319 prs_debug(ps, depth, desc, "lsa_io_priv_entries");
1320 depth++;
1322 if(!prs_align(ps))
1323 return False;
1325 for (i = 0; i < count; i++) {
1326 if (!smb_io_unihdr("", &entries[i].hdr_name, ps, depth))
1327 return False;
1328 if(!prs_uint32("luid_low ", ps, depth, &entries[i].luid_low))
1329 return False;
1330 if(!prs_uint32("luid_high", ps, depth, &entries[i].luid_high))
1331 return False;
1334 for (i = 0; i < count; i++)
1335 if (!smb_io_unistr2("", &entries[i].name, entries[i].hdr_name.buffer, ps, depth))
1336 return False;
1338 return True;
1341 /*******************************************************************
1342 Inits an LSA_R_ENUM_PRIVS structure.
1343 ********************************************************************/
1345 void init_lsa_r_enum_privs(LSA_R_ENUM_PRIVS *r_u, uint32 enum_context,
1346 uint32 count, LSA_PRIV_ENTRY *entries)
1348 DEBUG(5, ("init_lsa_r_enum_privs\n"));
1350 r_u->enum_context=enum_context;
1351 r_u->count=count;
1353 if (entries!=NULL) {
1354 r_u->ptr=1;
1355 r_u->count1=count;
1356 r_u->privs=entries;
1357 } else {
1358 r_u->ptr=0;
1359 r_u->count1=0;
1360 r_u->privs=NULL;
1364 /*******************************************************************
1365 reads or writes a structure.
1366 ********************************************************************/
1367 BOOL lsa_io_r_enum_privs(const char *desc, LSA_R_ENUM_PRIVS *r_q, prs_struct *ps, int depth)
1369 if (r_q == NULL)
1370 return False;
1372 prs_debug(ps, depth, desc, "lsa_io_r_enum_privs");
1373 depth++;
1375 if(!prs_align(ps))
1376 return False;
1378 if(!prs_uint32("enum_context", ps, depth, &r_q->enum_context))
1379 return False;
1380 if(!prs_uint32("count", ps, depth, &r_q->count))
1381 return False;
1382 if(!prs_uint32("ptr", ps, depth, &r_q->ptr))
1383 return False;
1385 if (r_q->ptr) {
1386 if(!prs_uint32("count1", ps, depth, &r_q->count1))
1387 return False;
1389 if (UNMARSHALLING(ps))
1390 if (!(r_q->privs = PRS_ALLOC_MEM(ps, LSA_PRIV_ENTRY, r_q->count1)))
1391 return False;
1393 if (!lsa_io_priv_entries("", r_q->privs, r_q->count1, ps, depth))
1394 return False;
1397 if(!prs_align(ps))
1398 return False;
1400 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1401 return False;
1403 return True;
1406 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)
1408 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1410 init_unistr2(&trn->name, name, UNI_FLAGS_NONE);
1411 init_uni_hdr(&trn->hdr_name, &trn->name);
1412 trn->lang_id = lang_id;
1413 trn->lang_id_sys = lang_id_sys;
1416 /*******************************************************************
1417 reads or writes a structure.
1418 ********************************************************************/
1419 BOOL lsa_io_q_priv_get_dispname(const char *desc, LSA_Q_PRIV_GET_DISPNAME *q_q, prs_struct *ps, int depth)
1421 if (q_q == NULL)
1422 return False;
1424 prs_debug(ps, depth, desc, "lsa_io_q_priv_get_dispname");
1425 depth++;
1427 if(!prs_align(ps))
1428 return False;
1430 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1431 return False;
1433 if (!smb_io_unihdr("hdr_name", &q_q->hdr_name, ps, depth))
1434 return False;
1436 if (!smb_io_unistr2("name", &q_q->name, q_q->hdr_name.buffer, ps, depth))
1437 return False;
1439 if(!prs_uint16("lang_id ", ps, depth, &q_q->lang_id))
1440 return False;
1441 if(!prs_uint16("lang_id_sys", ps, depth, &q_q->lang_id_sys))
1442 return False;
1444 return True;
1447 /*******************************************************************
1448 reads or writes a structure.
1449 ********************************************************************/
1450 BOOL lsa_io_r_priv_get_dispname(const char *desc, LSA_R_PRIV_GET_DISPNAME *r_q, prs_struct *ps, int depth)
1452 if (r_q == NULL)
1453 return False;
1455 prs_debug(ps, depth, desc, "lsa_io_r_priv_get_dispname");
1456 depth++;
1458 if (!prs_align(ps))
1459 return False;
1461 if (!prs_uint32("ptr_info", ps, depth, &r_q->ptr_info))
1462 return False;
1464 if (r_q->ptr_info){
1465 if (!smb_io_unihdr("hdr_name", &r_q->hdr_desc, ps, depth))
1466 return False;
1468 if (!smb_io_unistr2("desc", &r_q->desc, r_q->hdr_desc.buffer, ps, depth))
1469 return False;
1472 if(!prs_align(ps))
1473 return False;
1475 if(!prs_uint16("lang_id", ps, depth, &r_q->lang_id))
1476 return False;
1478 if(!prs_align(ps))
1479 return False;
1480 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1481 return False;
1483 return True;
1487 initialise a LSA_Q_ENUM_ACCOUNTS structure
1489 void init_lsa_q_enum_accounts(LSA_Q_ENUM_ACCOUNTS *trn, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1491 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1493 trn->enum_context = enum_context;
1494 trn->pref_max_length = pref_max_length;
1497 /*******************************************************************
1498 reads or writes a structure.
1499 ********************************************************************/
1500 BOOL lsa_io_q_enum_accounts(const char *desc, LSA_Q_ENUM_ACCOUNTS *q_q, prs_struct *ps, int depth)
1502 if (q_q == NULL)
1503 return False;
1505 prs_debug(ps, depth, desc, "lsa_io_q_enum_accounts");
1506 depth++;
1508 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1509 return False;
1511 if(!prs_uint32("enum_context ", ps, depth, &q_q->enum_context))
1512 return False;
1513 if(!prs_uint32("pref_max_length", ps, depth, &q_q->pref_max_length))
1514 return False;
1516 return True;
1520 /*******************************************************************
1521 Inits an LSA_R_ENUM_PRIVS structure.
1522 ********************************************************************/
1524 void init_lsa_r_enum_accounts(LSA_R_ENUM_ACCOUNTS *r_u, uint32 enum_context)
1526 DEBUG(5, ("init_lsa_r_enum_accounts\n"));
1528 r_u->enum_context=enum_context;
1529 if (r_u->enum_context!=0) {
1530 r_u->sids.num_entries=enum_context;
1531 r_u->sids.ptr_sid_enum=1;
1532 r_u->sids.num_entries2=enum_context;
1533 } else {
1534 r_u->sids.num_entries=0;
1535 r_u->sids.ptr_sid_enum=0;
1536 r_u->sids.num_entries2=0;
1540 /*******************************************************************
1541 reads or writes a structure.
1542 ********************************************************************/
1543 BOOL lsa_io_r_enum_accounts(const char *desc, LSA_R_ENUM_ACCOUNTS *r_q, prs_struct *ps, int depth)
1545 if (r_q == NULL)
1546 return False;
1548 prs_debug(ps, depth, desc, "lsa_io_r_enum_accounts");
1549 depth++;
1551 if (!prs_align(ps))
1552 return False;
1554 if(!prs_uint32("enum_context", ps, depth, &r_q->enum_context))
1555 return False;
1557 if (!lsa_io_sid_enum("sids", &r_q->sids, ps, depth))
1558 return False;
1560 if (!prs_align(ps))
1561 return False;
1563 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1564 return False;
1566 return True;
1570 /*******************************************************************
1571 Reads or writes an LSA_Q_UNK_GET_CONNUSER structure.
1572 ********************************************************************/
1574 BOOL lsa_io_q_unk_get_connuser(const char *desc, LSA_Q_UNK_GET_CONNUSER *q_c, prs_struct *ps, int depth)
1576 prs_debug(ps, depth, desc, "lsa_io_q_unk_get_connuser");
1577 depth++;
1579 if(!prs_align(ps))
1580 return False;
1582 if(!prs_uint32("ptr_srvname", ps, depth, &q_c->ptr_srvname))
1583 return False;
1585 if(!smb_io_unistr2("uni2_srvname", &q_c->uni2_srvname, q_c->ptr_srvname, ps, depth)) /* server name to be looked up */
1586 return False;
1588 if (!prs_align(ps))
1589 return False;
1591 if(!prs_uint32("unk1", ps, depth, &q_c->unk1))
1592 return False;
1593 if(!prs_uint32("unk2", ps, depth, &q_c->unk2))
1594 return False;
1595 if(!prs_uint32("unk3", ps, depth, &q_c->unk3))
1596 return False;
1598 /* Don't bother to read or write at present... */
1599 return True;
1602 /*******************************************************************
1603 Reads or writes an LSA_R_UNK_GET_CONNUSER structure.
1604 ********************************************************************/
1606 BOOL lsa_io_r_unk_get_connuser(const char *desc, LSA_R_UNK_GET_CONNUSER *r_c, prs_struct *ps, int depth)
1608 prs_debug(ps, depth, desc, "lsa_io_r_unk_get_connuser");
1609 depth++;
1611 if(!prs_align(ps))
1612 return False;
1614 if(!prs_uint32("ptr_user_name", ps, depth, &r_c->ptr_user_name))
1615 return False;
1616 if(!smb_io_unihdr("hdr_user_name", &r_c->hdr_user_name, ps, depth))
1617 return False;
1618 if(!smb_io_unistr2("uni2_user_name", &r_c->uni2_user_name, r_c->ptr_user_name, ps, depth))
1619 return False;
1621 if (!prs_align(ps))
1622 return False;
1624 if(!prs_uint32("unk1", ps, depth, &r_c->unk1))
1625 return False;
1627 if(!prs_uint32("ptr_dom_name", ps, depth, &r_c->ptr_dom_name))
1628 return False;
1629 if(!smb_io_unihdr("hdr_dom_name", &r_c->hdr_dom_name, ps, depth))
1630 return False;
1631 if(!smb_io_unistr2("uni2_dom_name", &r_c->uni2_dom_name, r_c->ptr_dom_name, ps, depth))
1632 return False;
1634 if (!prs_align(ps))
1635 return False;
1637 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1638 return False;
1640 return True;
1643 void init_lsa_q_create_account(LSA_Q_CREATEACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1645 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1647 init_dom_sid2(&trn->sid, sid);
1648 trn->access = desired_access;
1652 /*******************************************************************
1653 Reads or writes an LSA_Q_CREATEACCOUNT structure.
1654 ********************************************************************/
1656 BOOL lsa_io_q_create_account(const char *desc, LSA_Q_CREATEACCOUNT *r_c, prs_struct *ps, int depth)
1658 prs_debug(ps, depth, desc, "lsa_io_q_create_account");
1659 depth++;
1661 if(!prs_align(ps))
1662 return False;
1664 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1665 return False;
1667 if(!smb_io_dom_sid2("sid", &r_c->sid, ps, depth)) /* domain SID */
1668 return False;
1670 if(!prs_uint32("access", ps, depth, &r_c->access))
1671 return False;
1673 return True;
1676 /*******************************************************************
1677 Reads or writes an LSA_R_CREATEACCOUNT structure.
1678 ********************************************************************/
1680 BOOL lsa_io_r_create_account(const char *desc, LSA_R_CREATEACCOUNT *r_c, prs_struct *ps, int depth)
1682 prs_debug(ps, depth, desc, "lsa_io_r_open_account");
1683 depth++;
1685 if(!prs_align(ps))
1686 return False;
1688 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1689 return False;
1691 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1692 return False;
1694 return True;
1698 void init_lsa_q_open_account(LSA_Q_OPENACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1700 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1702 init_dom_sid2(&trn->sid, sid);
1703 trn->access = desired_access;
1706 /*******************************************************************
1707 Reads or writes an LSA_Q_OPENACCOUNT structure.
1708 ********************************************************************/
1710 BOOL lsa_io_q_open_account(const char *desc, LSA_Q_OPENACCOUNT *r_c, prs_struct *ps, int depth)
1712 prs_debug(ps, depth, desc, "lsa_io_q_open_account");
1713 depth++;
1715 if(!prs_align(ps))
1716 return False;
1718 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1719 return False;
1721 if(!smb_io_dom_sid2("sid", &r_c->sid, ps, depth)) /* domain SID */
1722 return False;
1724 if(!prs_uint32("access", ps, depth, &r_c->access))
1725 return False;
1727 return True;
1730 /*******************************************************************
1731 Reads or writes an LSA_R_OPENACCOUNT structure.
1732 ********************************************************************/
1734 BOOL lsa_io_r_open_account(const char *desc, LSA_R_OPENACCOUNT *r_c, prs_struct *ps, int depth)
1736 prs_debug(ps, depth, desc, "lsa_io_r_open_account");
1737 depth++;
1739 if(!prs_align(ps))
1740 return False;
1742 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1743 return False;
1745 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1746 return False;
1748 return True;
1752 void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd)
1754 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1758 /*******************************************************************
1759 Reads or writes an LSA_Q_ENUMPRIVSACCOUNT structure.
1760 ********************************************************************/
1762 BOOL lsa_io_q_enum_privsaccount(const char *desc, LSA_Q_ENUMPRIVSACCOUNT *r_c, prs_struct *ps, int depth)
1764 prs_debug(ps, depth, desc, "lsa_io_q_enum_privsaccount");
1765 depth++;
1767 if(!prs_align(ps))
1768 return False;
1770 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1771 return False;
1773 return True;
1776 /*******************************************************************
1777 Reads or writes an LUID structure.
1778 ********************************************************************/
1780 static BOOL lsa_io_luid(const char *desc, LUID *r_c, prs_struct *ps, int depth)
1782 prs_debug(ps, depth, desc, "lsa_io_luid");
1783 depth++;
1785 if(!prs_align(ps))
1786 return False;
1788 if(!prs_uint32("low", ps, depth, &r_c->low))
1789 return False;
1791 if(!prs_uint32("high", ps, depth, &r_c->high))
1792 return False;
1794 return True;
1797 /*******************************************************************
1798 Reads or writes an LUID_ATTR structure.
1799 ********************************************************************/
1801 static BOOL lsa_io_luid_attr(const char *desc, LUID_ATTR *r_c, prs_struct *ps, int depth)
1803 prs_debug(ps, depth, desc, "lsa_io_luid_attr");
1804 depth++;
1806 if(!prs_align(ps))
1807 return False;
1809 if (!lsa_io_luid(desc, &r_c->luid, ps, depth))
1810 return False;
1812 if(!prs_uint32("attr", ps, depth, &r_c->attr))
1813 return False;
1815 return True;
1818 /*******************************************************************
1819 Reads or writes an PRIVILEGE_SET structure.
1820 ********************************************************************/
1822 static BOOL lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *r_c, prs_struct *ps, int depth)
1824 uint32 i;
1826 prs_debug(ps, depth, desc, "lsa_io_privilege_set");
1827 depth++;
1829 if(!prs_align(ps))
1830 return False;
1832 if(!prs_uint32("count", ps, depth, &r_c->count))
1833 return False;
1834 if(!prs_uint32("control", ps, depth, &r_c->control))
1835 return False;
1837 for (i=0; i<r_c->count; i++) {
1838 if (!lsa_io_luid_attr(desc, &r_c->set[i], ps, depth))
1839 return False;
1842 return True;
1845 NTSTATUS init_lsa_r_enum_privsaccount(TALLOC_CTX *mem_ctx, LSA_R_ENUMPRIVSACCOUNT *r_u, LUID_ATTR *set, uint32 count, uint32 control)
1847 NTSTATUS ret = NT_STATUS_OK;
1849 r_u->ptr = 1;
1850 r_u->count = count;
1852 if ( !NT_STATUS_IS_OK(ret = privilege_set_init_by_ctx(mem_ctx, &(r_u->set))) )
1853 return ret;
1855 r_u->set.count = count;
1857 if (!NT_STATUS_IS_OK(ret = dup_luid_attr(r_u->set.mem_ctx, &(r_u->set.set), set, count)))
1858 return ret;
1860 DEBUG(10,("init_lsa_r_enum_privsaccount: %d privileges\n", r_u->count));
1862 return ret;
1865 /*******************************************************************
1866 Reads or writes an LSA_R_ENUMPRIVSACCOUNT structure.
1867 ********************************************************************/
1869 BOOL lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *r_c, prs_struct *ps, int depth)
1871 prs_debug(ps, depth, desc, "lsa_io_r_enum_privsaccount");
1872 depth++;
1874 if(!prs_align(ps))
1875 return False;
1877 if(!prs_uint32("ptr", ps, depth, &r_c->ptr))
1878 return False;
1880 if (r_c->ptr!=0) {
1881 if(!prs_uint32("count", ps, depth, &r_c->count))
1882 return False;
1884 /* malloc memory if unmarshalling here */
1886 if (UNMARSHALLING(ps) && r_c->count != 0) {
1887 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(r_c->set))))
1888 return False;
1890 if (!(r_c->set.set = PRS_ALLOC_MEM(ps,LUID_ATTR,r_c->count)))
1891 return False;
1895 if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth))
1896 return False;
1899 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1900 return False;
1902 return True;
1907 /*******************************************************************
1908 Reads or writes an LSA_Q_GETSYSTEMACCOUNTstructure.
1909 ********************************************************************/
1911 BOOL lsa_io_q_getsystemaccount(const char *desc, LSA_Q_GETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1913 prs_debug(ps, depth, desc, "lsa_io_q_getsystemaccount");
1914 depth++;
1916 if(!prs_align(ps))
1917 return False;
1919 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1920 return False;
1922 return True;
1925 /*******************************************************************
1926 Reads or writes an LSA_R_GETSYSTEMACCOUNTstructure.
1927 ********************************************************************/
1929 BOOL lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1931 prs_debug(ps, depth, desc, "lsa_io_r_getsystemaccount");
1932 depth++;
1934 if(!prs_align(ps))
1935 return False;
1937 if(!prs_uint32("access", ps, depth, &r_c->access))
1938 return False;
1940 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1941 return False;
1943 return True;
1947 /*******************************************************************
1948 Reads or writes an LSA_Q_SETSYSTEMACCOUNT structure.
1949 ********************************************************************/
1951 BOOL lsa_io_q_setsystemaccount(const char *desc, LSA_Q_SETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1953 prs_debug(ps, depth, desc, "lsa_io_q_setsystemaccount");
1954 depth++;
1956 if(!prs_align(ps))
1957 return False;
1959 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1960 return False;
1962 if(!prs_uint32("access", ps, depth, &r_c->access))
1963 return False;
1965 return True;
1968 /*******************************************************************
1969 Reads or writes an LSA_R_SETSYSTEMACCOUNT structure.
1970 ********************************************************************/
1972 BOOL lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1974 prs_debug(ps, depth, desc, "lsa_io_r_setsystemaccount");
1975 depth++;
1977 if(!prs_align(ps))
1978 return False;
1980 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1981 return False;
1983 return True;
1987 static void init_lsa_string( LSA_STRING *uni, const char *string )
1989 init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE);
1990 init_uni_hdr(&uni->hdr, &uni->unistring);
1993 void init_lsa_q_lookup_priv_value(LSA_Q_LOOKUP_PRIV_VALUE *q_u, POLICY_HND *hnd, const char *name)
1995 memcpy(&q_u->pol, hnd, sizeof(q_u->pol));
1996 init_lsa_string( &q_u->privname, name );
1999 BOOL smb_io_lsa_string( const char *desc, LSA_STRING *string, prs_struct *ps, int depth )
2001 prs_debug(ps, depth, desc, "smb_io_lsa_string");
2002 depth++;
2004 if(!smb_io_unihdr ("hdr", &string->hdr, ps, depth))
2005 return False;
2006 if(!smb_io_unistr2("unistring", &string->unistring, string->hdr.buffer, ps, depth))
2007 return False;
2009 return True;
2012 /*******************************************************************
2013 Reads or writes an LSA_Q_LOOKUP_PRIV_VALUE structure.
2014 ********************************************************************/
2016 BOOL lsa_io_q_lookup_priv_value(const char *desc, LSA_Q_LOOKUP_PRIV_VALUE *r_c, prs_struct *ps, int depth)
2018 prs_debug(ps, depth, desc, "lsa_io_q_lookup_priv_value");
2019 depth++;
2021 if(!prs_align(ps))
2022 return False;
2024 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
2025 return False;
2026 if(!smb_io_lsa_string("privname", &r_c->privname, ps, depth))
2027 return False;
2029 return True;
2032 /*******************************************************************
2033 Reads or writes an LSA_R_LOOKUP_PRIV_VALUE structure.
2034 ********************************************************************/
2036 BOOL lsa_io_r_lookup_priv_value(const char *desc, LSA_R_LOOKUP_PRIV_VALUE *r_c, prs_struct *ps, int depth)
2038 prs_debug(ps, depth, desc, "lsa_io_r_lookup_priv_value");
2039 depth++;
2041 if(!prs_align(ps))
2042 return False;
2044 if(!lsa_io_luid("luid", &r_c->luid, ps, depth))
2045 return False;
2047 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2048 return False;
2050 return True;
2054 /*******************************************************************
2055 Reads or writes an LSA_Q_ADDPRIVS structure.
2056 ********************************************************************/
2058 BOOL lsa_io_q_addprivs(const char *desc, LSA_Q_ADDPRIVS *r_c, prs_struct *ps, int depth)
2060 prs_debug(ps, depth, desc, "lsa_io_q_addprivs");
2061 depth++;
2063 if(!prs_align(ps))
2064 return False;
2066 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
2067 return False;
2069 if(!prs_uint32("count", ps, depth, &r_c->count))
2070 return False;
2072 if (UNMARSHALLING(ps) && r_c->count!=0) {
2073 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(r_c->set))))
2074 return False;
2076 if (!(r_c->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, r_c->count)))
2077 return False;
2080 if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth))
2081 return False;
2083 return True;
2086 /*******************************************************************
2087 Reads or writes an LSA_R_ADDPRIVS structure.
2088 ********************************************************************/
2090 BOOL lsa_io_r_addprivs(const char *desc, LSA_R_ADDPRIVS *r_c, prs_struct *ps, int depth)
2092 prs_debug(ps, depth, desc, "lsa_io_r_addprivs");
2093 depth++;
2095 if(!prs_align(ps))
2096 return False;
2098 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2099 return False;
2101 return True;
2104 /*******************************************************************
2105 Reads or writes an LSA_Q_REMOVEPRIVS structure.
2106 ********************************************************************/
2108 BOOL lsa_io_q_removeprivs(const char *desc, LSA_Q_REMOVEPRIVS *r_c, prs_struct *ps, int depth)
2110 prs_debug(ps, depth, desc, "lsa_io_q_removeprivs");
2111 depth++;
2113 if(!prs_align(ps))
2114 return False;
2116 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
2117 return False;
2119 if(!prs_uint32("allrights", ps, depth, &r_c->allrights))
2120 return False;
2122 if(!prs_uint32("ptr", ps, depth, &r_c->ptr))
2123 return False;
2126 * JFM: I'm not sure at all if the count is inside the ptr
2127 * never seen one with ptr=0
2130 if (r_c->ptr!=0) {
2131 if(!prs_uint32("count", ps, depth, &r_c->count))
2132 return False;
2134 if (UNMARSHALLING(ps) && r_c->count!=0) {
2135 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(r_c->set))))
2136 return False;
2138 if (!(r_c->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, r_c->count)))
2139 return False;
2142 if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth))
2143 return False;
2146 return True;
2149 /*******************************************************************
2150 Reads or writes an LSA_R_REMOVEPRIVS structure.
2151 ********************************************************************/
2153 BOOL lsa_io_r_removeprivs(const char *desc, LSA_R_REMOVEPRIVS *r_c, prs_struct *ps, int depth)
2155 prs_debug(ps, depth, desc, "lsa_io_r_removeprivs");
2156 depth++;
2158 if(!prs_align(ps))
2159 return False;
2161 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2162 return False;
2164 return True;
2167 BOOL policy_handle_is_valid(const POLICY_HND *hnd)
2169 POLICY_HND zero_pol;
2171 ZERO_STRUCT(zero_pol);
2172 return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True );
2175 /*******************************************************************
2176 Reads or writes an LSA_DNS_DOM_INFO structure.
2177 ********************************************************************/
2179 BOOL lsa_io_dns_dom_info(const char *desc, LSA_DNS_DOM_INFO *info,
2180 prs_struct *ps, int depth)
2182 prs_debug(ps, depth, desc, "lsa_io_dns_dom_info");
2183 depth++;
2185 if(!prs_align(ps))
2186 return False;
2187 if(!smb_io_unihdr("nb_name", &info->hdr_nb_dom_name, ps, depth))
2188 return False;
2189 if(!smb_io_unihdr("dns_name", &info->hdr_dns_dom_name, ps, depth))
2190 return False;
2191 if(!smb_io_unihdr("forest", &info->hdr_forest_name, ps, depth))
2192 return False;
2194 if(!prs_align(ps))
2195 return False;
2196 if ( !smb_io_uuid("dom_guid", &info->dom_guid, ps, depth) )
2197 return False;
2199 if(!prs_align(ps))
2200 return False;
2201 if(!prs_uint32("dom_sid", ps, depth, &info->ptr_dom_sid))
2202 return False;
2204 if(!smb_io_unistr2("nb_name", &info->uni_nb_dom_name,
2205 info->hdr_nb_dom_name.buffer, ps, depth))
2206 return False;
2207 if(!smb_io_unistr2("dns_name", &info->uni_dns_dom_name,
2208 info->hdr_dns_dom_name.buffer, ps, depth))
2209 return False;
2210 if(!smb_io_unistr2("forest", &info->uni_forest_name,
2211 info->hdr_forest_name.buffer, ps, depth))
2212 return False;
2214 if(!smb_io_dom_sid2("dom_sid", &info->dom_sid, ps, depth))
2215 return False;
2217 return True;
2221 /*******************************************************************
2222 Inits an LSA_Q_QUERY_INFO2 structure.
2223 ********************************************************************/
2225 void init_q_query2(LSA_Q_QUERY_INFO2 *q_q, POLICY_HND *hnd, uint16 info_class)
2227 DEBUG(5, ("init_q_query2\n"));
2229 memcpy(&q_q->pol, hnd, sizeof(q_q->pol));
2231 q_q->info_class = info_class;
2234 /*******************************************************************
2235 Reads or writes an LSA_Q_QUERY_DNSDOMINFO structure.
2236 ********************************************************************/
2238 BOOL lsa_io_q_query_info2(const char *desc, LSA_Q_QUERY_INFO2 *q_c,
2239 prs_struct *ps, int depth)
2241 prs_debug(ps, depth, desc, "lsa_io_q_query_info2");
2242 depth++;
2244 if(!prs_align(ps))
2245 return False;
2247 if(!smb_io_pol_hnd("pol", &q_c->pol, ps, depth))
2248 return False;
2250 if(!prs_uint16("info_class", ps, depth, &q_c->info_class))
2251 return False;
2253 return True;
2256 /*******************************************************************
2257 Reads or writes an LSA_R_QUERY_DNSDOMINFO structure.
2258 ********************************************************************/
2260 BOOL lsa_io_r_query_info2(const char *desc, LSA_R_QUERY_INFO2 *r_c,
2261 prs_struct *ps, int depth)
2263 prs_debug(ps, depth, desc, "lsa_io_r_query_info2");
2264 depth++;
2266 if(!prs_align(ps))
2267 return False;
2269 if(!prs_uint32("ptr", ps, depth, &r_c->ptr))
2270 return False;
2271 if(!prs_uint16("info_class", ps, depth, &r_c->info_class))
2272 return False;
2273 switch(r_c->info_class) {
2274 case 0x000c:
2275 if (!lsa_io_dns_dom_info("info12", &r_c->info.dns_dom_info,
2276 ps, depth))
2277 return False;
2278 break;
2279 default:
2280 DEBUG(0,("lsa_io_r_query_info2: unknown info class %d\n",
2281 r_c->info_class));
2282 return False;
2285 if(!prs_align(ps))
2286 return False;
2287 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2288 return False;
2290 return True;
2293 /*******************************************************************
2294 Inits an LSA_Q_ENUM_ACCT_RIGHTS structure.
2295 ********************************************************************/
2296 void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS *q_q,
2297 POLICY_HND *hnd,
2298 uint32 count,
2299 DOM_SID *sid)
2301 DEBUG(5, ("init_q_enum_acct_rights\n"));
2303 q_q->pol = *hnd;
2304 init_dom_sid2(&q_q->sid, sid);
2307 /*******************************************************************
2308 ********************************************************************/
2309 NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *r_u, PRIVILEGE_SET *privileges )
2311 uint32 i;
2312 char *privname;
2313 const char **privname_array = NULL;
2314 int num_priv = 0;
2316 for ( i=0; i<privileges->count; i++ ) {
2317 privname = luid_to_privilege_name( &privileges->set[i].luid );
2318 if ( privname ) {
2319 if ( !add_string_to_array( get_talloc_ctx(), privname, &privname_array, &num_priv ) )
2320 return NT_STATUS_NO_MEMORY;
2324 if ( num_priv ) {
2325 r_u->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY );
2327 if ( !init_unistr4_array( r_u->rights, num_priv, privname_array ) )
2328 return NT_STATUS_NO_MEMORY;
2330 r_u->count = num_priv;
2333 return NT_STATUS_OK;
2336 /*******************************************************************
2337 reads or writes a LSA_Q_ENUM_ACCT_RIGHTS structure.
2338 ********************************************************************/
2339 BOOL lsa_io_q_enum_acct_rights(const char *desc, LSA_Q_ENUM_ACCT_RIGHTS *q_q, prs_struct *ps, int depth)
2342 if (q_q == NULL)
2343 return False;
2345 prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_rights");
2346 depth++;
2348 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
2349 return False;
2351 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth))
2352 return False;
2354 return True;
2358 /*******************************************************************
2359 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2360 ********************************************************************/
2361 BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *r_c, prs_struct *ps, int depth)
2363 prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_rights");
2364 depth++;
2366 if(!prs_uint32("count ", ps, depth, &r_c->count))
2367 return False;
2369 if ( !prs_pointer("rights", ps, depth, (void**)&r_c->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2370 return False;
2372 if(!prs_align(ps))
2373 return False;
2375 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2376 return False;
2378 return True;
2382 /*******************************************************************
2383 Inits an LSA_Q_ADD_ACCT_RIGHTS structure.
2384 ********************************************************************/
2385 void init_q_add_acct_rights( LSA_Q_ADD_ACCT_RIGHTS *q_q, POLICY_HND *hnd,
2386 DOM_SID *sid, uint32 count, const char **rights )
2388 DEBUG(5, ("init_q_add_acct_rights\n"));
2390 q_q->pol = *hnd;
2391 init_dom_sid2(&q_q->sid, sid);
2393 q_q->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY );
2394 init_unistr4_array( q_q->rights, count, rights );
2396 q_q->count = count;
2400 /*******************************************************************
2401 reads or writes a LSA_Q_ADD_ACCT_RIGHTS structure.
2402 ********************************************************************/
2403 BOOL lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *q_q, prs_struct *ps, int depth)
2405 prs_debug(ps, depth, desc, "lsa_io_q_add_acct_rights");
2406 depth++;
2408 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
2409 return False;
2411 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth))
2412 return False;
2414 if(!prs_uint32("count", ps, depth, &q_q->count))
2415 return False;
2417 if ( !prs_pointer("rights", ps, depth, (void**)&q_q->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2418 return False;
2420 return True;
2423 /*******************************************************************
2424 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2425 ********************************************************************/
2426 BOOL lsa_io_r_add_acct_rights(const char *desc, LSA_R_ADD_ACCT_RIGHTS *r_c, prs_struct *ps, int depth)
2428 prs_debug(ps, depth, desc, "lsa_io_r_add_acct_rights");
2429 depth++;
2431 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2432 return False;
2434 return True;
2438 /*******************************************************************
2439 Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure.
2440 ********************************************************************/
2441 void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *q_q,
2442 POLICY_HND *hnd,
2443 DOM_SID *sid,
2444 uint32 removeall,
2445 uint32 count,
2446 const char **rights)
2448 DEBUG(5, ("init_q_remove_acct_rights\n"));
2450 q_q->pol = *hnd;
2452 init_dom_sid2(&q_q->sid, sid);
2454 q_q->removeall = removeall;
2455 q_q->count = count;
2457 q_q->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY );
2458 init_unistr4_array( q_q->rights, count, rights );
2462 /*******************************************************************
2463 reads or writes a LSA_Q_REMOVE_ACCT_RIGHTS structure.
2464 ********************************************************************/
2465 BOOL lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *q_q, prs_struct *ps, int depth)
2467 prs_debug(ps, depth, desc, "lsa_io_q_remove_acct_rights");
2468 depth++;
2470 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
2471 return False;
2473 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth))
2474 return False;
2476 if(!prs_uint32("removeall", ps, depth, &q_q->removeall))
2477 return False;
2479 if(!prs_uint32("count", ps, depth, &q_q->count))
2480 return False;
2482 if ( !prs_pointer("rights", ps, depth, (void**)&q_q->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2483 return False;
2485 return True;
2488 /*******************************************************************
2489 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2490 ********************************************************************/
2491 BOOL lsa_io_r_remove_acct_rights(const char *desc, LSA_R_REMOVE_ACCT_RIGHTS *r_c, prs_struct *ps, int depth)
2493 prs_debug(ps, depth, desc, "lsa_io_r_remove_acct_rights");
2494 depth++;
2496 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2497 return False;
2499 return True;