r10909: Give better shutdown messages
[Samba/nascimento.git] / source3 / rpc_parse / parse_lsa.c
blobd924ea27d1f9272088d03b4afc3744af4d04d431
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 *dom, prs_struct *ps, 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, &dom->num_ref_doms_1)) /* num referenced domains? */
87 return False;
88 if(!prs_uint32("ptr_ref_dom ", ps, depth, &dom->ptr_ref_dom)) /* undocumented buffer pointer. */
89 return False;
90 if(!prs_uint32("max_entries ", ps, depth, &dom->max_entries)) /* 32 - max number of entries */
91 return False;
93 SMB_ASSERT_ARRAY(dom->hdr_ref_dom, dom->num_ref_doms_1);
95 if (dom->ptr_ref_dom != 0) {
97 if(!prs_uint32("num_ref_doms_2", ps, depth, &dom->num_ref_doms_2)) /* 4 - num referenced domains? */
98 return False;
100 SMB_ASSERT_ARRAY(dom->ref_dom, dom->num_ref_doms_2);
102 for (i = 0; i < dom->num_ref_doms_1; i++) {
103 fstring t;
105 slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
106 if(!smb_io_unihdr(t, &dom->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, &dom->hdr_ref_dom[i].ptr_dom_sid))
111 return False;
114 for (i = 0; i < dom->num_ref_doms_2; i++) {
115 fstring t;
117 if (dom->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, &dom->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 (dom->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, &dom->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 *in, 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 in->ptr = 1; /* undocumented pointer */
265 in->des_access = desired_access;
267 in->system_name = system_name;
268 init_lsa_obj_attr(&in->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 *in, 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, &in->ptr))
282 return False;
283 if(!prs_uint16("system_name", ps, depth, &in->system_name))
284 return False;
285 if(!prs_align( ps ))
286 return False;
288 if(!lsa_io_obj_attr("", &in->attr, ps, depth))
289 return False;
291 if(!prs_uint32("des_access", ps, depth, &in->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 *out, 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("", &out->pol, ps, depth))
308 return False;
310 if(!prs_ntstatus("status", ps, depth, &out->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 *in, 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 in->ptr = 1; /* undocumented pointer */
329 in->des_access = desired_access;
331 init_unistr2(&in->uni_server_name, server_name, UNI_STR_TERMINATE);
333 init_lsa_obj_attr(&in->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 *in, 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, &in->ptr))
347 return False;
349 if(!smb_io_unistr2 ("", &in->uni_server_name, in->ptr, ps, depth))
350 return False;
351 if(!lsa_io_obj_attr("", &in->attr, ps, depth))
352 return False;
354 if(!prs_uint32("des_access", ps, depth, &in->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 *out, 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("", &out->pol, ps, depth))
371 return False;
373 if(!prs_ntstatus("status", ps, depth, &out->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 *in, const POLICY_HND *hnd,
384 uint32 sec_info)
386 DEBUG(5, ("init_q_query_sec_obj\n"));
388 in->pol = *hnd;
389 in->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 *in,
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("", &in->pol, ps, depth))
405 return False;
407 if (!prs_uint32("sec_info", ps, depth, &in->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 *out, prs_struct *ps, int depth)
419 prs_debug(ps, depth, desc, "lsa_io_r_query_sec_obj");
420 depth++;
422 if (!prs_align(ps))
423 return False;
425 if (!prs_uint32("ptr", ps, depth, &out->ptr))
426 return False;
428 if (out->ptr != 0) {
429 if (!sec_io_desc_buf("sec", &out->buf, ps, depth))
430 return False;
433 if (!prs_ntstatus("status", ps, depth, &out->status))
434 return False;
436 return True;
439 /*******************************************************************
440 Inits an LSA_Q_QUERY_INFO structure.
441 ********************************************************************/
443 void init_q_query(LSA_Q_QUERY_INFO *in, POLICY_HND *hnd, uint16 info_class)
445 DEBUG(5, ("init_q_query\n"));
447 memcpy(&in->pol, hnd, sizeof(in->pol));
449 in->info_class = info_class;
452 /*******************************************************************
453 Reads or writes an LSA_Q_QUERY_INFO structure.
454 ********************************************************************/
456 BOOL lsa_io_q_query(const char *desc, LSA_Q_QUERY_INFO *in, prs_struct *ps,
457 int depth)
459 prs_debug(ps, depth, desc, "lsa_io_q_query");
460 depth++;
462 if(!smb_io_pol_hnd("", &in->pol, ps, depth))
463 return False;
465 if(!prs_uint16("info_class", ps, depth, &in->info_class))
466 return False;
468 return True;
471 /*******************************************************************
472 makes an LSA_Q_ENUM_TRUST_DOM structure.
473 ********************************************************************/
474 BOOL init_q_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM * q_e, POLICY_HND *pol,
475 uint32 enum_context, uint32 preferred_len)
477 DEBUG(5, ("init_q_enum_trust_dom\n"));
479 q_e->pol = *pol;
480 q_e->enum_context = enum_context;
481 q_e->preferred_len = preferred_len;
483 return True;
486 /*******************************************************************
487 Reads or writes an LSA_Q_ENUM_TRUST_DOM structure.
488 ********************************************************************/
490 BOOL lsa_io_q_enum_trust_dom(const char *desc, LSA_Q_ENUM_TRUST_DOM *q_e,
491 prs_struct *ps, int depth)
493 prs_debug(ps, depth, desc, "lsa_io_q_enum_trust_dom");
494 depth++;
496 if(!smb_io_pol_hnd("", &q_e->pol, ps, depth))
497 return False;
499 if(!prs_uint32("enum_context ", ps, depth, &q_e->enum_context))
500 return False;
501 if(!prs_uint32("preferred_len", ps, depth, &q_e->preferred_len))
502 return False;
504 return True;
507 /*******************************************************************
508 Inits an LSA_R_ENUM_TRUST_DOM structure.
509 ********************************************************************/
511 void init_r_enum_trust_dom(TALLOC_CTX *ctx, LSA_R_ENUM_TRUST_DOM *out, uint32 enum_context,
512 uint32 req_num_domains, uint32 num_domains, TRUSTDOM **td)
514 unsigned int i;
516 DEBUG(5, ("init_r_enum_trust_dom\n"));
518 out->enum_context = enum_context;
519 out->count = num_domains;
521 if ( num_domains != 0 ) {
523 /* allocate container memory */
525 out->domlist = TALLOC_P( ctx, DOMAIN_LIST );
526 out->domlist->domains = TALLOC_ARRAY( ctx, DOMAIN_INFO, out->count );
528 if ( !out->domlist || !out->domlist->domains ) {
529 out->status = NT_STATUS_NO_MEMORY;
530 return;
533 out->domlist->count = out->count;
535 /* initialize the list of domains and their sid */
537 for (i = 0; i < num_domains; i++) {
538 if ( !(out->domlist->domains[i].sid = TALLOC_P(ctx, DOM_SID2)) ) {
539 out->status = NT_STATUS_NO_MEMORY;
540 return;
543 init_dom_sid2(out->domlist->domains[i].sid, &(td[i])->sid);
544 init_unistr4_w(ctx, &out->domlist->domains[i].name, (td[i])->name);
550 /*******************************************************************
551 ********************************************************************/
553 BOOL lsa_io_domain_list( const char *desc, prs_struct *ps, int depth, DOMAIN_LIST *domlist )
555 int i;
557 prs_debug(ps, depth, desc, "lsa_io_domain_list");
558 depth++;
560 if(!prs_uint32("count", ps, depth, &domlist->count))
561 return False;
563 if ( domlist->count == 0 )
564 return True;
566 if ( UNMARSHALLING(ps) ) {
567 if ( !(domlist->domains = PRS_ALLOC_MEM( ps, DOMAIN_INFO, domlist->count )) )
568 return False;
571 /* headers */
573 for ( i=0; i<domlist->count; i++ ) {
574 if ( !prs_unistr4_hdr("name_header", ps, depth, &domlist->domains[i].name) )
575 return False;
576 if ( !smb_io_dom_sid2_p("sid_header", ps, depth, &domlist->domains[i].sid) )
577 return False;
580 /* data */
582 for ( i=0; i<domlist->count; i++ ) {
583 if ( !prs_unistr4_str("name", ps, depth, &domlist->domains[i].name) )
584 return False;
585 if( !smb_io_dom_sid2("sid", domlist->domains[i].sid, ps, depth) )
586 return False;
589 return True;
592 /*******************************************************************
593 Reads or writes an LSA_R_ENUM_TRUST_DOM structure.
594 ********************************************************************/
596 BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *out,
597 prs_struct *ps, int depth)
599 prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom");
600 depth++;
602 if(!prs_uint32("enum_context", ps, depth, &out->enum_context))
603 return False;
605 if(!prs_uint32("count", ps, depth, &out->count))
606 return False;
608 if ( !prs_pointer("trusted_domains", ps, depth, (void**)&out->domlist, sizeof(DOMAIN_LIST), (PRS_POINTER_CAST)lsa_io_domain_list))
609 return False;
611 if(!prs_ntstatus("status", ps, depth, &out->status))
612 return False;
614 return True;
617 /*******************************************************************
618 reads or writes a dom query structure.
619 ********************************************************************/
621 static BOOL lsa_io_dom_query(const char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth)
623 if (d_q == NULL)
624 return False;
626 prs_debug(ps, depth, desc, "lsa_io_dom_query");
627 depth++;
629 if(!prs_align(ps))
630 return False;
632 if(!prs_uint16("uni_dom_max_len", ps, depth, &d_q->uni_dom_max_len)) /* domain name string length * 2 */
633 return False;
634 if(!prs_uint16("uni_dom_str_len", ps, depth, &d_q->uni_dom_str_len)) /* domain name string length * 2 */
635 return False;
637 if(!prs_uint32("buffer_dom_name", ps, depth, &d_q->buffer_dom_name)) /* undocumented domain name string buffer pointer */
638 return False;
639 if(!prs_uint32("buffer_dom_sid ", ps, depth, &d_q->buffer_dom_sid)) /* undocumented domain SID string buffer pointer */
640 return False;
642 if(!smb_io_unistr2("unistr2", &d_q->uni_domain_name, d_q->buffer_dom_name, ps, depth)) /* domain name (unicode string) */
643 return False;
645 if(!prs_align(ps))
646 return False;
648 if (d_q->buffer_dom_sid != 0) {
649 if(!smb_io_dom_sid2("", &d_q->dom_sid, ps, depth)) /* domain SID */
650 return False;
651 } else {
652 memset((char *)&d_q->dom_sid, '\0', sizeof(d_q->dom_sid));
655 return True;
658 /*******************************************************************
659 reads or writes a structure.
660 ********************************************************************/
662 static BOOL lsa_io_dom_query_2(const char *desc, DOM_QUERY_2 *d_q, prs_struct *ps, int depth)
664 uint32 ptr = 1;
666 if (d_q == NULL)
667 return False;
669 prs_debug(ps, depth, desc, "lsa_io_dom_query_2");
670 depth++;
672 if (!prs_align(ps))
673 return False;
675 if (!prs_uint32("auditing_enabled", ps, depth, &d_q->auditing_enabled))
676 return False;
677 if (!prs_uint32("ptr ", ps, depth, &ptr))
678 return False;
679 if (!prs_uint32("count1", ps, depth, &d_q->count1))
680 return False;
681 if (!prs_uint32("count2", ps, depth, &d_q->count2))
682 return False;
684 if (UNMARSHALLING(ps)) {
685 d_q->auditsettings = TALLOC_ZERO_ARRAY(ps->mem_ctx, uint32, d_q->count2);
688 if (d_q->auditsettings == NULL) {
689 DEBUG(1, ("lsa_io_dom_query_2: NULL auditsettings!\n"));
690 return False;
693 if (!prs_uint32s(False, "auditsettings", ps, depth, d_q->auditsettings, d_q->count2))
694 return False;
696 return True;
699 /*******************************************************************
700 Reads or writes a dom query structure.
701 ********************************************************************/
703 static BOOL lsa_io_dom_query_3(const char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
705 return lsa_io_dom_query("", d_q, ps, depth);
708 /*******************************************************************
709 Reads or writes a dom query structure.
710 ********************************************************************/
712 static BOOL lsa_io_dom_query_5(const char *desc, DOM_QUERY_5 *d_q, prs_struct *ps, int depth)
714 return lsa_io_dom_query("", d_q, ps, depth);
717 /*******************************************************************
718 Reads or writes a dom query structure.
719 ********************************************************************/
721 static BOOL lsa_io_dom_query_6(const char *desc, DOM_QUERY_6 *d_q, prs_struct *ps, int depth)
723 if (d_q == NULL)
724 return False;
726 prs_debug(ps, depth, desc, "lsa_io_dom_query_6");
727 depth++;
729 if (!prs_uint16("server_role", ps, depth, &d_q->server_role))
730 return False;
732 return True;
735 /*******************************************************************
736 Reads or writes an LSA_R_QUERY_INFO structure.
737 ********************************************************************/
739 BOOL lsa_io_r_query(const char *desc, LSA_R_QUERY_INFO *out, prs_struct *ps, int depth)
741 prs_debug(ps, depth, desc, "lsa_io_r_query");
742 depth++;
744 if(!prs_uint32("undoc_buffer", ps, depth, &out->undoc_buffer))
745 return False;
747 if (out->undoc_buffer != 0) {
748 if(!prs_uint16("info_class", ps, depth, &out->info_class))
749 return False;
751 if(!prs_align(ps))
752 return False;
754 switch (out->info_class) {
755 case 2:
756 if(!lsa_io_dom_query_2("", &out->dom.id2, ps, depth))
757 return False;
758 break;
759 case 3:
760 if(!lsa_io_dom_query_3("", &out->dom.id3, ps, depth))
761 return False;
762 break;
763 case 5:
764 if(!lsa_io_dom_query_5("", &out->dom.id5, ps, depth))
765 return False;
766 break;
767 case 6:
768 if(!lsa_io_dom_query_6("", &out->dom.id6, ps, depth))
769 return False;
770 break;
771 default:
772 /* PANIC! */
773 break;
777 if(!prs_align(ps))
778 return False;
780 if(!prs_ntstatus("status", ps, depth, &out->status))
781 return False;
783 return True;
786 /*******************************************************************
787 Inits a LSA_SID_ENUM structure.
788 ********************************************************************/
790 static void init_lsa_sid_enum(TALLOC_CTX *mem_ctx, LSA_SID_ENUM *sen,
791 int num_entries, const DOM_SID *sids)
793 int i;
795 DEBUG(5, ("init_lsa_sid_enum\n"));
797 sen->num_entries = num_entries;
798 sen->ptr_sid_enum = (num_entries != 0);
799 sen->num_entries2 = num_entries;
801 /* Allocate memory for sids and sid pointers */
803 if (num_entries == 0) return;
805 if ((sen->ptr_sid = TALLOC_ZERO_ARRAY(mem_ctx, uint32, num_entries )) == NULL) {
806 DEBUG(3, ("init_lsa_sid_enum(): out of memory for ptr_sid\n"));
807 return;
810 if ((sen->sid = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID2, num_entries)) == NULL) {
811 DEBUG(3, ("init_lsa_sid_enum(): out of memory for sids\n"));
812 return;
815 /* Copy across SIDs and SID pointers */
817 for (i = 0; i < num_entries; i++) {
818 sen->ptr_sid[i] = 1;
819 init_dom_sid2(&sen->sid[i], &sids[i]);
823 /*******************************************************************
824 Reads or writes a LSA_SID_ENUM structure.
825 ********************************************************************/
827 static BOOL lsa_io_sid_enum(const char *desc, LSA_SID_ENUM *sen, prs_struct *ps,
828 int depth)
830 unsigned int i;
832 prs_debug(ps, depth, desc, "lsa_io_sid_enum");
833 depth++;
835 if(!prs_align(ps))
836 return False;
838 if(!prs_uint32("num_entries ", ps, depth, &sen->num_entries))
839 return False;
840 if(!prs_uint32("ptr_sid_enum", ps, depth, &sen->ptr_sid_enum))
841 return False;
844 if the ptr is NULL, leave here. checked from a real w2k trace.
845 JFM, 11/23/2001
848 if (sen->ptr_sid_enum==0)
849 return True;
851 if(!prs_uint32("num_entries2", ps, depth, &sen->num_entries2))
852 return False;
854 /* Mallocate memory if we're unpacking from the wire */
856 if (UNMARSHALLING(ps)) {
857 if ((sen->ptr_sid = PRS_ALLOC_MEM( ps, uint32, sen->num_entries)) == NULL) {
858 DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
859 "ptr_sid\n"));
860 return False;
863 if ((sen->sid = PRS_ALLOC_MEM( ps, DOM_SID2, sen->num_entries)) == NULL) {
864 DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
865 "sids\n"));
866 return False;
870 for (i = 0; i < sen->num_entries; i++) {
871 fstring temp;
873 slprintf(temp, sizeof(temp) - 1, "ptr_sid[%d]", i);
874 if(!prs_uint32(temp, ps, depth, &sen->ptr_sid[i])) {
875 return False;
879 for (i = 0; i < sen->num_entries; i++) {
880 fstring temp;
882 slprintf(temp, sizeof(temp) - 1, "sid[%d]", i);
883 if(!smb_io_dom_sid2(temp, &sen->sid[i], ps, depth)) {
884 return False;
888 return True;
891 /*******************************************************************
892 Inits an LSA_R_ENUM_TRUST_DOM structure.
893 ********************************************************************/
895 void init_q_lookup_sids(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_SIDS *q_l,
896 POLICY_HND *hnd, int num_sids, const DOM_SID *sids,
897 uint16 level)
899 DEBUG(5, ("init_q_lookup_sids\n"));
901 ZERO_STRUCTP(q_l);
903 memcpy(&q_l->pol, hnd, sizeof(q_l->pol));
904 init_lsa_sid_enum(mem_ctx, &q_l->sids, num_sids, sids);
906 q_l->level = level;
909 /*******************************************************************
910 Reads or writes a LSA_Q_LOOKUP_SIDS structure.
911 ********************************************************************/
913 BOOL lsa_io_q_lookup_sids(const char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps,
914 int depth)
916 prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids");
917 depth++;
919 if(!prs_align(ps))
920 return False;
922 if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */
923 return False;
924 if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */
925 return False;
926 if(!lsa_io_trans_names("names ", &q_s->names, ps, depth)) /* translated names */
927 return False;
929 if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */
930 return False;
931 if(!prs_align(ps))
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 *out, prs_struct *ps, int depth)
1134 unsigned int i;
1136 prs_debug(ps, depth, desc, "lsa_io_r_lookup_names");
1137 depth++;
1139 if(!prs_align(ps))
1140 return False;
1142 if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref))
1143 return False;
1145 if (out->ptr_dom_ref != 0)
1146 if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth))
1147 return False;
1149 if(!prs_uint32("num_entries", ps, depth, &out->num_entries))
1150 return False;
1151 if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries))
1152 return False;
1154 if (out->ptr_entries != 0) {
1155 if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2))
1156 return False;
1158 if (out->num_entries2 != out->num_entries) {
1159 /* RPC fault */
1160 return False;
1163 if (UNMARSHALLING(ps)) {
1164 if ((out->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID2, out->num_entries2))
1165 == NULL) {
1166 DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n"));
1167 return False;
1171 for (i = 0; i < out->num_entries2; i++)
1172 if(!smb_io_dom_rid2("", &out->dom_rid[i], ps, depth)) /* domain RIDs being looked up */
1173 return False;
1176 if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count))
1177 return False;
1179 if(!prs_ntstatus("status ", ps, depth, &out->status))
1180 return False;
1182 return True;
1186 /*******************************************************************
1187 Inits an LSA_Q_CLOSE structure.
1188 ********************************************************************/
1190 void init_lsa_q_close(LSA_Q_CLOSE *in, POLICY_HND *hnd)
1192 DEBUG(5, ("init_lsa_q_close\n"));
1194 memcpy(&in->pol, hnd, sizeof(in->pol));
1197 /*******************************************************************
1198 Reads or writes an LSA_Q_CLOSE structure.
1199 ********************************************************************/
1201 BOOL lsa_io_q_close(const char *desc, LSA_Q_CLOSE *in, prs_struct *ps, int depth)
1203 prs_debug(ps, depth, desc, "lsa_io_q_close");
1204 depth++;
1206 if(!smb_io_pol_hnd("", &in->pol, ps, depth))
1207 return False;
1209 return True;
1212 /*******************************************************************
1213 Reads or writes an LSA_R_CLOSE structure.
1214 ********************************************************************/
1216 BOOL lsa_io_r_close(const char *desc, LSA_R_CLOSE *out, prs_struct *ps, int depth)
1218 prs_debug(ps, depth, desc, "lsa_io_r_close");
1219 depth++;
1221 if(!smb_io_pol_hnd("", &out->pol, ps, depth))
1222 return False;
1224 if(!prs_ntstatus("status", ps, depth, &out->status))
1225 return False;
1227 return True;
1230 /*******************************************************************
1231 Reads or writes an LSA_Q_OPEN_SECRET structure.
1232 ********************************************************************/
1234 BOOL lsa_io_q_open_secret(const char *desc, LSA_Q_OPEN_SECRET *in, prs_struct *ps, int depth)
1236 prs_debug(ps, depth, desc, "lsa_io_q_open_secret");
1237 depth++;
1239 if(!prs_align(ps))
1240 return False;
1242 if(!smb_io_pol_hnd("", &in->handle, ps, depth))
1243 return False;
1245 if(!prs_unistr4 ("secretname", ps, depth, &in->secretname))
1246 return False;
1247 if(!prs_align(ps))
1248 return False;
1250 if(!prs_uint32("access", ps, depth, &in->access))
1251 return False;
1253 return True;
1256 /*******************************************************************
1257 Reads or writes an LSA_R_OPEN_SECRET structure.
1258 ********************************************************************/
1260 BOOL lsa_io_r_open_secret(const char *desc, LSA_R_OPEN_SECRET *out, prs_struct *ps, int depth)
1262 prs_debug(ps, depth, desc, "lsa_io_r_open_secret");
1263 depth++;
1265 if(!prs_align(ps))
1266 return False;
1268 if(!smb_io_pol_hnd("", &out->handle, ps, depth))
1269 return False;
1271 if(!prs_ntstatus("status", ps, depth, &out->status))
1272 return False;
1274 return True;
1277 /*******************************************************************
1278 Inits an LSA_Q_ENUM_PRIVS structure.
1279 ********************************************************************/
1281 void init_q_enum_privs(LSA_Q_ENUM_PRIVS *in, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1283 DEBUG(5, ("init_q_enum_privs\n"));
1285 memcpy(&in->pol, hnd, sizeof(in->pol));
1287 in->enum_context = enum_context;
1288 in->pref_max_length = pref_max_length;
1291 /*******************************************************************
1292 reads or writes a structure.
1293 ********************************************************************/
1294 BOOL lsa_io_q_enum_privs(const char *desc, LSA_Q_ENUM_PRIVS *in, prs_struct *ps, int depth)
1296 if (in == NULL)
1297 return False;
1299 prs_debug(ps, depth, desc, "lsa_io_q_enum_privs");
1300 depth++;
1302 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
1303 return False;
1305 if(!prs_uint32("enum_context ", ps, depth, &in->enum_context))
1306 return False;
1307 if(!prs_uint32("pref_max_length", ps, depth, &in->pref_max_length))
1308 return False;
1310 return True;
1313 /*******************************************************************
1314 reads or writes a structure.
1315 ********************************************************************/
1316 static BOOL lsa_io_priv_entries(const char *desc, LSA_PRIV_ENTRY *entries, uint32 count, prs_struct *ps, int depth)
1318 uint32 i;
1320 if (entries == NULL)
1321 return False;
1323 prs_debug(ps, depth, desc, "lsa_io_priv_entries");
1324 depth++;
1326 if(!prs_align(ps))
1327 return False;
1329 for (i = 0; i < count; i++) {
1330 if (!smb_io_unihdr("", &entries[i].hdr_name, ps, depth))
1331 return False;
1332 if(!prs_uint32("luid_low ", ps, depth, &entries[i].luid_low))
1333 return False;
1334 if(!prs_uint32("luid_high", ps, depth, &entries[i].luid_high))
1335 return False;
1338 for (i = 0; i < count; i++)
1339 if (!smb_io_unistr2("", &entries[i].name, entries[i].hdr_name.buffer, ps, depth))
1340 return False;
1342 return True;
1345 /*******************************************************************
1346 Inits an LSA_R_ENUM_PRIVS structure.
1347 ********************************************************************/
1349 void init_lsa_r_enum_privs(LSA_R_ENUM_PRIVS *out, uint32 enum_context,
1350 uint32 count, LSA_PRIV_ENTRY *entries)
1352 DEBUG(5, ("init_lsa_r_enum_privs\n"));
1354 out->enum_context=enum_context;
1355 out->count=count;
1357 if (entries!=NULL) {
1358 out->ptr=1;
1359 out->count1=count;
1360 out->privs=entries;
1361 } else {
1362 out->ptr=0;
1363 out->count1=0;
1364 out->privs=NULL;
1368 /*******************************************************************
1369 reads or writes a structure.
1370 ********************************************************************/
1371 BOOL lsa_io_r_enum_privs(const char *desc, LSA_R_ENUM_PRIVS *out, prs_struct *ps, int depth)
1373 if (out == NULL)
1374 return False;
1376 prs_debug(ps, depth, desc, "lsa_io_r_enum_privs");
1377 depth++;
1379 if(!prs_align(ps))
1380 return False;
1382 if(!prs_uint32("enum_context", ps, depth, &out->enum_context))
1383 return False;
1384 if(!prs_uint32("count", ps, depth, &out->count))
1385 return False;
1386 if(!prs_uint32("ptr", ps, depth, &out->ptr))
1387 return False;
1389 if (out->ptr) {
1390 if(!prs_uint32("count1", ps, depth, &out->count1))
1391 return False;
1393 if (UNMARSHALLING(ps))
1394 if (!(out->privs = PRS_ALLOC_MEM(ps, LSA_PRIV_ENTRY, out->count1)))
1395 return False;
1397 if (!lsa_io_priv_entries("", out->privs, out->count1, ps, depth))
1398 return False;
1401 if(!prs_align(ps))
1402 return False;
1404 if(!prs_ntstatus("status", ps, depth, &out->status))
1405 return False;
1407 return True;
1410 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)
1412 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1414 init_unistr2(&trn->name, name, UNI_FLAGS_NONE);
1415 init_uni_hdr(&trn->hdr_name, &trn->name);
1416 trn->lang_id = lang_id;
1417 trn->lang_id_sys = lang_id_sys;
1420 /*******************************************************************
1421 reads or writes a structure.
1422 ********************************************************************/
1423 BOOL lsa_io_q_priv_get_dispname(const char *desc, LSA_Q_PRIV_GET_DISPNAME *in, prs_struct *ps, int depth)
1425 if (in == NULL)
1426 return False;
1428 prs_debug(ps, depth, desc, "lsa_io_q_priv_get_dispname");
1429 depth++;
1431 if(!prs_align(ps))
1432 return False;
1434 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
1435 return False;
1437 if (!smb_io_unihdr("hdr_name", &in->hdr_name, ps, depth))
1438 return False;
1440 if (!smb_io_unistr2("name", &in->name, in->hdr_name.buffer, ps, depth))
1441 return False;
1443 if(!prs_uint16("lang_id ", ps, depth, &in->lang_id))
1444 return False;
1445 if(!prs_uint16("lang_id_sys", ps, depth, &in->lang_id_sys))
1446 return False;
1448 return True;
1451 /*******************************************************************
1452 reads or writes a structure.
1453 ********************************************************************/
1454 BOOL lsa_io_r_priv_get_dispname(const char *desc, LSA_R_PRIV_GET_DISPNAME *out, prs_struct *ps, int depth)
1456 if (out == NULL)
1457 return False;
1459 prs_debug(ps, depth, desc, "lsa_io_r_priv_get_dispname");
1460 depth++;
1462 if (!prs_align(ps))
1463 return False;
1465 if (!prs_uint32("ptr_info", ps, depth, &out->ptr_info))
1466 return False;
1468 if (out->ptr_info){
1469 if (!smb_io_unihdr("hdr_name", &out->hdr_desc, ps, depth))
1470 return False;
1472 if (!smb_io_unistr2("desc", &out->desc, out->hdr_desc.buffer, ps, depth))
1473 return False;
1476 if(!prs_align(ps))
1477 return False;
1479 if(!prs_uint16("lang_id", ps, depth, &out->lang_id))
1480 return False;
1482 if(!prs_align(ps))
1483 return False;
1484 if(!prs_ntstatus("status", ps, depth, &out->status))
1485 return False;
1487 return True;
1491 initialise a LSA_Q_ENUM_ACCOUNTS structure
1493 void init_lsa_q_enum_accounts(LSA_Q_ENUM_ACCOUNTS *trn, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1495 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1497 trn->enum_context = enum_context;
1498 trn->pref_max_length = pref_max_length;
1501 /*******************************************************************
1502 reads or writes a structure.
1503 ********************************************************************/
1504 BOOL lsa_io_q_enum_accounts(const char *desc, LSA_Q_ENUM_ACCOUNTS *in, prs_struct *ps, int depth)
1506 if (in == NULL)
1507 return False;
1509 prs_debug(ps, depth, desc, "lsa_io_q_enum_accounts");
1510 depth++;
1512 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
1513 return False;
1515 if(!prs_uint32("enum_context ", ps, depth, &in->enum_context))
1516 return False;
1517 if(!prs_uint32("pref_max_length", ps, depth, &in->pref_max_length))
1518 return False;
1520 return True;
1524 /*******************************************************************
1525 Inits an LSA_R_ENUM_PRIVS structure.
1526 ********************************************************************/
1528 void init_lsa_r_enum_accounts(LSA_R_ENUM_ACCOUNTS *out, uint32 enum_context)
1530 DEBUG(5, ("init_lsa_r_enum_accounts\n"));
1532 out->enum_context=enum_context;
1533 if (out->enum_context!=0) {
1534 out->sids.num_entries=enum_context;
1535 out->sids.ptr_sid_enum=1;
1536 out->sids.num_entries2=enum_context;
1537 } else {
1538 out->sids.num_entries=0;
1539 out->sids.ptr_sid_enum=0;
1540 out->sids.num_entries2=0;
1544 /*******************************************************************
1545 reads or writes a structure.
1546 ********************************************************************/
1547 BOOL lsa_io_r_enum_accounts(const char *desc, LSA_R_ENUM_ACCOUNTS *out, prs_struct *ps, int depth)
1549 if (out == NULL)
1550 return False;
1552 prs_debug(ps, depth, desc, "lsa_io_r_enum_accounts");
1553 depth++;
1555 if (!prs_align(ps))
1556 return False;
1558 if(!prs_uint32("enum_context", ps, depth, &out->enum_context))
1559 return False;
1561 if (!lsa_io_sid_enum("sids", &out->sids, ps, depth))
1562 return False;
1564 if (!prs_align(ps))
1565 return False;
1567 if(!prs_ntstatus("status", ps, depth, &out->status))
1568 return False;
1570 return True;
1574 /*******************************************************************
1575 Reads or writes an LSA_Q_UNK_GET_CONNUSER structure.
1576 ********************************************************************/
1578 BOOL lsa_io_q_unk_get_connuser(const char *desc, LSA_Q_UNK_GET_CONNUSER *in, prs_struct *ps, int depth)
1580 prs_debug(ps, depth, desc, "lsa_io_q_unk_get_connuser");
1581 depth++;
1583 if(!prs_align(ps))
1584 return False;
1586 if(!prs_uint32("ptr_srvname", ps, depth, &in->ptr_srvname))
1587 return False;
1589 if(!smb_io_unistr2("uni2_srvname", &in->uni2_srvname, in->ptr_srvname, ps, depth)) /* server name to be looked up */
1590 return False;
1592 if (!prs_align(ps))
1593 return False;
1595 if(!prs_uint32("unk1", ps, depth, &in->unk1))
1596 return False;
1597 if(!prs_uint32("unk2", ps, depth, &in->unk2))
1598 return False;
1599 if(!prs_uint32("unk3", ps, depth, &in->unk3))
1600 return False;
1602 /* Don't bother to read or write at present... */
1603 return True;
1606 /*******************************************************************
1607 Reads or writes an LSA_R_UNK_GET_CONNUSER structure.
1608 ********************************************************************/
1610 BOOL lsa_io_r_unk_get_connuser(const char *desc, LSA_R_UNK_GET_CONNUSER *out, prs_struct *ps, int depth)
1612 prs_debug(ps, depth, desc, "lsa_io_r_unk_get_connuser");
1613 depth++;
1615 if(!prs_align(ps))
1616 return False;
1618 if(!prs_uint32("ptr_user_name", ps, depth, &out->ptr_user_name))
1619 return False;
1620 if(!smb_io_unihdr("hdr_user_name", &out->hdr_user_name, ps, depth))
1621 return False;
1622 if(!smb_io_unistr2("uni2_user_name", &out->uni2_user_name, out->ptr_user_name, ps, depth))
1623 return False;
1625 if (!prs_align(ps))
1626 return False;
1628 if(!prs_uint32("unk1", ps, depth, &out->unk1))
1629 return False;
1631 if(!prs_uint32("ptr_dom_name", ps, depth, &out->ptr_dom_name))
1632 return False;
1633 if(!smb_io_unihdr("hdr_dom_name", &out->hdr_dom_name, ps, depth))
1634 return False;
1635 if(!smb_io_unistr2("uni2_dom_name", &out->uni2_dom_name, out->ptr_dom_name, ps, depth))
1636 return False;
1638 if (!prs_align(ps))
1639 return False;
1641 if(!prs_ntstatus("status", ps, depth, &out->status))
1642 return False;
1644 return True;
1647 void init_lsa_q_create_account(LSA_Q_CREATEACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1649 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1651 init_dom_sid2(&trn->sid, sid);
1652 trn->access = desired_access;
1656 /*******************************************************************
1657 Reads or writes an LSA_Q_CREATEACCOUNT structure.
1658 ********************************************************************/
1660 BOOL lsa_io_q_create_account(const char *desc, LSA_Q_CREATEACCOUNT *out, prs_struct *ps, int depth)
1662 prs_debug(ps, depth, desc, "lsa_io_q_create_account");
1663 depth++;
1665 if(!prs_align(ps))
1666 return False;
1668 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1669 return False;
1671 if(!smb_io_dom_sid2("sid", &out->sid, ps, depth)) /* domain SID */
1672 return False;
1674 if(!prs_uint32("access", ps, depth, &out->access))
1675 return False;
1677 return True;
1680 /*******************************************************************
1681 Reads or writes an LSA_R_CREATEACCOUNT structure.
1682 ********************************************************************/
1684 BOOL lsa_io_r_create_account(const char *desc, LSA_R_CREATEACCOUNT *out, prs_struct *ps, int depth)
1686 prs_debug(ps, depth, desc, "lsa_io_r_open_account");
1687 depth++;
1689 if(!prs_align(ps))
1690 return False;
1692 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1693 return False;
1695 if(!prs_ntstatus("status", ps, depth, &out->status))
1696 return False;
1698 return True;
1702 void init_lsa_q_open_account(LSA_Q_OPENACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1704 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1706 init_dom_sid2(&trn->sid, sid);
1707 trn->access = desired_access;
1710 /*******************************************************************
1711 Reads or writes an LSA_Q_OPENACCOUNT structure.
1712 ********************************************************************/
1714 BOOL lsa_io_q_open_account(const char *desc, LSA_Q_OPENACCOUNT *out, prs_struct *ps, int depth)
1716 prs_debug(ps, depth, desc, "lsa_io_q_open_account");
1717 depth++;
1719 if(!prs_align(ps))
1720 return False;
1722 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1723 return False;
1725 if(!smb_io_dom_sid2("sid", &out->sid, ps, depth)) /* domain SID */
1726 return False;
1728 if(!prs_uint32("access", ps, depth, &out->access))
1729 return False;
1731 return True;
1734 /*******************************************************************
1735 Reads or writes an LSA_R_OPENACCOUNT structure.
1736 ********************************************************************/
1738 BOOL lsa_io_r_open_account(const char *desc, LSA_R_OPENACCOUNT *out, prs_struct *ps, int depth)
1740 prs_debug(ps, depth, desc, "lsa_io_r_open_account");
1741 depth++;
1743 if(!prs_align(ps))
1744 return False;
1746 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1747 return False;
1749 if(!prs_ntstatus("status", ps, depth, &out->status))
1750 return False;
1752 return True;
1756 void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd)
1758 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1762 /*******************************************************************
1763 Reads or writes an LSA_Q_ENUMPRIVSACCOUNT structure.
1764 ********************************************************************/
1766 BOOL lsa_io_q_enum_privsaccount(const char *desc, LSA_Q_ENUMPRIVSACCOUNT *out, prs_struct *ps, int depth)
1768 prs_debug(ps, depth, desc, "lsa_io_q_enum_privsaccount");
1769 depth++;
1771 if(!prs_align(ps))
1772 return False;
1774 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1775 return False;
1777 return True;
1780 /*******************************************************************
1781 Reads or writes an LUID structure.
1782 ********************************************************************/
1784 static BOOL lsa_io_luid(const char *desc, LUID *out, prs_struct *ps, int depth)
1786 prs_debug(ps, depth, desc, "lsa_io_luid");
1787 depth++;
1789 if(!prs_align(ps))
1790 return False;
1792 if(!prs_uint32("low", ps, depth, &out->low))
1793 return False;
1795 if(!prs_uint32("high", ps, depth, &out->high))
1796 return False;
1798 return True;
1801 /*******************************************************************
1802 Reads or writes an LUID_ATTR structure.
1803 ********************************************************************/
1805 static BOOL lsa_io_luid_attr(const char *desc, LUID_ATTR *out, prs_struct *ps, int depth)
1807 prs_debug(ps, depth, desc, "lsa_io_luid_attr");
1808 depth++;
1810 if(!prs_align(ps))
1811 return False;
1813 if (!lsa_io_luid(desc, &out->luid, ps, depth))
1814 return False;
1816 if(!prs_uint32("attr", ps, depth, &out->attr))
1817 return False;
1819 return True;
1822 /*******************************************************************
1823 Reads or writes an PRIVILEGE_SET structure.
1824 ********************************************************************/
1826 static BOOL lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *out, prs_struct *ps, int depth)
1828 uint32 i;
1830 prs_debug(ps, depth, desc, "lsa_io_privilege_set");
1831 depth++;
1833 if(!prs_align(ps))
1834 return False;
1836 if(!prs_uint32("count", ps, depth, &out->count))
1837 return False;
1838 if(!prs_uint32("control", ps, depth, &out->control))
1839 return False;
1841 for (i=0; i<out->count; i++) {
1842 if (!lsa_io_luid_attr(desc, &out->set[i], ps, depth))
1843 return False;
1846 return True;
1849 NTSTATUS init_lsa_r_enum_privsaccount(TALLOC_CTX *mem_ctx, LSA_R_ENUMPRIVSACCOUNT *out, LUID_ATTR *set, uint32 count, uint32 control)
1851 NTSTATUS ret = NT_STATUS_OK;
1853 out->ptr = 1;
1854 out->count = count;
1856 if ( !NT_STATUS_IS_OK(ret = privilege_set_init_by_ctx(mem_ctx, &(out->set))) )
1857 return ret;
1859 out->set.count = count;
1861 if (!NT_STATUS_IS_OK(ret = dup_luid_attr(out->set.mem_ctx, &(out->set.set), set, count)))
1862 return ret;
1864 DEBUG(10,("init_lsa_r_enum_privsaccount: %d privileges\n", out->count));
1866 return ret;
1869 /*******************************************************************
1870 Reads or writes an LSA_R_ENUMPRIVSACCOUNT structure.
1871 ********************************************************************/
1873 BOOL lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *out, prs_struct *ps, int depth)
1875 prs_debug(ps, depth, desc, "lsa_io_r_enum_privsaccount");
1876 depth++;
1878 if(!prs_align(ps))
1879 return False;
1881 if(!prs_uint32("ptr", ps, depth, &out->ptr))
1882 return False;
1884 if (out->ptr!=0) {
1885 if(!prs_uint32("count", ps, depth, &out->count))
1886 return False;
1888 /* malloc memory if unmarshalling here */
1890 if (UNMARSHALLING(ps) && out->count != 0) {
1891 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))
1892 return False;
1894 if (!(out->set.set = PRS_ALLOC_MEM(ps,LUID_ATTR,out->count)))
1895 return False;
1899 if(!lsa_io_privilege_set(desc, &out->set, ps, depth))
1900 return False;
1903 if(!prs_ntstatus("status", ps, depth, &out->status))
1904 return False;
1906 return True;
1911 /*******************************************************************
1912 Reads or writes an LSA_Q_GETSYSTEMACCOUNTstructure.
1913 ********************************************************************/
1915 BOOL lsa_io_q_getsystemaccount(const char *desc, LSA_Q_GETSYSTEMACCOUNT *out, prs_struct *ps, int depth)
1917 prs_debug(ps, depth, desc, "lsa_io_q_getsystemaccount");
1918 depth++;
1920 if(!prs_align(ps))
1921 return False;
1923 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1924 return False;
1926 return True;
1929 /*******************************************************************
1930 Reads or writes an LSA_R_GETSYSTEMACCOUNTstructure.
1931 ********************************************************************/
1933 BOOL lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT *out, prs_struct *ps, int depth)
1935 prs_debug(ps, depth, desc, "lsa_io_r_getsystemaccount");
1936 depth++;
1938 if(!prs_align(ps))
1939 return False;
1941 if(!prs_uint32("access", ps, depth, &out->access))
1942 return False;
1944 if(!prs_ntstatus("status", ps, depth, &out->status))
1945 return False;
1947 return True;
1951 /*******************************************************************
1952 Reads or writes an LSA_Q_SETSYSTEMACCOUNT structure.
1953 ********************************************************************/
1955 BOOL lsa_io_q_setsystemaccount(const char *desc, LSA_Q_SETSYSTEMACCOUNT *out, prs_struct *ps, int depth)
1957 prs_debug(ps, depth, desc, "lsa_io_q_setsystemaccount");
1958 depth++;
1960 if(!prs_align(ps))
1961 return False;
1963 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1964 return False;
1966 if(!prs_uint32("access", ps, depth, &out->access))
1967 return False;
1969 return True;
1972 /*******************************************************************
1973 Reads or writes an LSA_R_SETSYSTEMACCOUNT structure.
1974 ********************************************************************/
1976 BOOL lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *out, prs_struct *ps, int depth)
1978 prs_debug(ps, depth, desc, "lsa_io_r_setsystemaccount");
1979 depth++;
1981 if(!prs_align(ps))
1982 return False;
1984 if(!prs_ntstatus("status", ps, depth, &out->status))
1985 return False;
1987 return True;
1991 static void init_lsa_string( LSA_STRING *uni, const char *string )
1993 init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE);
1994 init_uni_hdr(&uni->hdr, &uni->unistring);
1997 void init_lsa_q_lookup_priv_value(LSA_Q_LOOKUP_PRIV_VALUE *q_u, POLICY_HND *hnd, const char *name)
1999 memcpy(&q_u->pol, hnd, sizeof(q_u->pol));
2000 init_lsa_string( &q_u->privname, name );
2003 BOOL smb_io_lsa_string( const char *desc, LSA_STRING *string, prs_struct *ps, int depth )
2005 prs_debug(ps, depth, desc, "smb_io_lsa_string");
2006 depth++;
2008 if(!smb_io_unihdr ("hdr", &string->hdr, ps, depth))
2009 return False;
2010 if(!smb_io_unistr2("unistring", &string->unistring, string->hdr.buffer, ps, depth))
2011 return False;
2013 return True;
2016 /*******************************************************************
2017 Reads or writes an LSA_Q_LOOKUP_PRIV_VALUE structure.
2018 ********************************************************************/
2020 BOOL lsa_io_q_lookup_priv_value(const char *desc, LSA_Q_LOOKUP_PRIV_VALUE *out, prs_struct *ps, int depth)
2022 prs_debug(ps, depth, desc, "lsa_io_q_lookup_priv_value");
2023 depth++;
2025 if(!prs_align(ps))
2026 return False;
2028 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2029 return False;
2030 if(!smb_io_lsa_string("privname", &out->privname, ps, depth))
2031 return False;
2033 return True;
2036 /*******************************************************************
2037 Reads or writes an LSA_R_LOOKUP_PRIV_VALUE structure.
2038 ********************************************************************/
2040 BOOL lsa_io_r_lookup_priv_value(const char *desc, LSA_R_LOOKUP_PRIV_VALUE *out, prs_struct *ps, int depth)
2042 prs_debug(ps, depth, desc, "lsa_io_r_lookup_priv_value");
2043 depth++;
2045 if(!prs_align(ps))
2046 return False;
2048 if(!lsa_io_luid("luid", &out->luid, ps, depth))
2049 return False;
2051 if(!prs_ntstatus("status", ps, depth, &out->status))
2052 return False;
2054 return True;
2058 /*******************************************************************
2059 Reads or writes an LSA_Q_ADDPRIVS structure.
2060 ********************************************************************/
2062 BOOL lsa_io_q_addprivs(const char *desc, LSA_Q_ADDPRIVS *out, prs_struct *ps, int depth)
2064 prs_debug(ps, depth, desc, "lsa_io_q_addprivs");
2065 depth++;
2067 if(!prs_align(ps))
2068 return False;
2070 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2071 return False;
2073 if(!prs_uint32("count", ps, depth, &out->count))
2074 return False;
2076 if (UNMARSHALLING(ps) && out->count!=0) {
2077 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))
2078 return False;
2080 if (!(out->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, out->count)))
2081 return False;
2084 if(!lsa_io_privilege_set(desc, &out->set, ps, depth))
2085 return False;
2087 return True;
2090 /*******************************************************************
2091 Reads or writes an LSA_R_ADDPRIVS structure.
2092 ********************************************************************/
2094 BOOL lsa_io_r_addprivs(const char *desc, LSA_R_ADDPRIVS *out, prs_struct *ps, int depth)
2096 prs_debug(ps, depth, desc, "lsa_io_r_addprivs");
2097 depth++;
2099 if(!prs_align(ps))
2100 return False;
2102 if(!prs_ntstatus("status", ps, depth, &out->status))
2103 return False;
2105 return True;
2108 /*******************************************************************
2109 Reads or writes an LSA_Q_REMOVEPRIVS structure.
2110 ********************************************************************/
2112 BOOL lsa_io_q_removeprivs(const char *desc, LSA_Q_REMOVEPRIVS *out, prs_struct *ps, int depth)
2114 prs_debug(ps, depth, desc, "lsa_io_q_removeprivs");
2115 depth++;
2117 if(!prs_align(ps))
2118 return False;
2120 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2121 return False;
2123 if(!prs_uint32("allrights", ps, depth, &out->allrights))
2124 return False;
2126 if(!prs_uint32("ptr", ps, depth, &out->ptr))
2127 return False;
2130 * JFM: I'm not sure at all if the count is inside the ptr
2131 * never seen one with ptr=0
2134 if (out->ptr!=0) {
2135 if(!prs_uint32("count", ps, depth, &out->count))
2136 return False;
2138 if (UNMARSHALLING(ps) && out->count!=0) {
2139 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))
2140 return False;
2142 if (!(out->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, out->count)))
2143 return False;
2146 if(!lsa_io_privilege_set(desc, &out->set, ps, depth))
2147 return False;
2150 return True;
2153 /*******************************************************************
2154 Reads or writes an LSA_R_REMOVEPRIVS structure.
2155 ********************************************************************/
2157 BOOL lsa_io_r_removeprivs(const char *desc, LSA_R_REMOVEPRIVS *out, prs_struct *ps, int depth)
2159 prs_debug(ps, depth, desc, "lsa_io_r_removeprivs");
2160 depth++;
2162 if(!prs_align(ps))
2163 return False;
2165 if(!prs_ntstatus("status", ps, depth, &out->status))
2166 return False;
2168 return True;
2171 BOOL policy_handle_is_valid(const POLICY_HND *hnd)
2173 POLICY_HND zero_pol;
2175 ZERO_STRUCT(zero_pol);
2176 return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True );
2179 /*******************************************************************
2180 Reads or writes an LSA_DNS_DOM_INFO structure.
2181 ********************************************************************/
2183 BOOL lsa_io_dns_dom_info(const char *desc, LSA_DNS_DOM_INFO *info,
2184 prs_struct *ps, int depth)
2186 prs_debug(ps, depth, desc, "lsa_io_dns_dom_info");
2187 depth++;
2189 if(!prs_align(ps))
2190 return False;
2191 if(!smb_io_unihdr("nb_name", &info->hdr_nb_dom_name, ps, depth))
2192 return False;
2193 if(!smb_io_unihdr("dns_name", &info->hdr_dns_dom_name, ps, depth))
2194 return False;
2195 if(!smb_io_unihdr("forest", &info->hdr_forest_name, ps, depth))
2196 return False;
2198 if(!prs_align(ps))
2199 return False;
2200 if ( !smb_io_uuid("dom_guid", &info->dom_guid, ps, depth) )
2201 return False;
2203 if(!prs_align(ps))
2204 return False;
2205 if(!prs_uint32("dom_sid", ps, depth, &info->ptr_dom_sid))
2206 return False;
2208 if(!smb_io_unistr2("nb_name", &info->uni_nb_dom_name,
2209 info->hdr_nb_dom_name.buffer, ps, depth))
2210 return False;
2211 if(!smb_io_unistr2("dns_name", &info->uni_dns_dom_name,
2212 info->hdr_dns_dom_name.buffer, ps, depth))
2213 return False;
2214 if(!smb_io_unistr2("forest", &info->uni_forest_name,
2215 info->hdr_forest_name.buffer, ps, depth))
2216 return False;
2218 if(!smb_io_dom_sid2("dom_sid", &info->dom_sid, ps, depth))
2219 return False;
2221 return True;
2225 /*******************************************************************
2226 Inits an LSA_Q_QUERY_INFO2 structure.
2227 ********************************************************************/
2229 void init_q_query2(LSA_Q_QUERY_INFO2 *in, POLICY_HND *hnd, uint16 info_class)
2231 DEBUG(5, ("init_q_query2\n"));
2233 memcpy(&in->pol, hnd, sizeof(in->pol));
2235 in->info_class = info_class;
2238 /*******************************************************************
2239 Reads or writes an LSA_Q_QUERY_DNSDOMINFO structure.
2240 ********************************************************************/
2242 BOOL lsa_io_q_query_info2(const char *desc, LSA_Q_QUERY_INFO2 *in, prs_struct *ps, int depth)
2244 prs_debug(ps, depth, desc, "lsa_io_q_query_info2");
2245 depth++;
2247 if(!prs_align(ps))
2248 return False;
2250 if(!smb_io_pol_hnd("pol", &in->pol, ps, depth))
2251 return False;
2253 if(!prs_uint16("info_class", ps, depth, &in->info_class))
2254 return False;
2256 return True;
2259 /*******************************************************************
2260 Reads or writes an LSA_R_QUERY_DNSDOMINFO structure.
2261 ********************************************************************/
2263 BOOL lsa_io_r_query_info2(const char *desc, LSA_R_QUERY_INFO2 *out,
2264 prs_struct *ps, int depth)
2266 prs_debug(ps, depth, desc, "lsa_io_r_query_info2");
2267 depth++;
2269 if(!prs_align(ps))
2270 return False;
2272 if(!prs_uint32("ptr", ps, depth, &out->ptr))
2273 return False;
2274 if(!prs_uint16("info_class", ps, depth, &out->info_class))
2275 return False;
2276 switch(out->info_class) {
2277 case 0x000c:
2278 if (!lsa_io_dns_dom_info("info12", &out->info.dns_dom_info,
2279 ps, depth))
2280 return False;
2281 break;
2282 default:
2283 DEBUG(0,("lsa_io_r_query_info2: unknown info class %d\n",
2284 out->info_class));
2285 return False;
2288 if(!prs_align(ps))
2289 return False;
2290 if(!prs_ntstatus("status", ps, depth, &out->status))
2291 return False;
2293 return True;
2296 /*******************************************************************
2297 Inits an LSA_Q_ENUM_ACCT_RIGHTS structure.
2298 ********************************************************************/
2299 void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS *in,
2300 POLICY_HND *hnd,
2301 uint32 count,
2302 DOM_SID *sid)
2304 DEBUG(5, ("init_q_enum_acct_rights\n"));
2306 in->pol = *hnd;
2307 init_dom_sid2(&in->sid, sid);
2310 /*******************************************************************
2311 ********************************************************************/
2312 NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *out, PRIVILEGE_SET *privileges )
2314 uint32 i;
2315 char *privname;
2316 const char **privname_array = NULL;
2317 int num_priv = 0;
2319 for ( i=0; i<privileges->count; i++ ) {
2320 privname = luid_to_privilege_name( &privileges->set[i].luid );
2321 if ( privname ) {
2322 if ( !add_string_to_array( get_talloc_ctx(), privname, &privname_array, &num_priv ) )
2323 return NT_STATUS_NO_MEMORY;
2327 if ( num_priv ) {
2328 out->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY );
2330 if ( !init_unistr4_array( out->rights, num_priv, privname_array ) )
2331 return NT_STATUS_NO_MEMORY;
2333 out->count = num_priv;
2336 return NT_STATUS_OK;
2339 /*******************************************************************
2340 reads or writes a LSA_Q_ENUM_ACCT_RIGHTS structure.
2341 ********************************************************************/
2342 BOOL lsa_io_q_enum_acct_rights(const char *desc, LSA_Q_ENUM_ACCT_RIGHTS *in, prs_struct *ps, int depth)
2345 if (in == NULL)
2346 return False;
2348 prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_rights");
2349 depth++;
2351 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
2352 return False;
2354 if(!smb_io_dom_sid2("sid", &in->sid, ps, depth))
2355 return False;
2357 return True;
2361 /*******************************************************************
2362 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2363 ********************************************************************/
2364 BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *out, prs_struct *ps, int depth)
2366 prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_rights");
2367 depth++;
2369 if(!prs_uint32("count ", ps, depth, &out->count))
2370 return False;
2372 if ( !prs_pointer("rights", ps, depth, (void**)&out->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2373 return False;
2375 if(!prs_align(ps))
2376 return False;
2378 if(!prs_ntstatus("status", ps, depth, &out->status))
2379 return False;
2381 return True;
2385 /*******************************************************************
2386 Inits an LSA_Q_ADD_ACCT_RIGHTS structure.
2387 ********************************************************************/
2388 void init_q_add_acct_rights( LSA_Q_ADD_ACCT_RIGHTS *in, POLICY_HND *hnd,
2389 DOM_SID *sid, uint32 count, const char **rights )
2391 DEBUG(5, ("init_q_add_acct_rights\n"));
2393 in->pol = *hnd;
2394 init_dom_sid2(&in->sid, sid);
2396 in->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY );
2397 init_unistr4_array( in->rights, count, rights );
2399 in->count = count;
2403 /*******************************************************************
2404 reads or writes a LSA_Q_ADD_ACCT_RIGHTS structure.
2405 ********************************************************************/
2406 BOOL lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *in, prs_struct *ps, int depth)
2408 prs_debug(ps, depth, desc, "lsa_io_q_add_acct_rights");
2409 depth++;
2411 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
2412 return False;
2414 if(!smb_io_dom_sid2("sid", &in->sid, ps, depth))
2415 return False;
2417 if(!prs_uint32("count", ps, depth, &in->count))
2418 return False;
2420 if ( !prs_pointer("rights", ps, depth, (void**)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2421 return False;
2423 return True;
2426 /*******************************************************************
2427 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2428 ********************************************************************/
2429 BOOL lsa_io_r_add_acct_rights(const char *desc, LSA_R_ADD_ACCT_RIGHTS *out, prs_struct *ps, int depth)
2431 prs_debug(ps, depth, desc, "lsa_io_r_add_acct_rights");
2432 depth++;
2434 if(!prs_ntstatus("status", ps, depth, &out->status))
2435 return False;
2437 return True;
2441 /*******************************************************************
2442 Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure.
2443 ********************************************************************/
2444 void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *in,
2445 POLICY_HND *hnd,
2446 DOM_SID *sid,
2447 uint32 removeall,
2448 uint32 count,
2449 const char **rights)
2451 DEBUG(5, ("init_q_remove_acct_rights\n"));
2453 in->pol = *hnd;
2455 init_dom_sid2(&in->sid, sid);
2457 in->removeall = removeall;
2458 in->count = count;
2460 in->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY );
2461 init_unistr4_array( in->rights, count, rights );
2465 /*******************************************************************
2466 reads or writes a LSA_Q_REMOVE_ACCT_RIGHTS structure.
2467 ********************************************************************/
2468 BOOL lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *in, prs_struct *ps, int depth)
2470 prs_debug(ps, depth, desc, "lsa_io_q_remove_acct_rights");
2471 depth++;
2473 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
2474 return False;
2476 if(!smb_io_dom_sid2("sid", &in->sid, ps, depth))
2477 return False;
2479 if(!prs_uint32("removeall", ps, depth, &in->removeall))
2480 return False;
2482 if(!prs_uint32("count", ps, depth, &in->count))
2483 return False;
2485 if ( !prs_pointer("rights", ps, depth, (void**)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2486 return False;
2488 return True;
2491 /*******************************************************************
2492 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2493 ********************************************************************/
2494 BOOL lsa_io_r_remove_acct_rights(const char *desc, LSA_R_REMOVE_ACCT_RIGHTS *out, prs_struct *ps, int depth)
2496 prs_debug(ps, depth, desc, "lsa_io_r_remove_acct_rights");
2497 depth++;
2499 if(!prs_ntstatus("status", ps, depth, &out->status))
2500 return False;
2502 return True;
2505 /*******************************************************************
2506 Inits an LSA_Q_OPEN_TRUSTED_DOMAIN structure.
2507 ********************************************************************/
2509 void init_lsa_q_open_trusted_domain(LSA_Q_OPEN_TRUSTED_DOMAIN *q, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
2511 memcpy(&q->pol, hnd, sizeof(q->pol));
2513 init_dom_sid2(&q->sid, sid);
2514 q->access_mask = desired_access;
2517 /*******************************************************************
2518 ********************************************************************/
2520 #if 0 /* jerry, I think this not correct - gd */
2521 BOOL lsa_io_q_open_trusted_domain(const char *desc, LSA_Q_OPEN_TRUSTED_DOMAIN *in, prs_struct *ps, int depth)
2523 prs_debug(ps, depth, desc, "lsa_io_q_open_trusted_domain");
2524 depth++;
2526 if(!prs_align(ps))
2527 return False;
2529 if (!smb_io_pol_hnd("", &in->handle, ps, depth))
2530 return False;
2532 if(!prs_uint32("count", ps, depth, &in->count))
2533 return False;
2535 if(!smb_io_dom_sid("sid", &in->sid, ps, depth))
2536 return False;
2538 return True;
2540 #endif
2542 /*******************************************************************
2543 Reads or writes an LSA_Q_OPEN_TRUSTED_DOMAIN structure.
2544 ********************************************************************/
2546 BOOL lsa_io_q_open_trusted_domain(const char *desc, LSA_Q_OPEN_TRUSTED_DOMAIN *q_o, prs_struct *ps, int depth)
2548 prs_debug(ps, depth, desc, "lsa_io_q_open_trusted_domain");
2549 depth++;
2551 if(!prs_align(ps))
2552 return False;
2554 if(!smb_io_pol_hnd("pol", &q_o->pol, ps, depth))
2555 return False;
2557 if(!smb_io_dom_sid2("sid", &q_o->sid, ps, depth))
2558 return False;
2560 if(!prs_uint32("access", ps, depth, &q_o->access_mask))
2561 return False;
2563 return True;
2566 /*******************************************************************
2567 Reads or writes an LSA_R_OPEN_TRUSTED_DOMAIN structure.
2568 ********************************************************************/
2570 BOOL lsa_io_r_open_trusted_domain(const char *desc, LSA_R_OPEN_TRUSTED_DOMAIN *out, prs_struct *ps, int depth)
2572 prs_debug(ps, depth, desc, "lsa_io_r_open_trusted_domain");
2573 depth++;
2575 if(!prs_align(ps))
2576 return False;
2578 if (!smb_io_pol_hnd("handle", &out->handle, ps, depth))
2579 return False;
2581 if(!prs_ntstatus("status", ps, depth, &out->status))
2582 return False;
2584 return True;
2587 /*******************************************************************
2588 ********************************************************************/
2590 BOOL lsa_io_q_create_trusted_domain(const char *desc, LSA_Q_CREATE_TRUSTED_DOMAIN *in, prs_struct *ps, int depth)
2592 prs_debug(ps, depth, desc, "lsa_io_q_create_trusted_domain");
2593 depth++;
2595 if(!prs_align(ps))
2596 return False;
2598 if(!smb_io_pol_hnd("", &in->handle, ps, depth))
2599 return False;
2601 if(!prs_unistr4 ("secretname", ps, depth, &in->secretname))
2602 return False;
2603 if(!prs_align(ps))
2604 return False;
2606 if(!prs_uint32("access", ps, depth, &in->access))
2607 return False;
2609 return True;
2612 /*******************************************************************
2613 ********************************************************************/
2615 BOOL lsa_io_r_create_trusted_domain(const char *desc, LSA_R_CREATE_TRUSTED_DOMAIN *out, prs_struct *ps, int depth)
2617 prs_debug(ps, depth, desc, "lsa_io_r_create_trusted_domain");
2618 depth++;
2620 if(!prs_align(ps))
2621 return False;
2623 if (!smb_io_pol_hnd("", &out->handle, ps, depth))
2624 return False;
2626 if(!prs_ntstatus("status", ps, depth, &out->status))
2627 return False;
2629 return True;
2632 /*******************************************************************
2633 ********************************************************************/
2635 BOOL lsa_io_q_create_secret(const char *desc, LSA_Q_CREATE_SECRET *in, prs_struct *ps, int depth)
2637 prs_debug(ps, depth, desc, "lsa_io_q_create_secret");
2638 depth++;
2640 if(!prs_align(ps))
2641 return False;
2643 if(!smb_io_pol_hnd("", &in->handle, ps, depth))
2644 return False;
2646 if(!prs_unistr4 ("secretname", ps, depth, &in->secretname))
2647 return False;
2648 if(!prs_align(ps))
2649 return False;
2651 if(!prs_uint32("access", ps, depth, &in->access))
2652 return False;
2654 return True;
2657 /*******************************************************************
2658 ********************************************************************/
2660 BOOL lsa_io_r_create_secret(const char *desc, LSA_R_CREATE_SECRET *out, prs_struct *ps, int depth)
2662 prs_debug(ps, depth, desc, "lsa_io_r_create_secret");
2663 depth++;
2665 if(!prs_align(ps))
2666 return False;
2668 if (!smb_io_pol_hnd("", &out->handle, ps, depth))
2669 return False;
2671 if(!prs_ntstatus("status", ps, depth, &out->status))
2672 return False;
2674 return True;
2679 /*******************************************************************
2680 ********************************************************************/
2682 static BOOL lsa_io_data_blob( const char *desc, prs_struct *ps, int depth, LSA_DATA_BLOB *blob )
2684 prs_debug(ps, depth, desc, "lsa_io_data_blob");
2685 depth++;
2687 if ( !prs_uint32("size", ps, depth, &blob->size) )
2688 return False;
2689 if ( !prs_uint32("size", ps, depth, &blob->size) )
2690 return False;
2692 if ( !prs_io_unistr2_p(desc, ps, depth, &blob->data) )
2693 return False;
2695 return True;
2698 /*******************************************************************
2699 ********************************************************************/
2701 BOOL lsa_io_q_set_secret(const char *desc, LSA_Q_SET_SECRET *in, prs_struct *ps, int depth)
2703 prs_debug(ps, depth, desc, "lsa_io_q_set_secret");
2704 depth++;
2706 if ( !prs_align(ps) )
2707 return False;
2709 if ( !smb_io_pol_hnd("", &in->handle, ps, depth) )
2710 return False;
2712 if ( !prs_pointer( "old_value", ps, depth, (void*)&in->old_value, sizeof(LSA_DATA_BLOB), (PRS_POINTER_CAST)lsa_io_data_blob ))
2713 return False;
2715 if( !prs_align(ps) )
2716 return False;
2717 if ( !prs_pointer( "old_value", ps, depth, (void*)&in->old_value, sizeof(LSA_DATA_BLOB), (PRS_POINTER_CAST)lsa_io_data_blob ))
2718 return False;
2721 return True;
2724 /*******************************************************************
2725 ********************************************************************/
2727 BOOL lsa_io_r_set_secret(const char *desc, LSA_R_SET_SECRET *out, prs_struct *ps, int depth)
2729 prs_debug(ps, depth, desc, "lsa_io_r_set_secret");
2730 depth++;
2732 if(!prs_ntstatus("status", ps, depth, &out->status))
2733 return False;
2735 return True;
2738 /*******************************************************************
2739 ********************************************************************/
2741 BOOL lsa_io_q_delete_object(const char *desc, LSA_Q_DELETE_OBJECT *in, prs_struct *ps, int depth)
2743 prs_debug(ps, depth, desc, "lsa_io_q_delete_object");
2744 depth++;
2746 if(!prs_align(ps))
2747 return False;
2749 if(!smb_io_pol_hnd("", &in->handle, ps, depth))
2750 return False;
2752 return True;
2755 /*******************************************************************
2756 ********************************************************************/
2758 BOOL lsa_io_r_delete_object(const char *desc, LSA_R_DELETE_OBJECT *out, prs_struct *ps, int depth)
2760 prs_debug(ps, depth, desc, "lsa_io_r_delete_object");
2761 depth++;
2763 if(!prs_ntstatus("status", ps, depth, &out->status))
2764 return False;
2766 return True;
2769 /*******************************************************************
2770 Inits an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO structure.
2771 ********************************************************************/
2773 void init_q_query_trusted_domain_info(LSA_Q_QUERY_TRUSTED_DOMAIN_INFO *q,
2774 POLICY_HND *hnd, uint16 info_class)
2776 DEBUG(5, ("init_q_query_trusted_domain_info\n"));
2778 q->pol = *hnd;
2779 q->info_class = info_class;
2782 /*******************************************************************
2783 Inits an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME structure.
2784 ********************************************************************/
2786 void init_q_query_trusted_domain_info_by_name(LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME *q,
2787 POLICY_HND *hnd, uint16 info_class,
2788 const char *dom_name)
2790 DEBUG(5, ("init_q_query_trusted_domain_info_by_name\n"));
2792 q->pol = *hnd;
2793 init_lsa_string(&q->domain_name, dom_name );
2794 q->info_class = info_class;
2797 /*******************************************************************
2798 Inits an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID structure.
2799 ********************************************************************/
2801 void init_q_query_trusted_domain_info_by_sid(LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID *q,
2802 POLICY_HND *hnd, uint16 info_class,
2803 DOM_SID *dom_sid)
2805 DEBUG(5, ("init_q_query_trusted_domain_info_by_sid\n"));
2807 q->pol = *hnd;
2808 init_dom_sid2(&q->dom_sid, dom_sid);
2809 q->info_class = info_class;
2812 /*******************************************************************
2813 Reads or writes an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO structure.
2814 ********************************************************************/
2816 BOOL lsa_io_q_query_trusted_domain_info(const char *desc,
2817 LSA_Q_QUERY_TRUSTED_DOMAIN_INFO *q_q,
2818 prs_struct *ps, int depth)
2820 prs_debug(ps, depth, desc, "lsa_io_q_query_trusted_domain_info");
2821 depth++;
2823 if(!prs_align(ps))
2824 return False;
2826 if(!smb_io_pol_hnd("pol", &q_q->pol, ps, depth))
2827 return False;
2829 if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
2830 return False;
2832 return True;
2836 /*******************************************************************
2837 Reads or writes an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID structure.
2838 ********************************************************************/
2840 BOOL lsa_io_q_query_trusted_domain_info_by_sid(const char *desc,
2841 LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID *q_q,
2842 prs_struct *ps, int depth)
2844 prs_debug(ps, depth, desc, "lsa_io_q_query_trusted_domain_info_by_sid");
2845 depth++;
2847 if(!prs_align(ps))
2848 return False;
2850 if(!smb_io_pol_hnd("pol", &q_q->pol, ps, depth))
2851 return False;
2853 if(!prs_align(ps))
2854 return False;
2856 if(!smb_io_dom_sid2("dom_sid", &q_q->dom_sid, ps, depth))
2857 return False;
2859 if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
2860 return False;
2862 return True;
2865 /*******************************************************************
2866 Reads or writes an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME structure.
2867 ********************************************************************/
2869 BOOL lsa_io_q_query_trusted_domain_info_by_name(const char *desc,
2870 LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME *q_q,
2871 prs_struct *ps, int depth)
2873 prs_debug(ps, depth, desc, "lsa_io_q_query_trusted_domain_info_by_name");
2874 depth++;
2876 if(!prs_align(ps))
2877 return False;
2879 if(!smb_io_pol_hnd("pol", &q_q->pol, ps, depth))
2880 return False;
2882 if(!prs_align(ps))
2883 return False;
2885 if(!smb_io_lsa_string("domain_name", &q_q->domain_name, ps, depth))
2886 return False;
2888 if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
2889 return False;
2891 return True;
2894 /*******************************************************************
2895 ********************************************************************/
2897 static BOOL smb_io_lsa_data_buf_hdr(const char *desc, LSA_DATA_BUF_HDR *buf_hdr,
2898 prs_struct *ps, int depth)
2900 prs_debug(ps, depth, desc, "smb_io_lsa_data_buf_hdr");
2901 depth++;
2903 if(!prs_align(ps))
2904 return False;
2906 if(!prs_uint32("length", ps, depth, &buf_hdr->length))
2907 return False;
2909 if(!prs_uint32("size", ps, depth, &buf_hdr->size))
2910 return False;
2912 if (!prs_uint32("data_ptr", ps, depth, &buf_hdr->data_ptr))
2913 return False;
2915 return True;
2918 /*******************************************************************
2919 ********************************************************************/
2921 static BOOL smb_io_lsa_data_buf(const char *desc, LSA_DATA_BUF *buf,
2922 prs_struct *ps, int depth, int length, int size)
2924 prs_debug(ps, depth, desc, "smb_io_lsa_data_buf");
2925 depth++;
2927 if ( UNMARSHALLING(ps) ) {
2928 if ( !(buf->data = PRS_ALLOC_MEM( ps, uint8, length )) )
2929 return False;
2932 if (!prs_uint32("size", ps, depth, &buf->size))
2933 return False;
2935 if (!prs_uint32("offset", ps, depth, &buf->offset))
2936 return False;
2938 if (!prs_uint32("length", ps, depth, &buf->length))
2939 return False;
2941 if(!prs_uint8s(False, "data", ps, depth, buf->data, size))
2942 return False;
2944 return True;
2947 /*******************************************************************
2948 ********************************************************************/
2950 static BOOL lsa_io_trustdom_query_1(const char *desc, TRUSTED_DOMAIN_INFO_NAME *name,
2951 prs_struct *ps, int depth)
2953 if (!smb_io_lsa_string("netbios_name", &name->netbios_name, ps, depth))
2954 return False;
2956 return True;
2959 /*******************************************************************
2960 ********************************************************************/
2962 static BOOL lsa_io_trustdom_query_3(const char *desc, TRUSTED_DOMAIN_INFO_POSIX_OFFSET *posix,
2963 prs_struct *ps, int depth)
2965 if(!prs_uint32("posix_offset", ps, depth, &posix->posix_offset))
2966 return False;
2968 return True;
2971 /*******************************************************************
2972 ********************************************************************/
2974 static BOOL lsa_io_trustdom_query_4(const char *desc, TRUSTED_DOMAIN_INFO_PASSWORD *password,
2975 prs_struct *ps, int depth)
2977 if(!prs_align(ps))
2978 return False;
2980 if(!prs_uint32("ptr_password", ps, depth, &password->ptr_password))
2981 return False;
2983 if(!prs_uint32("ptr_old_password", ps, depth, &password->ptr_old_password))
2984 return False;
2986 if (&password->ptr_password) {
2988 if (!smb_io_lsa_data_buf_hdr("password_hdr", &password->password_hdr, ps, depth))
2989 return False;
2991 if (!smb_io_lsa_data_buf("password", &password->password, ps, depth,
2992 password->password_hdr.length, password->password_hdr.size))
2993 return False;
2996 if (&password->ptr_old_password) {
2998 if (!smb_io_lsa_data_buf_hdr("old_password_hdr", &password->old_password_hdr, ps, depth))
2999 return False;
3001 if (!smb_io_lsa_data_buf("old_password", &password->old_password, ps, depth,
3002 password->old_password_hdr.length, password->old_password_hdr.size))
3003 return False;
3006 return True;
3009 /*******************************************************************
3010 ********************************************************************/
3012 static BOOL lsa_io_trustdom_query(const char *desc, prs_struct *ps, int depth, LSA_TRUSTED_DOMAIN_INFO *info)
3014 prs_debug(ps, depth, desc, "lsa_io_trustdom_query");
3015 depth++;
3017 if(!prs_uint16("info_class", ps, depth, &info->info_class))
3018 return False;
3020 if(!prs_align(ps))
3021 return False;
3023 switch (info->info_class) {
3024 case 1:
3025 if(!lsa_io_trustdom_query_1("name", &info->name, ps, depth))
3026 return False;
3027 break;
3028 case 3:
3029 if(!lsa_io_trustdom_query_3("posix_offset", &info->posix_offset, ps, depth))
3030 return False;
3031 break;
3032 case 4:
3033 if(!lsa_io_trustdom_query_4("password", &info->password, ps, depth))
3034 return False;
3035 break;
3036 default:
3037 DEBUG(0,("unsupported info-level: %d\n", info->info_class));
3038 return False;
3041 return True;
3044 /*******************************************************************
3045 Reads or writes an LSA_R_QUERY_TRUSTED_DOMAIN_INFO structure.
3046 ********************************************************************/
3048 BOOL lsa_io_r_query_trusted_domain_info(const char *desc,
3049 LSA_R_QUERY_TRUSTED_DOMAIN_INFO *r_q,
3050 prs_struct *ps, int depth)
3052 if (r_q == NULL)
3053 return False;
3055 prs_debug(ps, depth, desc, "lsa_io_r_query_trusted_domain_info");
3056 depth++;
3058 if (!prs_pointer("trustdom", ps, depth, (void**)&r_q->info,
3059 sizeof(LSA_TRUSTED_DOMAIN_INFO),
3060 (PRS_POINTER_CAST)lsa_io_trustdom_query) )
3061 return False;
3063 if(!prs_align(ps))
3064 return False;
3066 if(!prs_ntstatus("status", ps, depth, &r_q->status))
3067 return False;
3069 return True;