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.
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,
53 prs_debug(ps, depth, desc, "lsa_io_trans_name");
59 if(!prs_uint16("sid_name_use", ps, depth, &trn->sid_name_use))
64 if(!smb_io_unihdr ("hdr_name", &trn->hdr_name, ps, depth))
66 if(!prs_uint32("domain_idx ", ps, depth, &trn->domain_idx))
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)
80 prs_debug(ps, depth, desc, "lsa_io_dom_r_ref");
86 if(!prs_uint32("num_ref_doms_1", ps, depth, &dom->num_ref_doms_1)) /* num referenced domains? */
88 if(!prs_uint32("ptr_ref_dom ", ps, depth, &dom->ptr_ref_dom)) /* undocumented buffer pointer. */
90 if(!prs_uint32("max_entries ", ps, depth, &dom->max_entries)) /* 32 - max number of entries */
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? */
100 SMB_ASSERT_ARRAY(dom->ref_dom, dom->num_ref_doms_2);
102 for (i = 0; i < dom->num_ref_doms_1; i++) {
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))
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))
114 for (i = 0; i < dom->num_ref_doms_2; i++) {
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 */
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 */
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,
159 prs_debug(ps, depth, desc, "lsa_io_obj_qos");
165 start = prs_offset(ps);
167 /* these pointers had _better_ be zero, because we don't know
170 if(!prs_uint32("len ", ps, depth, &qos->len)) /* 0x18 - length (in bytes) inc. the length field. */
172 if(!prs_uint16("sec_imp_level ", ps, depth, &qos->sec_imp_level ))
174 if(!prs_uint8 ("sec_ctxt_mode ", ps, depth, &qos->sec_ctxt_mode ))
176 if(!prs_uint8 ("effective_only", ps, depth, &qos->effective_only))
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));
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;
202 attr->ptr_sec_qos = 1;
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,
217 prs_debug(ps, depth, desc, "lsa_io_obj_attr");
223 /* these pointers had _better_ be zero, because we don't know
226 if(!prs_uint32("len ", ps, depth, &attr->len)) /* 0x18 - length (in bytes) inc. the length field. */
228 if(!prs_uint32("ptr_root_dir", ps, depth, &attr->ptr_root_dir)) /* 0 - root directory (pointer) */
230 if(!prs_uint32("ptr_obj_name", ps, depth, &attr->ptr_obj_name)) /* 0 - object name (pointer) */
232 if(!prs_uint32("attributes ", ps, depth, &attr->attributes)) /* 0 - attributes (undocumented) */
234 if(!prs_uint32("ptr_sec_desc", ps, depth, &attr->ptr_sec_desc)) /* 0 - security descriptior (pointer) */
236 if(!prs_uint32("ptr_sec_qos ", ps, depth, &attr->ptr_sec_qos )) /* security quality of service (pointer) */
239 if (attr->ptr_sec_qos != 0) {
240 if (UNMARSHALLING(ps))
241 if (!(attr->sec_qos = PRS_ALLOC_MEM(ps,LSA_SEC_QOS,1)))
244 if(!lsa_io_sec_qos("sec_qos", attr->sec_qos, ps, depth))
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,
260 DEBUG(5, ("init_open_pol: attr:%d da:%d\n", attributes,
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,
278 prs_debug(ps, depth, desc, "lsa_io_q_open_pol");
281 if(!prs_uint32("ptr ", ps, depth, &in->ptr))
283 if(!prs_uint16("system_name", ps, depth, &in->system_name))
288 if(!lsa_io_obj_attr("", &in->attr, ps, depth))
291 if(!prs_uint32("des_access", ps, depth, &in->des_access))
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,
304 prs_debug(ps, depth, desc, "lsa_io_r_open_pol");
307 if(!smb_io_pol_hnd("", &out->pol, ps, depth))
310 if(!prs_ntstatus("status", ps, depth, &out->status))
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,
324 DEBUG(5, ("init_q_open_pol2: attr:%d da:%d\n", attributes,
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,
343 prs_debug(ps, depth, desc, "lsa_io_q_open_pol2");
346 if(!prs_uint32("ptr ", ps, depth, &in->ptr))
349 if(!smb_io_unistr2 ("", &in->uni_server_name, in->ptr, ps, depth))
351 if(!lsa_io_obj_attr("", &in->attr, ps, depth))
354 if(!prs_uint32("des_access", ps, depth, &in->des_access))
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,
367 prs_debug(ps, depth, desc, "lsa_io_r_open_pol2");
370 if(!smb_io_pol_hnd("", &out->pol, ps, depth))
373 if(!prs_ntstatus("status", ps, depth, &out->status))
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,
386 DEBUG(5, ("init_q_query_sec_obj\n"));
389 in->sec_info = sec_info;
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");
404 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
407 if (!prs_uint32("sec_info", ps, depth, &in->sec_info))
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");
425 if (!prs_uint32("ptr", ps, depth, &out->ptr))
429 if (!sec_io_desc_buf("sec", &out->buf, ps, depth))
433 if (!prs_ntstatus("status", ps, depth, &out->status))
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,
459 prs_debug(ps, depth, desc, "lsa_io_q_query");
462 if(!smb_io_pol_hnd("", &in->pol, ps, depth))
465 if(!prs_uint16("info_class", ps, depth, &in->info_class))
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"));
480 q_e->enum_context = enum_context;
481 q_e->preferred_len = preferred_len;
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");
496 if(!smb_io_pol_hnd("", &q_e->pol, ps, depth))
499 if(!prs_uint32("enum_context ", ps, depth, &q_e->enum_context))
501 if(!prs_uint32("preferred_len", ps, depth, &q_e->preferred_len))
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,
512 uint32 enum_context, uint32 num_domains,
513 struct trustdom_info **td)
517 DEBUG(5, ("init_r_enum_trust_dom\n"));
519 out->enum_context = enum_context;
520 out->count = num_domains;
522 if ( num_domains != 0 ) {
524 /* allocate container memory */
526 out->domlist = TALLOC_P( ctx, DOMAIN_LIST );
527 out->domlist->domains = TALLOC_ARRAY( ctx, DOMAIN_INFO,
530 if ( !out->domlist || !out->domlist->domains ) {
531 out->status = NT_STATUS_NO_MEMORY;
535 out->domlist->count = out->count;
537 /* initialize the list of domains and their sid */
539 for (i = 0; i < num_domains; i++) {
541 if ( !(out->domlist->domains[i].sid =
542 TALLOC_P(ctx, DOM_SID2)) ) {
543 out->status = NT_STATUS_NO_MEMORY;
547 init_dom_sid2(out->domlist->domains[i].sid,
549 if (push_ucs2_talloc(ctx, &name, (td[i])->name) < 0){
550 out->status = NT_STATUS_NO_MEMORY;
553 init_unistr4_w(ctx, &out->domlist->domains[i].name,
560 /*******************************************************************
561 ********************************************************************/
563 BOOL lsa_io_domain_list( const char *desc, prs_struct *ps, int depth, DOMAIN_LIST *domlist )
567 prs_debug(ps, depth, desc, "lsa_io_domain_list");
570 if(!prs_uint32("count", ps, depth, &domlist->count))
573 if ( domlist->count == 0 )
576 if ( UNMARSHALLING(ps) ) {
577 if ( !(domlist->domains = PRS_ALLOC_MEM( ps, DOMAIN_INFO, domlist->count )) )
583 for ( i=0; i<domlist->count; i++ ) {
584 if ( !prs_unistr4_hdr("name_header", ps, depth, &domlist->domains[i].name) )
586 if ( !smb_io_dom_sid2_p("sid_header", ps, depth, &domlist->domains[i].sid) )
592 for ( i=0; i<domlist->count; i++ ) {
593 if ( !prs_unistr4_str("name", ps, depth, &domlist->domains[i].name) )
595 if( !smb_io_dom_sid2("sid", domlist->domains[i].sid, ps, depth) )
602 /*******************************************************************
603 Reads or writes an LSA_R_ENUM_TRUST_DOM structure.
604 ********************************************************************/
606 BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *out,
607 prs_struct *ps, int depth)
609 prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom");
612 if(!prs_uint32("enum_context", ps, depth, &out->enum_context))
615 if(!prs_uint32("count", ps, depth, &out->count))
618 if ( !prs_pointer("trusted_domains", ps, depth, (void**)&out->domlist, sizeof(DOMAIN_LIST), (PRS_POINTER_CAST)lsa_io_domain_list))
621 if(!prs_ntstatus("status", ps, depth, &out->status))
627 /*******************************************************************
628 reads or writes a dom query structure.
629 ********************************************************************/
631 static BOOL lsa_io_dom_query(const char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth)
636 prs_debug(ps, depth, desc, "lsa_io_dom_query");
642 if(!prs_uint16("uni_dom_max_len", ps, depth, &d_q->uni_dom_max_len)) /* domain name string length * 2 */
644 if(!prs_uint16("uni_dom_str_len", ps, depth, &d_q->uni_dom_str_len)) /* domain name string length * 2 */
647 if(!prs_uint32("buffer_dom_name", ps, depth, &d_q->buffer_dom_name)) /* undocumented domain name string buffer pointer */
649 if(!prs_uint32("buffer_dom_sid ", ps, depth, &d_q->buffer_dom_sid)) /* undocumented domain SID string buffer pointer */
652 if(!smb_io_unistr2("unistr2", &d_q->uni_domain_name, d_q->buffer_dom_name, ps, depth)) /* domain name (unicode string) */
658 if (d_q->buffer_dom_sid != 0) {
659 if(!smb_io_dom_sid2("", &d_q->dom_sid, ps, depth)) /* domain SID */
662 memset((char *)&d_q->dom_sid, '\0', sizeof(d_q->dom_sid));
668 /*******************************************************************
669 reads or writes a structure.
670 ********************************************************************/
672 static BOOL lsa_io_dom_query_2(const char *desc, DOM_QUERY_2 *d_q, prs_struct *ps, int depth)
679 prs_debug(ps, depth, desc, "lsa_io_dom_query_2");
685 if (!prs_uint32("auditing_enabled", ps, depth, &d_q->auditing_enabled))
687 if (!prs_uint32("ptr ", ps, depth, &ptr))
689 if (!prs_uint32("count1", ps, depth, &d_q->count1))
691 if (!prs_uint32("count2", ps, depth, &d_q->count2))
694 if (UNMARSHALLING(ps)) {
695 d_q->auditsettings = TALLOC_ZERO_ARRAY(ps->mem_ctx, uint32, d_q->count2);
698 if (d_q->auditsettings == NULL) {
699 DEBUG(1, ("lsa_io_dom_query_2: NULL auditsettings!\n"));
703 if (!prs_uint32s(False, "auditsettings", ps, depth, d_q->auditsettings, d_q->count2))
709 /*******************************************************************
710 Reads or writes a dom query structure.
711 ********************************************************************/
713 static BOOL lsa_io_dom_query_3(const char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
715 return lsa_io_dom_query("", d_q, ps, depth);
718 /*******************************************************************
719 Reads or writes a dom query structure.
720 ********************************************************************/
722 static BOOL lsa_io_dom_query_5(const char *desc, DOM_QUERY_5 *d_q, prs_struct *ps, int depth)
724 return lsa_io_dom_query("", d_q, ps, depth);
727 /*******************************************************************
728 Reads or writes a dom query structure.
729 ********************************************************************/
731 static BOOL lsa_io_dom_query_6(const char *desc, DOM_QUERY_6 *d_q, prs_struct *ps, int depth)
736 prs_debug(ps, depth, desc, "lsa_io_dom_query_6");
739 if (!prs_uint16("server_role", ps, depth, &d_q->server_role))
745 /*******************************************************************
746 Reads or writes an LSA_R_QUERY_INFO structure.
747 ********************************************************************/
749 BOOL lsa_io_r_query(const char *desc, LSA_R_QUERY_INFO *out, prs_struct *ps, int depth)
751 prs_debug(ps, depth, desc, "lsa_io_r_query");
754 if(!prs_uint32("undoc_buffer", ps, depth, &out->undoc_buffer))
757 if (out->undoc_buffer != 0) {
758 if(!prs_uint16("info_class", ps, depth, &out->info_class))
764 switch (out->info_class) {
766 if(!lsa_io_dom_query_2("", &out->dom.id2, ps, depth))
770 if(!lsa_io_dom_query_3("", &out->dom.id3, ps, depth))
774 if(!lsa_io_dom_query_5("", &out->dom.id5, ps, depth))
778 if(!lsa_io_dom_query_6("", &out->dom.id6, ps, depth))
790 if(!prs_ntstatus("status", ps, depth, &out->status))
796 /*******************************************************************
797 Inits a LSA_SID_ENUM structure.
798 ********************************************************************/
800 static void init_lsa_sid_enum(TALLOC_CTX *mem_ctx, LSA_SID_ENUM *sen,
801 int num_entries, const DOM_SID *sids)
805 DEBUG(5, ("init_lsa_sid_enum\n"));
807 sen->num_entries = num_entries;
808 sen->ptr_sid_enum = (num_entries != 0);
809 sen->num_entries2 = num_entries;
811 /* Allocate memory for sids and sid pointers */
813 if (num_entries == 0) return;
815 if ((sen->ptr_sid = TALLOC_ZERO_ARRAY(mem_ctx, uint32, num_entries )) == NULL) {
816 DEBUG(3, ("init_lsa_sid_enum(): out of memory for ptr_sid\n"));
820 if ((sen->sid = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID2, num_entries)) == NULL) {
821 DEBUG(3, ("init_lsa_sid_enum(): out of memory for sids\n"));
825 /* Copy across SIDs and SID pointers */
827 for (i = 0; i < num_entries; i++) {
829 init_dom_sid2(&sen->sid[i], &sids[i]);
833 /*******************************************************************
834 Reads or writes a LSA_SID_ENUM structure.
835 ********************************************************************/
837 static BOOL lsa_io_sid_enum(const char *desc, LSA_SID_ENUM *sen, prs_struct *ps,
842 prs_debug(ps, depth, desc, "lsa_io_sid_enum");
848 if(!prs_uint32("num_entries ", ps, depth, &sen->num_entries))
850 if(!prs_uint32("ptr_sid_enum", ps, depth, &sen->ptr_sid_enum))
854 if the ptr is NULL, leave here. checked from a real w2k trace.
858 if (sen->ptr_sid_enum==0)
861 if(!prs_uint32("num_entries2", ps, depth, &sen->num_entries2))
864 /* Mallocate memory if we're unpacking from the wire */
866 if (UNMARSHALLING(ps)) {
867 if ((sen->ptr_sid = PRS_ALLOC_MEM( ps, uint32, sen->num_entries)) == NULL) {
868 DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
873 if ((sen->sid = PRS_ALLOC_MEM( ps, DOM_SID2, sen->num_entries)) == NULL) {
874 DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
880 for (i = 0; i < sen->num_entries; i++) {
883 slprintf(temp, sizeof(temp) - 1, "ptr_sid[%d]", i);
884 if(!prs_uint32(temp, ps, depth, &sen->ptr_sid[i])) {
889 for (i = 0; i < sen->num_entries; i++) {
892 slprintf(temp, sizeof(temp) - 1, "sid[%d]", i);
893 if(!smb_io_dom_sid2(temp, &sen->sid[i], ps, depth)) {
901 /*******************************************************************
902 Inits an LSA_R_ENUM_TRUST_DOM structure.
903 ********************************************************************/
905 void init_q_lookup_sids(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_SIDS *q_l,
906 POLICY_HND *hnd, int num_sids, const DOM_SID *sids,
909 DEBUG(5, ("init_q_lookup_sids\n"));
913 memcpy(&q_l->pol, hnd, sizeof(q_l->pol));
914 init_lsa_sid_enum(mem_ctx, &q_l->sids, num_sids, sids);
919 /*******************************************************************
920 Reads or writes a LSA_Q_LOOKUP_SIDS structure.
921 ********************************************************************/
923 BOOL lsa_io_q_lookup_sids(const char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps,
926 prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids");
932 if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */
934 if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */
936 if(!lsa_io_trans_names("names ", &q_s->names, ps, depth)) /* translated names */
939 if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */
944 if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count))
950 /*******************************************************************
951 Reads or writes a structure.
952 ********************************************************************/
954 static BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn,
955 prs_struct *ps, int depth)
959 prs_debug(ps, depth, desc, "lsa_io_trans_names");
965 if(!prs_uint32("num_entries ", ps, depth, &trn->num_entries))
967 if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names))
970 if (trn->ptr_trans_names != 0) {
971 if(!prs_uint32("num_entries2 ", ps, depth,
975 if (UNMARSHALLING(ps)) {
976 if ((trn->name = PRS_ALLOC_MEM(ps, LSA_TRANS_NAME, trn->num_entries)) == NULL) {
980 if ((trn->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, trn->num_entries)) == NULL) {
985 for (i = 0; i < trn->num_entries2; i++) {
987 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
989 if(!lsa_io_trans_name(t, &trn->name[i], ps, depth)) /* translated name */
993 for (i = 0; i < trn->num_entries2; i++) {
995 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
997 if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth))
1007 /*******************************************************************
1008 Reads or writes a structure.
1009 ********************************************************************/
1011 BOOL lsa_io_r_lookup_sids(const char *desc, LSA_R_LOOKUP_SIDS *r_s,
1012 prs_struct *ps, int depth)
1014 prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids");
1020 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref))
1023 if (r_s->ptr_dom_ref != 0)
1024 if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */
1027 if(!lsa_io_trans_names("names ", r_s->names, ps, depth)) /* translated names */
1033 if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count))
1036 if(!prs_ntstatus("status ", ps, depth, &r_s->status))
1042 /*******************************************************************
1044 ********************************************************************/
1046 void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l,
1047 POLICY_HND *hnd, int num_names, const char **names)
1051 DEBUG(5, ("init_q_lookup_names\n"));
1056 q_l->num_entries = num_names;
1057 q_l->num_entries2 = num_names;
1058 q_l->lookup_level = 1;
1060 if ((q_l->uni_name = TALLOC_ZERO_ARRAY(mem_ctx, UNISTR2, num_names)) == NULL) {
1061 DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1065 if ((q_l->hdr_name = TALLOC_ZERO_ARRAY(mem_ctx, UNIHDR, num_names)) == NULL) {
1066 DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1070 for (i = 0; i < num_names; i++) {
1071 init_unistr2(&q_l->uni_name[i], names[i], UNI_FLAGS_NONE);
1072 init_uni_hdr(&q_l->hdr_name[i], &q_l->uni_name[i]);
1076 /*******************************************************************
1077 reads or writes a structure.
1078 ********************************************************************/
1080 BOOL lsa_io_q_lookup_names(const char *desc, LSA_Q_LOOKUP_NAMES *q_r,
1081 prs_struct *ps, int depth)
1085 prs_debug(ps, depth, desc, "lsa_io_q_lookup_names");
1091 if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */
1096 if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries))
1098 if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2))
1101 if (UNMARSHALLING(ps)) {
1102 if (q_r->num_entries) {
1103 if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)
1105 if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)
1110 for (i = 0; i < q_r->num_entries; i++) {
1113 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1117 for (i = 0; i < q_r->num_entries; i++) {
1120 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1126 if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1128 if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1130 if(!prs_uint32("lookup_level ", ps, depth, &q_r->lookup_level))
1132 if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count))
1138 /*******************************************************************
1139 reads or writes a structure.
1140 ********************************************************************/
1142 BOOL lsa_io_r_lookup_names(const char *desc, LSA_R_LOOKUP_NAMES *out, prs_struct *ps, int depth)
1146 prs_debug(ps, depth, desc, "lsa_io_r_lookup_names");
1152 if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref))
1155 if (out->ptr_dom_ref != 0)
1156 if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth))
1159 if(!prs_uint32("num_entries", ps, depth, &out->num_entries))
1161 if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries))
1164 if (out->ptr_entries != 0) {
1165 if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2))
1168 if (out->num_entries2 != out->num_entries) {
1173 if (UNMARSHALLING(ps)) {
1174 if ((out->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID2, out->num_entries2))
1176 DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n"));
1181 for (i = 0; i < out->num_entries2; i++)
1182 if(!smb_io_dom_rid2("", &out->dom_rid[i], ps, depth)) /* domain RIDs being looked up */
1186 if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count))
1189 if(!prs_ntstatus("status ", ps, depth, &out->status))
1196 /*******************************************************************
1197 Inits an LSA_Q_CLOSE structure.
1198 ********************************************************************/
1200 void init_lsa_q_close(LSA_Q_CLOSE *in, POLICY_HND *hnd)
1202 DEBUG(5, ("init_lsa_q_close\n"));
1204 memcpy(&in->pol, hnd, sizeof(in->pol));
1207 /*******************************************************************
1208 Reads or writes an LSA_Q_CLOSE structure.
1209 ********************************************************************/
1211 BOOL lsa_io_q_close(const char *desc, LSA_Q_CLOSE *in, prs_struct *ps, int depth)
1213 prs_debug(ps, depth, desc, "lsa_io_q_close");
1216 if(!smb_io_pol_hnd("", &in->pol, ps, depth))
1222 /*******************************************************************
1223 Reads or writes an LSA_R_CLOSE structure.
1224 ********************************************************************/
1226 BOOL lsa_io_r_close(const char *desc, LSA_R_CLOSE *out, prs_struct *ps, int depth)
1228 prs_debug(ps, depth, desc, "lsa_io_r_close");
1231 if(!smb_io_pol_hnd("", &out->pol, ps, depth))
1234 if(!prs_ntstatus("status", ps, depth, &out->status))
1240 /*******************************************************************
1241 Reads or writes an LSA_Q_OPEN_SECRET structure.
1242 ********************************************************************/
1244 BOOL lsa_io_q_open_secret(const char *desc, LSA_Q_OPEN_SECRET *in, prs_struct *ps, int depth)
1246 prs_debug(ps, depth, desc, "lsa_io_q_open_secret");
1252 if(!smb_io_pol_hnd("", &in->handle, ps, depth))
1255 if(!prs_unistr4 ("secretname", ps, depth, &in->secretname))
1260 if(!prs_uint32("access", ps, depth, &in->access))
1266 /*******************************************************************
1267 Reads or writes an LSA_R_OPEN_SECRET structure.
1268 ********************************************************************/
1270 BOOL lsa_io_r_open_secret(const char *desc, LSA_R_OPEN_SECRET *out, prs_struct *ps, int depth)
1272 prs_debug(ps, depth, desc, "lsa_io_r_open_secret");
1278 if(!smb_io_pol_hnd("", &out->handle, ps, depth))
1281 if(!prs_ntstatus("status", ps, depth, &out->status))
1287 /*******************************************************************
1288 Inits an LSA_Q_ENUM_PRIVS structure.
1289 ********************************************************************/
1291 void init_q_enum_privs(LSA_Q_ENUM_PRIVS *in, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1293 DEBUG(5, ("init_q_enum_privs\n"));
1295 memcpy(&in->pol, hnd, sizeof(in->pol));
1297 in->enum_context = enum_context;
1298 in->pref_max_length = pref_max_length;
1301 /*******************************************************************
1302 reads or writes a structure.
1303 ********************************************************************/
1304 BOOL lsa_io_q_enum_privs(const char *desc, LSA_Q_ENUM_PRIVS *in, prs_struct *ps, int depth)
1309 prs_debug(ps, depth, desc, "lsa_io_q_enum_privs");
1312 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
1315 if(!prs_uint32("enum_context ", ps, depth, &in->enum_context))
1317 if(!prs_uint32("pref_max_length", ps, depth, &in->pref_max_length))
1323 /*******************************************************************
1324 reads or writes a structure.
1325 ********************************************************************/
1326 static BOOL lsa_io_priv_entries(const char *desc, LSA_PRIV_ENTRY *entries, uint32 count, prs_struct *ps, int depth)
1330 if (entries == NULL)
1333 prs_debug(ps, depth, desc, "lsa_io_priv_entries");
1339 for (i = 0; i < count; i++) {
1340 if (!smb_io_unihdr("", &entries[i].hdr_name, ps, depth))
1342 if(!prs_uint32("luid_low ", ps, depth, &entries[i].luid_low))
1344 if(!prs_uint32("luid_high", ps, depth, &entries[i].luid_high))
1348 for (i = 0; i < count; i++)
1349 if (!smb_io_unistr2("", &entries[i].name, entries[i].hdr_name.buffer, ps, depth))
1355 /*******************************************************************
1356 Inits an LSA_R_ENUM_PRIVS structure.
1357 ********************************************************************/
1359 void init_lsa_r_enum_privs(LSA_R_ENUM_PRIVS *out, uint32 enum_context,
1360 uint32 count, LSA_PRIV_ENTRY *entries)
1362 DEBUG(5, ("init_lsa_r_enum_privs\n"));
1364 out->enum_context=enum_context;
1367 if (entries!=NULL) {
1378 /*******************************************************************
1379 reads or writes a structure.
1380 ********************************************************************/
1381 BOOL lsa_io_r_enum_privs(const char *desc, LSA_R_ENUM_PRIVS *out, prs_struct *ps, int depth)
1386 prs_debug(ps, depth, desc, "lsa_io_r_enum_privs");
1392 if(!prs_uint32("enum_context", ps, depth, &out->enum_context))
1394 if(!prs_uint32("count", ps, depth, &out->count))
1396 if(!prs_uint32("ptr", ps, depth, &out->ptr))
1400 if(!prs_uint32("count1", ps, depth, &out->count1))
1403 if (UNMARSHALLING(ps))
1404 if (!(out->privs = PRS_ALLOC_MEM(ps, LSA_PRIV_ENTRY, out->count1)))
1407 if (!lsa_io_priv_entries("", out->privs, out->count1, ps, depth))
1414 if(!prs_ntstatus("status", ps, depth, &out->status))
1420 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)
1422 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1424 init_unistr2(&trn->name, name, UNI_FLAGS_NONE);
1425 init_uni_hdr(&trn->hdr_name, &trn->name);
1426 trn->lang_id = lang_id;
1427 trn->lang_id_sys = lang_id_sys;
1430 /*******************************************************************
1431 reads or writes a structure.
1432 ********************************************************************/
1433 BOOL lsa_io_q_priv_get_dispname(const char *desc, LSA_Q_PRIV_GET_DISPNAME *in, prs_struct *ps, int depth)
1438 prs_debug(ps, depth, desc, "lsa_io_q_priv_get_dispname");
1444 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
1447 if (!smb_io_unihdr("hdr_name", &in->hdr_name, ps, depth))
1450 if (!smb_io_unistr2("name", &in->name, in->hdr_name.buffer, ps, depth))
1453 if(!prs_uint16("lang_id ", ps, depth, &in->lang_id))
1455 if(!prs_uint16("lang_id_sys", ps, depth, &in->lang_id_sys))
1461 /*******************************************************************
1462 reads or writes a structure.
1463 ********************************************************************/
1464 BOOL lsa_io_r_priv_get_dispname(const char *desc, LSA_R_PRIV_GET_DISPNAME *out, prs_struct *ps, int depth)
1469 prs_debug(ps, depth, desc, "lsa_io_r_priv_get_dispname");
1475 if (!prs_uint32("ptr_info", ps, depth, &out->ptr_info))
1479 if (!smb_io_unihdr("hdr_name", &out->hdr_desc, ps, depth))
1482 if (!smb_io_unistr2("desc", &out->desc, out->hdr_desc.buffer, ps, depth))
1489 if(!prs_uint16("lang_id", ps, depth, &out->lang_id))
1494 if(!prs_ntstatus("status", ps, depth, &out->status))
1501 initialise a LSA_Q_ENUM_ACCOUNTS structure
1503 void init_lsa_q_enum_accounts(LSA_Q_ENUM_ACCOUNTS *trn, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1505 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1507 trn->enum_context = enum_context;
1508 trn->pref_max_length = pref_max_length;
1511 /*******************************************************************
1512 reads or writes a structure.
1513 ********************************************************************/
1514 BOOL lsa_io_q_enum_accounts(const char *desc, LSA_Q_ENUM_ACCOUNTS *in, prs_struct *ps, int depth)
1519 prs_debug(ps, depth, desc, "lsa_io_q_enum_accounts");
1522 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
1525 if(!prs_uint32("enum_context ", ps, depth, &in->enum_context))
1527 if(!prs_uint32("pref_max_length", ps, depth, &in->pref_max_length))
1534 /*******************************************************************
1535 Inits an LSA_R_ENUM_PRIVS structure.
1536 ********************************************************************/
1538 void init_lsa_r_enum_accounts(LSA_R_ENUM_ACCOUNTS *out, uint32 enum_context)
1540 DEBUG(5, ("init_lsa_r_enum_accounts\n"));
1542 out->enum_context=enum_context;
1543 if (out->enum_context!=0) {
1544 out->sids.num_entries=enum_context;
1545 out->sids.ptr_sid_enum=1;
1546 out->sids.num_entries2=enum_context;
1548 out->sids.num_entries=0;
1549 out->sids.ptr_sid_enum=0;
1550 out->sids.num_entries2=0;
1554 /*******************************************************************
1555 reads or writes a structure.
1556 ********************************************************************/
1557 BOOL lsa_io_r_enum_accounts(const char *desc, LSA_R_ENUM_ACCOUNTS *out, prs_struct *ps, int depth)
1562 prs_debug(ps, depth, desc, "lsa_io_r_enum_accounts");
1568 if(!prs_uint32("enum_context", ps, depth, &out->enum_context))
1571 if (!lsa_io_sid_enum("sids", &out->sids, ps, depth))
1577 if(!prs_ntstatus("status", ps, depth, &out->status))
1584 /*******************************************************************
1585 Reads or writes an LSA_Q_UNK_GET_CONNUSER structure.
1586 ********************************************************************/
1588 BOOL lsa_io_q_unk_get_connuser(const char *desc, LSA_Q_UNK_GET_CONNUSER *in, prs_struct *ps, int depth)
1590 prs_debug(ps, depth, desc, "lsa_io_q_unk_get_connuser");
1596 if(!prs_uint32("ptr_srvname", ps, depth, &in->ptr_srvname))
1599 if(!smb_io_unistr2("uni2_srvname", &in->uni2_srvname, in->ptr_srvname, ps, depth)) /* server name to be looked up */
1605 if(!prs_uint32("unk1", ps, depth, &in->unk1))
1607 if(!prs_uint32("unk2", ps, depth, &in->unk2))
1609 if(!prs_uint32("unk3", ps, depth, &in->unk3))
1612 /* Don't bother to read or write at present... */
1616 /*******************************************************************
1617 Reads or writes an LSA_R_UNK_GET_CONNUSER structure.
1618 ********************************************************************/
1620 BOOL lsa_io_r_unk_get_connuser(const char *desc, LSA_R_UNK_GET_CONNUSER *out, prs_struct *ps, int depth)
1622 prs_debug(ps, depth, desc, "lsa_io_r_unk_get_connuser");
1628 if(!prs_uint32("ptr_user_name", ps, depth, &out->ptr_user_name))
1630 if(!smb_io_unihdr("hdr_user_name", &out->hdr_user_name, ps, depth))
1632 if(!smb_io_unistr2("uni2_user_name", &out->uni2_user_name, out->ptr_user_name, ps, depth))
1638 if(!prs_uint32("unk1", ps, depth, &out->unk1))
1641 if(!prs_uint32("ptr_dom_name", ps, depth, &out->ptr_dom_name))
1643 if(!smb_io_unihdr("hdr_dom_name", &out->hdr_dom_name, ps, depth))
1645 if(!smb_io_unistr2("uni2_dom_name", &out->uni2_dom_name, out->ptr_dom_name, ps, depth))
1651 if(!prs_ntstatus("status", ps, depth, &out->status))
1657 void init_lsa_q_create_account(LSA_Q_CREATEACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1659 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1661 init_dom_sid2(&trn->sid, sid);
1662 trn->access = desired_access;
1666 /*******************************************************************
1667 Reads or writes an LSA_Q_CREATEACCOUNT structure.
1668 ********************************************************************/
1670 BOOL lsa_io_q_create_account(const char *desc, LSA_Q_CREATEACCOUNT *out, prs_struct *ps, int depth)
1672 prs_debug(ps, depth, desc, "lsa_io_q_create_account");
1678 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1681 if(!smb_io_dom_sid2("sid", &out->sid, ps, depth)) /* domain SID */
1684 if(!prs_uint32("access", ps, depth, &out->access))
1690 /*******************************************************************
1691 Reads or writes an LSA_R_CREATEACCOUNT structure.
1692 ********************************************************************/
1694 BOOL lsa_io_r_create_account(const char *desc, LSA_R_CREATEACCOUNT *out, prs_struct *ps, int depth)
1696 prs_debug(ps, depth, desc, "lsa_io_r_open_account");
1702 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1705 if(!prs_ntstatus("status", ps, depth, &out->status))
1712 void init_lsa_q_open_account(LSA_Q_OPENACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1714 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1716 init_dom_sid2(&trn->sid, sid);
1717 trn->access = desired_access;
1720 /*******************************************************************
1721 Reads or writes an LSA_Q_OPENACCOUNT structure.
1722 ********************************************************************/
1724 BOOL lsa_io_q_open_account(const char *desc, LSA_Q_OPENACCOUNT *out, prs_struct *ps, int depth)
1726 prs_debug(ps, depth, desc, "lsa_io_q_open_account");
1732 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1735 if(!smb_io_dom_sid2("sid", &out->sid, ps, depth)) /* domain SID */
1738 if(!prs_uint32("access", ps, depth, &out->access))
1744 /*******************************************************************
1745 Reads or writes an LSA_R_OPENACCOUNT structure.
1746 ********************************************************************/
1748 BOOL lsa_io_r_open_account(const char *desc, LSA_R_OPENACCOUNT *out, prs_struct *ps, int depth)
1750 prs_debug(ps, depth, desc, "lsa_io_r_open_account");
1756 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1759 if(!prs_ntstatus("status", ps, depth, &out->status))
1766 void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd)
1768 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1772 /*******************************************************************
1773 Reads or writes an LSA_Q_ENUMPRIVSACCOUNT structure.
1774 ********************************************************************/
1776 BOOL lsa_io_q_enum_privsaccount(const char *desc, LSA_Q_ENUMPRIVSACCOUNT *out, prs_struct *ps, int depth)
1778 prs_debug(ps, depth, desc, "lsa_io_q_enum_privsaccount");
1784 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1790 /*******************************************************************
1791 Reads or writes an LUID structure.
1792 ********************************************************************/
1794 static BOOL lsa_io_luid(const char *desc, LUID *out, prs_struct *ps, int depth)
1796 prs_debug(ps, depth, desc, "lsa_io_luid");
1802 if(!prs_uint32("low", ps, depth, &out->low))
1805 if(!prs_uint32("high", ps, depth, &out->high))
1811 /*******************************************************************
1812 Reads or writes an LUID_ATTR structure.
1813 ********************************************************************/
1815 static BOOL lsa_io_luid_attr(const char *desc, LUID_ATTR *out, prs_struct *ps, int depth)
1817 prs_debug(ps, depth, desc, "lsa_io_luid_attr");
1823 if (!lsa_io_luid(desc, &out->luid, ps, depth))
1826 if(!prs_uint32("attr", ps, depth, &out->attr))
1832 /*******************************************************************
1833 Reads or writes an PRIVILEGE_SET structure.
1834 ********************************************************************/
1836 static BOOL lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *out, prs_struct *ps, int depth)
1840 prs_debug(ps, depth, desc, "lsa_io_privilege_set");
1846 if(!prs_uint32("count", ps, depth, &out->count))
1848 if(!prs_uint32("control", ps, depth, &out->control))
1851 for (i=0; i<out->count; i++) {
1852 if (!lsa_io_luid_attr(desc, &out->set[i], ps, depth))
1859 NTSTATUS init_lsa_r_enum_privsaccount(TALLOC_CTX *mem_ctx, LSA_R_ENUMPRIVSACCOUNT *out, LUID_ATTR *set, uint32 count, uint32 control)
1861 NTSTATUS ret = NT_STATUS_OK;
1866 if ( !NT_STATUS_IS_OK(ret = privilege_set_init_by_ctx(mem_ctx, &(out->set))) )
1869 out->set.count = count;
1871 if (!NT_STATUS_IS_OK(ret = dup_luid_attr(out->set.mem_ctx, &(out->set.set), set, count)))
1874 DEBUG(10,("init_lsa_r_enum_privsaccount: %d privileges\n", out->count));
1879 /*******************************************************************
1880 Reads or writes an LSA_R_ENUMPRIVSACCOUNT structure.
1881 ********************************************************************/
1883 BOOL lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *out, prs_struct *ps, int depth)
1885 prs_debug(ps, depth, desc, "lsa_io_r_enum_privsaccount");
1891 if(!prs_uint32("ptr", ps, depth, &out->ptr))
1895 if(!prs_uint32("count", ps, depth, &out->count))
1898 /* malloc memory if unmarshalling here */
1900 if (UNMARSHALLING(ps) && out->count != 0) {
1901 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))
1904 if (!(out->set.set = PRS_ALLOC_MEM(ps,LUID_ATTR,out->count)))
1909 if(!lsa_io_privilege_set(desc, &out->set, ps, depth))
1913 if(!prs_ntstatus("status", ps, depth, &out->status))
1921 /*******************************************************************
1922 Reads or writes an LSA_Q_GETSYSTEMACCOUNTstructure.
1923 ********************************************************************/
1925 BOOL lsa_io_q_getsystemaccount(const char *desc, LSA_Q_GETSYSTEMACCOUNT *out, prs_struct *ps, int depth)
1927 prs_debug(ps, depth, desc, "lsa_io_q_getsystemaccount");
1933 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1939 /*******************************************************************
1940 Reads or writes an LSA_R_GETSYSTEMACCOUNTstructure.
1941 ********************************************************************/
1943 BOOL lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT *out, prs_struct *ps, int depth)
1945 prs_debug(ps, depth, desc, "lsa_io_r_getsystemaccount");
1951 if(!prs_uint32("access", ps, depth, &out->access))
1954 if(!prs_ntstatus("status", ps, depth, &out->status))
1961 /*******************************************************************
1962 Reads or writes an LSA_Q_SETSYSTEMACCOUNT structure.
1963 ********************************************************************/
1965 BOOL lsa_io_q_setsystemaccount(const char *desc, LSA_Q_SETSYSTEMACCOUNT *out, prs_struct *ps, int depth)
1967 prs_debug(ps, depth, desc, "lsa_io_q_setsystemaccount");
1973 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
1976 if(!prs_uint32("access", ps, depth, &out->access))
1982 /*******************************************************************
1983 Reads or writes an LSA_R_SETSYSTEMACCOUNT structure.
1984 ********************************************************************/
1986 BOOL lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *out, prs_struct *ps, int depth)
1988 prs_debug(ps, depth, desc, "lsa_io_r_setsystemaccount");
1994 if(!prs_ntstatus("status", ps, depth, &out->status))
2001 static void init_lsa_string( LSA_STRING *uni, const char *string )
2003 init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE);
2004 init_uni_hdr(&uni->hdr, &uni->unistring);
2007 void init_lsa_q_lookup_priv_value(LSA_Q_LOOKUP_PRIV_VALUE *q_u, POLICY_HND *hnd, const char *name)
2009 memcpy(&q_u->pol, hnd, sizeof(q_u->pol));
2010 init_lsa_string( &q_u->privname, name );
2013 BOOL smb_io_lsa_string( const char *desc, LSA_STRING *string, prs_struct *ps, int depth )
2015 prs_debug(ps, depth, desc, "smb_io_lsa_string");
2018 if(!smb_io_unihdr ("hdr", &string->hdr, ps, depth))
2020 if(!smb_io_unistr2("unistring", &string->unistring, string->hdr.buffer, ps, depth))
2026 /*******************************************************************
2027 Reads or writes an LSA_Q_LOOKUP_PRIV_VALUE structure.
2028 ********************************************************************/
2030 BOOL lsa_io_q_lookup_priv_value(const char *desc, LSA_Q_LOOKUP_PRIV_VALUE *out, prs_struct *ps, int depth)
2032 prs_debug(ps, depth, desc, "lsa_io_q_lookup_priv_value");
2038 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2040 if(!smb_io_lsa_string("privname", &out->privname, ps, depth))
2046 /*******************************************************************
2047 Reads or writes an LSA_R_LOOKUP_PRIV_VALUE structure.
2048 ********************************************************************/
2050 BOOL lsa_io_r_lookup_priv_value(const char *desc, LSA_R_LOOKUP_PRIV_VALUE *out, prs_struct *ps, int depth)
2052 prs_debug(ps, depth, desc, "lsa_io_r_lookup_priv_value");
2058 if(!lsa_io_luid("luid", &out->luid, ps, depth))
2061 if(!prs_ntstatus("status", ps, depth, &out->status))
2068 /*******************************************************************
2069 Reads or writes an LSA_Q_ADDPRIVS structure.
2070 ********************************************************************/
2072 BOOL lsa_io_q_addprivs(const char *desc, LSA_Q_ADDPRIVS *out, prs_struct *ps, int depth)
2074 prs_debug(ps, depth, desc, "lsa_io_q_addprivs");
2080 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2083 if(!prs_uint32("count", ps, depth, &out->count))
2086 if (UNMARSHALLING(ps) && out->count!=0) {
2087 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))
2090 if (!(out->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, out->count)))
2094 if(!lsa_io_privilege_set(desc, &out->set, ps, depth))
2100 /*******************************************************************
2101 Reads or writes an LSA_R_ADDPRIVS structure.
2102 ********************************************************************/
2104 BOOL lsa_io_r_addprivs(const char *desc, LSA_R_ADDPRIVS *out, prs_struct *ps, int depth)
2106 prs_debug(ps, depth, desc, "lsa_io_r_addprivs");
2112 if(!prs_ntstatus("status", ps, depth, &out->status))
2118 /*******************************************************************
2119 Reads or writes an LSA_Q_REMOVEPRIVS structure.
2120 ********************************************************************/
2122 BOOL lsa_io_q_removeprivs(const char *desc, LSA_Q_REMOVEPRIVS *out, prs_struct *ps, int depth)
2124 prs_debug(ps, depth, desc, "lsa_io_q_removeprivs");
2130 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2133 if(!prs_uint32("allrights", ps, depth, &out->allrights))
2136 if(!prs_uint32("ptr", ps, depth, &out->ptr))
2140 * JFM: I'm not sure at all if the count is inside the ptr
2141 * never seen one with ptr=0
2145 if(!prs_uint32("count", ps, depth, &out->count))
2148 if (UNMARSHALLING(ps) && out->count!=0) {
2149 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))
2152 if (!(out->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, out->count)))
2156 if(!lsa_io_privilege_set(desc, &out->set, ps, depth))
2163 /*******************************************************************
2164 Reads or writes an LSA_R_REMOVEPRIVS structure.
2165 ********************************************************************/
2167 BOOL lsa_io_r_removeprivs(const char *desc, LSA_R_REMOVEPRIVS *out, prs_struct *ps, int depth)
2169 prs_debug(ps, depth, desc, "lsa_io_r_removeprivs");
2175 if(!prs_ntstatus("status", ps, depth, &out->status))
2181 BOOL policy_handle_is_valid(const POLICY_HND *hnd)
2183 POLICY_HND zero_pol;
2185 ZERO_STRUCT(zero_pol);
2186 return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True );
2189 /*******************************************************************
2190 Reads or writes an LSA_DNS_DOM_INFO structure.
2191 ********************************************************************/
2193 BOOL lsa_io_dns_dom_info(const char *desc, LSA_DNS_DOM_INFO *info,
2194 prs_struct *ps, int depth)
2196 prs_debug(ps, depth, desc, "lsa_io_dns_dom_info");
2201 if(!smb_io_unihdr("nb_name", &info->hdr_nb_dom_name, ps, depth))
2203 if(!smb_io_unihdr("dns_name", &info->hdr_dns_dom_name, ps, depth))
2205 if(!smb_io_unihdr("forest", &info->hdr_forest_name, ps, depth))
2210 if ( !smb_io_uuid("dom_guid", &info->dom_guid, ps, depth) )
2215 if(!prs_uint32("dom_sid", ps, depth, &info->ptr_dom_sid))
2218 if(!smb_io_unistr2("nb_name", &info->uni_nb_dom_name,
2219 info->hdr_nb_dom_name.buffer, ps, depth))
2221 if(!smb_io_unistr2("dns_name", &info->uni_dns_dom_name,
2222 info->hdr_dns_dom_name.buffer, ps, depth))
2224 if(!smb_io_unistr2("forest", &info->uni_forest_name,
2225 info->hdr_forest_name.buffer, ps, depth))
2228 if(!smb_io_dom_sid2("dom_sid", &info->dom_sid, ps, depth))
2235 /*******************************************************************
2236 Inits an LSA_Q_QUERY_INFO2 structure.
2237 ********************************************************************/
2239 void init_q_query2(LSA_Q_QUERY_INFO2 *in, POLICY_HND *hnd, uint16 info_class)
2241 DEBUG(5, ("init_q_query2\n"));
2243 memcpy(&in->pol, hnd, sizeof(in->pol));
2245 in->info_class = info_class;
2248 /*******************************************************************
2249 Reads or writes an LSA_Q_QUERY_DNSDOMINFO structure.
2250 ********************************************************************/
2252 BOOL lsa_io_q_query_info2(const char *desc, LSA_Q_QUERY_INFO2 *in, prs_struct *ps, int depth)
2254 prs_debug(ps, depth, desc, "lsa_io_q_query_info2");
2260 if(!smb_io_pol_hnd("pol", &in->pol, ps, depth))
2263 if(!prs_uint16("info_class", ps, depth, &in->info_class))
2269 /*******************************************************************
2270 Reads or writes an LSA_R_QUERY_DNSDOMINFO structure.
2271 ********************************************************************/
2273 BOOL lsa_io_r_query_info2(const char *desc, LSA_R_QUERY_INFO2 *out,
2274 prs_struct *ps, int depth)
2276 prs_debug(ps, depth, desc, "lsa_io_r_query_info2");
2282 if(!prs_uint32("ptr", ps, depth, &out->ptr))
2284 if(!prs_uint16("info_class", ps, depth, &out->info_class))
2286 switch(out->info_class) {
2288 if (!lsa_io_dns_dom_info("info12", &out->info.dns_dom_info,
2293 DEBUG(0,("lsa_io_r_query_info2: unknown info class %d\n",
2300 if(!prs_ntstatus("status", ps, depth, &out->status))
2306 /*******************************************************************
2307 Inits an LSA_Q_ENUM_ACCT_RIGHTS structure.
2308 ********************************************************************/
2309 void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS *in,
2314 DEBUG(5, ("init_q_enum_acct_rights\n"));
2317 init_dom_sid2(&in->sid, sid);
2320 /*******************************************************************
2321 ********************************************************************/
2322 NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *out, PRIVILEGE_SET *privileges )
2326 const char **privname_array = NULL;
2329 for ( i=0; i<privileges->count; i++ ) {
2330 privname = luid_to_privilege_name( &privileges->set[i].luid );
2332 if ( !add_string_to_array( get_talloc_ctx(), privname, &privname_array, &num_priv ) )
2333 return NT_STATUS_NO_MEMORY;
2338 out->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY );
2340 if ( !init_unistr4_array( out->rights, num_priv, privname_array ) )
2341 return NT_STATUS_NO_MEMORY;
2343 out->count = num_priv;
2346 return NT_STATUS_OK;
2349 /*******************************************************************
2350 reads or writes a LSA_Q_ENUM_ACCT_RIGHTS structure.
2351 ********************************************************************/
2352 BOOL lsa_io_q_enum_acct_rights(const char *desc, LSA_Q_ENUM_ACCT_RIGHTS *in, prs_struct *ps, int depth)
2358 prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_rights");
2361 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
2364 if(!smb_io_dom_sid2("sid", &in->sid, ps, depth))
2371 /*******************************************************************
2372 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2373 ********************************************************************/
2374 BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *out, prs_struct *ps, int depth)
2376 prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_rights");
2379 if(!prs_uint32("count ", ps, depth, &out->count))
2382 if ( !prs_pointer("rights", ps, depth, (void**)&out->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2388 if(!prs_ntstatus("status", ps, depth, &out->status))
2395 /*******************************************************************
2396 Inits an LSA_Q_ADD_ACCT_RIGHTS structure.
2397 ********************************************************************/
2398 void init_q_add_acct_rights( LSA_Q_ADD_ACCT_RIGHTS *in, POLICY_HND *hnd,
2399 DOM_SID *sid, uint32 count, const char **rights )
2401 DEBUG(5, ("init_q_add_acct_rights\n"));
2404 init_dom_sid2(&in->sid, sid);
2406 in->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY );
2407 init_unistr4_array( in->rights, count, rights );
2413 /*******************************************************************
2414 reads or writes a LSA_Q_ADD_ACCT_RIGHTS structure.
2415 ********************************************************************/
2416 BOOL lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *in, prs_struct *ps, int depth)
2418 prs_debug(ps, depth, desc, "lsa_io_q_add_acct_rights");
2421 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
2424 if(!smb_io_dom_sid2("sid", &in->sid, ps, depth))
2427 if(!prs_uint32("count", ps, depth, &in->count))
2430 if ( !prs_pointer("rights", ps, depth, (void**)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2436 /*******************************************************************
2437 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2438 ********************************************************************/
2439 BOOL lsa_io_r_add_acct_rights(const char *desc, LSA_R_ADD_ACCT_RIGHTS *out, prs_struct *ps, int depth)
2441 prs_debug(ps, depth, desc, "lsa_io_r_add_acct_rights");
2444 if(!prs_ntstatus("status", ps, depth, &out->status))
2451 /*******************************************************************
2452 Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure.
2453 ********************************************************************/
2454 void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *in,
2459 const char **rights)
2461 DEBUG(5, ("init_q_remove_acct_rights\n"));
2465 init_dom_sid2(&in->sid, sid);
2467 in->removeall = removeall;
2470 in->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY );
2471 init_unistr4_array( in->rights, count, rights );
2475 /*******************************************************************
2476 reads or writes a LSA_Q_REMOVE_ACCT_RIGHTS structure.
2477 ********************************************************************/
2478 BOOL lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *in, prs_struct *ps, int depth)
2480 prs_debug(ps, depth, desc, "lsa_io_q_remove_acct_rights");
2483 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
2486 if(!smb_io_dom_sid2("sid", &in->sid, ps, depth))
2489 if(!prs_uint32("removeall", ps, depth, &in->removeall))
2492 if(!prs_uint32("count", ps, depth, &in->count))
2495 if ( !prs_pointer("rights", ps, depth, (void**)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2501 /*******************************************************************
2502 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2503 ********************************************************************/
2504 BOOL lsa_io_r_remove_acct_rights(const char *desc, LSA_R_REMOVE_ACCT_RIGHTS *out, prs_struct *ps, int depth)
2506 prs_debug(ps, depth, desc, "lsa_io_r_remove_acct_rights");
2509 if(!prs_ntstatus("status", ps, depth, &out->status))
2515 /*******************************************************************
2516 Inits an LSA_Q_OPEN_TRUSTED_DOMAIN structure.
2517 ********************************************************************/
2519 void init_lsa_q_open_trusted_domain(LSA_Q_OPEN_TRUSTED_DOMAIN *q, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
2521 memcpy(&q->pol, hnd, sizeof(q->pol));
2523 init_dom_sid2(&q->sid, sid);
2524 q->access_mask = desired_access;
2527 /*******************************************************************
2528 ********************************************************************/
2530 #if 0 /* jerry, I think this not correct - gd */
2531 BOOL lsa_io_q_open_trusted_domain(const char *desc, LSA_Q_OPEN_TRUSTED_DOMAIN *in, prs_struct *ps, int depth)
2533 prs_debug(ps, depth, desc, "lsa_io_q_open_trusted_domain");
2539 if (!smb_io_pol_hnd("", &in->handle, ps, depth))
2542 if(!prs_uint32("count", ps, depth, &in->count))
2545 if(!smb_io_dom_sid("sid", &in->sid, ps, depth))
2553 /*******************************************************************
2554 Inits an LSA_Q_OPEN_TRUSTED_DOMAIN_BY_NAME structure.
2555 ********************************************************************/
2557 void init_lsa_q_open_trusted_domain_by_name(LSA_Q_OPEN_TRUSTED_DOMAIN_BY_NAME *q,
2560 uint32 desired_access)
2562 memcpy(&q->pol, hnd, sizeof(q->pol));
2564 init_lsa_string(&q->name, name);
2565 q->access_mask = desired_access;
2568 /*******************************************************************
2569 ********************************************************************/
2572 /*******************************************************************
2573 Reads or writes an LSA_Q_OPEN_TRUSTED_DOMAIN_BY_NAME structure.
2574 ********************************************************************/
2576 BOOL lsa_io_q_open_trusted_domain_by_name(const char *desc, LSA_Q_OPEN_TRUSTED_DOMAIN_BY_NAME *q_o, prs_struct *ps, int depth)
2578 prs_debug(ps, depth, desc, "lsa_io_q_open_trusted_domain_by_name");
2584 if(!smb_io_pol_hnd("pol", &q_o->pol, ps, depth))
2590 if(!smb_io_lsa_string("name", &q_o->name, ps, depth))
2596 if(!prs_uint32("access", ps, depth, &q_o->access_mask))
2602 /*******************************************************************
2603 Reads or writes an LSA_R_OPEN_TRUSTED_DOMAIN_BY_NAME structure.
2604 ********************************************************************/
2606 BOOL lsa_io_r_open_trusted_domain_by_name(const char *desc, LSA_R_OPEN_TRUSTED_DOMAIN_BY_NAME *out, prs_struct *ps, int depth)
2608 prs_debug(ps, depth, desc, "lsa_io_r_open_trusted_domain_by_name");
2614 if (!smb_io_pol_hnd("handle", &out->handle, ps, depth))
2617 if(!prs_ntstatus("status", ps, depth, &out->status))
2623 /*******************************************************************
2624 ********************************************************************/
2626 BOOL lsa_io_q_open_trusted_domain(const char *desc, LSA_Q_OPEN_TRUSTED_DOMAIN *q_o, prs_struct *ps, int depth)
2628 prs_debug(ps, depth, desc, "lsa_io_q_open_trusted_domain");
2634 if(!smb_io_pol_hnd("pol", &q_o->pol, ps, depth))
2637 if(!smb_io_dom_sid2("sid", &q_o->sid, ps, depth))
2640 if(!prs_uint32("access", ps, depth, &q_o->access_mask))
2646 /*******************************************************************
2647 Reads or writes an LSA_R_OPEN_TRUSTED_DOMAIN structure.
2648 ********************************************************************/
2650 BOOL lsa_io_r_open_trusted_domain(const char *desc, LSA_R_OPEN_TRUSTED_DOMAIN *out, prs_struct *ps, int depth)
2652 prs_debug(ps, depth, desc, "lsa_io_r_open_trusted_domain");
2658 if (!smb_io_pol_hnd("handle", &out->handle, ps, depth))
2661 if(!prs_ntstatus("status", ps, depth, &out->status))
2667 /*******************************************************************
2668 ********************************************************************/
2670 BOOL lsa_io_q_create_trusted_domain(const char *desc, LSA_Q_CREATE_TRUSTED_DOMAIN *in, prs_struct *ps, int depth)
2672 prs_debug(ps, depth, desc, "lsa_io_q_create_trusted_domain");
2678 if(!smb_io_pol_hnd("", &in->handle, ps, depth))
2681 if(!prs_unistr4 ("secretname", ps, depth, &in->secretname))
2686 if(!prs_uint32("access", ps, depth, &in->access))
2692 /*******************************************************************
2693 ********************************************************************/
2695 BOOL lsa_io_r_create_trusted_domain(const char *desc, LSA_R_CREATE_TRUSTED_DOMAIN *out, prs_struct *ps, int depth)
2697 prs_debug(ps, depth, desc, "lsa_io_r_create_trusted_domain");
2703 if (!smb_io_pol_hnd("", &out->handle, ps, depth))
2706 if(!prs_ntstatus("status", ps, depth, &out->status))
2712 /*******************************************************************
2713 ********************************************************************/
2715 BOOL lsa_io_q_create_secret(const char *desc, LSA_Q_CREATE_SECRET *in, prs_struct *ps, int depth)
2717 prs_debug(ps, depth, desc, "lsa_io_q_create_secret");
2723 if(!smb_io_pol_hnd("", &in->handle, ps, depth))
2726 if(!prs_unistr4 ("secretname", ps, depth, &in->secretname))
2731 if(!prs_uint32("access", ps, depth, &in->access))
2737 /*******************************************************************
2738 ********************************************************************/
2740 BOOL lsa_io_r_create_secret(const char *desc, LSA_R_CREATE_SECRET *out, prs_struct *ps, int depth)
2742 prs_debug(ps, depth, desc, "lsa_io_r_create_secret");
2748 if (!smb_io_pol_hnd("", &out->handle, ps, depth))
2751 if(!prs_ntstatus("status", ps, depth, &out->status))
2759 /*******************************************************************
2760 ********************************************************************/
2762 static BOOL lsa_io_data_blob( const char *desc, prs_struct *ps, int depth, LSA_DATA_BLOB *blob )
2764 prs_debug(ps, depth, desc, "lsa_io_data_blob");
2767 if ( !prs_uint32("size", ps, depth, &blob->size) )
2769 if ( !prs_uint32("size", ps, depth, &blob->size) )
2772 if ( !prs_io_unistr2_p(desc, ps, depth, &blob->data) )
2778 /*******************************************************************
2779 ********************************************************************/
2781 BOOL lsa_io_q_set_secret(const char *desc, LSA_Q_SET_SECRET *in, prs_struct *ps, int depth)
2783 prs_debug(ps, depth, desc, "lsa_io_q_set_secret");
2786 if ( !prs_align(ps) )
2789 if ( !smb_io_pol_hnd("", &in->handle, ps, depth) )
2792 if ( !prs_pointer( "old_value", ps, depth, (void*)&in->old_value, sizeof(LSA_DATA_BLOB), (PRS_POINTER_CAST)lsa_io_data_blob ))
2795 if( !prs_align(ps) )
2797 if ( !prs_pointer( "old_value", ps, depth, (void*)&in->old_value, sizeof(LSA_DATA_BLOB), (PRS_POINTER_CAST)lsa_io_data_blob ))
2804 /*******************************************************************
2805 ********************************************************************/
2807 BOOL lsa_io_r_set_secret(const char *desc, LSA_R_SET_SECRET *out, prs_struct *ps, int depth)
2809 prs_debug(ps, depth, desc, "lsa_io_r_set_secret");
2812 if(!prs_ntstatus("status", ps, depth, &out->status))
2818 /*******************************************************************
2819 ********************************************************************/
2821 BOOL lsa_io_q_delete_object(const char *desc, LSA_Q_DELETE_OBJECT *in, prs_struct *ps, int depth)
2823 prs_debug(ps, depth, desc, "lsa_io_q_delete_object");
2829 if(!smb_io_pol_hnd("", &in->handle, ps, depth))
2835 /*******************************************************************
2836 ********************************************************************/
2838 BOOL lsa_io_r_delete_object(const char *desc, LSA_R_DELETE_OBJECT *out, prs_struct *ps, int depth)
2840 prs_debug(ps, depth, desc, "lsa_io_r_delete_object");
2843 if(!prs_ntstatus("status", ps, depth, &out->status))
2849 /*******************************************************************
2850 Inits an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO structure.
2851 ********************************************************************/
2853 void init_q_query_trusted_domain_info(LSA_Q_QUERY_TRUSTED_DOMAIN_INFO *q,
2854 POLICY_HND *hnd, uint16 info_class)
2856 DEBUG(5, ("init_q_query_trusted_domain_info\n"));
2859 q->info_class = info_class;
2862 /*******************************************************************
2863 Inits an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME structure.
2864 ********************************************************************/
2866 void init_q_query_trusted_domain_info_by_name(LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME *q,
2867 POLICY_HND *hnd, uint16 info_class,
2868 const char *dom_name)
2870 DEBUG(5, ("init_q_query_trusted_domain_info_by_name\n"));
2873 init_lsa_string(&q->domain_name, dom_name );
2874 q->info_class = info_class;
2877 /*******************************************************************
2878 Inits an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID structure.
2879 ********************************************************************/
2881 void init_q_query_trusted_domain_info_by_sid(LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID *q,
2882 POLICY_HND *hnd, uint16 info_class,
2885 DEBUG(5, ("init_q_query_trusted_domain_info_by_sid\n"));
2888 init_dom_sid2(&q->dom_sid, dom_sid);
2889 q->info_class = info_class;
2892 /*******************************************************************
2893 Reads or writes an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO structure.
2894 ********************************************************************/
2896 BOOL lsa_io_q_query_trusted_domain_info(const char *desc,
2897 LSA_Q_QUERY_TRUSTED_DOMAIN_INFO *q_q,
2898 prs_struct *ps, int depth)
2900 prs_debug(ps, depth, desc, "lsa_io_q_query_trusted_domain_info");
2906 if(!smb_io_pol_hnd("pol", &q_q->pol, ps, depth))
2909 if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
2916 /*******************************************************************
2917 Reads or writes an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID structure.
2918 ********************************************************************/
2920 BOOL lsa_io_q_query_trusted_domain_info_by_sid(const char *desc,
2921 LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID *q_q,
2922 prs_struct *ps, int depth)
2924 prs_debug(ps, depth, desc, "lsa_io_q_query_trusted_domain_info_by_sid");
2930 if(!smb_io_pol_hnd("pol", &q_q->pol, ps, depth))
2936 if(!smb_io_dom_sid2("dom_sid", &q_q->dom_sid, ps, depth))
2939 if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
2945 /*******************************************************************
2946 Reads or writes an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME structure.
2947 ********************************************************************/
2949 BOOL lsa_io_q_query_trusted_domain_info_by_name(const char *desc,
2950 LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME *q_q,
2951 prs_struct *ps, int depth)
2953 prs_debug(ps, depth, desc, "lsa_io_q_query_trusted_domain_info_by_name");
2959 if(!smb_io_pol_hnd("pol", &q_q->pol, ps, depth))
2965 if(!smb_io_lsa_string("domain_name", &q_q->domain_name, ps, depth))
2968 if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
2974 /*******************************************************************
2975 ********************************************************************/
2977 static BOOL smb_io_lsa_data_buf_hdr(const char *desc, LSA_DATA_BUF_HDR *buf_hdr,
2978 prs_struct *ps, int depth)
2980 prs_debug(ps, depth, desc, "smb_io_lsa_data_buf_hdr");
2986 if(!prs_uint32("length", ps, depth, &buf_hdr->length))
2989 if(!prs_uint32("size", ps, depth, &buf_hdr->size))
2992 if (!prs_uint32("data_ptr", ps, depth, &buf_hdr->data_ptr))
2998 /*******************************************************************
2999 ********************************************************************/
3001 static BOOL smb_io_lsa_data_buf(const char *desc, LSA_DATA_BUF *buf,
3002 prs_struct *ps, int depth, int length, int size)
3004 prs_debug(ps, depth, desc, "smb_io_lsa_data_buf");
3007 if ( UNMARSHALLING(ps) ) {
3008 if ( !(buf->data = PRS_ALLOC_MEM( ps, uint8, length )) )
3012 if (!prs_uint32("size", ps, depth, &buf->size))
3015 if (!prs_uint32("offset", ps, depth, &buf->offset))
3018 if (!prs_uint32("length", ps, depth, &buf->length))
3021 if(!prs_uint8s(False, "data", ps, depth, buf->data, size))
3027 /*******************************************************************
3028 ********************************************************************/
3030 static BOOL lsa_io_trustdom_query_1(const char *desc, TRUSTED_DOMAIN_INFO_NAME *name,
3031 prs_struct *ps, int depth)
3033 if (!smb_io_lsa_string("netbios_name", &name->netbios_name, ps, depth))
3039 /*******************************************************************
3040 ********************************************************************/
3042 static BOOL lsa_io_trustdom_query_3(const char *desc, TRUSTED_DOMAIN_INFO_POSIX_OFFSET *posix,
3043 prs_struct *ps, int depth)
3045 if(!prs_uint32("posix_offset", ps, depth, &posix->posix_offset))
3051 /*******************************************************************
3052 ********************************************************************/
3054 static BOOL lsa_io_trustdom_query_4(const char *desc, TRUSTED_DOMAIN_INFO_PASSWORD *password,
3055 prs_struct *ps, int depth)
3060 if(!prs_uint32("ptr_password", ps, depth, &password->ptr_password))
3063 if(!prs_uint32("ptr_old_password", ps, depth, &password->ptr_old_password))
3066 if (&password->ptr_password) {
3068 if (!smb_io_lsa_data_buf_hdr("password_hdr", &password->password_hdr, ps, depth))
3071 if (!smb_io_lsa_data_buf("password", &password->password, ps, depth,
3072 password->password_hdr.length, password->password_hdr.size))
3076 if (&password->ptr_old_password) {
3078 if (!smb_io_lsa_data_buf_hdr("old_password_hdr", &password->old_password_hdr, ps, depth))
3081 if (!smb_io_lsa_data_buf("old_password", &password->old_password, ps, depth,
3082 password->old_password_hdr.length, password->old_password_hdr.size))
3089 /*******************************************************************
3090 ********************************************************************/
3092 static BOOL lsa_io_trustdom_query_6(const char *desc, TRUSTED_DOMAIN_INFO_EX *info_ex,
3093 prs_struct *ps, int depth)
3097 if (!smb_io_unihdr("domain_name_hdr", &info_ex->domain_name.hdr, ps, depth))
3100 if (!smb_io_unihdr("netbios_name_hdr", &info_ex->netbios_name.hdr, ps, depth))
3103 if (!prs_uint32("dom_sid_ptr", ps, depth, &dom_sid_ptr))
3106 if (!prs_uint32("trust_direction", ps, depth, &info_ex->trust_direction))
3109 if (!prs_uint32("trust_type", ps, depth, &info_ex->trust_type))
3112 if (!prs_uint32("trust_attributes", ps, depth, &info_ex->trust_attributes))
3115 if (!smb_io_unistr2("domain_name_unistring", &info_ex->domain_name.unistring, info_ex->domain_name.hdr.buffer, ps, depth))
3118 if (!smb_io_unistr2("netbios_name_unistring", &info_ex->netbios_name.unistring, info_ex->netbios_name.hdr.buffer, ps, depth))
3121 if (!smb_io_dom_sid2("sid", &info_ex->sid, ps, depth))
3127 /*******************************************************************
3128 ********************************************************************/
3130 static BOOL lsa_io_trustdom_query(const char *desc, prs_struct *ps, int depth, LSA_TRUSTED_DOMAIN_INFO *info)
3132 prs_debug(ps, depth, desc, "lsa_io_trustdom_query");
3135 if(!prs_uint16("info_class", ps, depth, &info->info_class))
3141 switch (info->info_class) {
3143 if(!lsa_io_trustdom_query_1("name", &info->name, ps, depth))
3147 if(!lsa_io_trustdom_query_3("posix_offset", &info->posix_offset, ps, depth))
3151 if(!lsa_io_trustdom_query_4("password", &info->password, ps, depth))
3155 if(!lsa_io_trustdom_query_6("info_ex", &info->info_ex, ps, depth))
3159 DEBUG(0,("unsupported info-level: %d\n", info->info_class));
3166 /*******************************************************************
3167 Reads or writes an LSA_R_QUERY_TRUSTED_DOMAIN_INFO structure.
3168 ********************************************************************/
3170 BOOL lsa_io_r_query_trusted_domain_info(const char *desc,
3171 LSA_R_QUERY_TRUSTED_DOMAIN_INFO *r_q,
3172 prs_struct *ps, int depth)
3177 prs_debug(ps, depth, desc, "lsa_io_r_query_trusted_domain_info");
3180 if (!prs_pointer("trustdom", ps, depth, (void**)&r_q->info,
3181 sizeof(LSA_TRUSTED_DOMAIN_INFO),
3182 (PRS_POINTER_CAST)lsa_io_trustdom_query) )
3188 if(!prs_ntstatus("status", ps, depth, &r_q->status))
3194 /*******************************************************************
3195 Inits an LSA_Q_QUERY_DOM_INFO_POLICY structure.
3196 ********************************************************************/
3198 void init_q_query_dom_info(LSA_Q_QUERY_DOM_INFO_POLICY *in, POLICY_HND *hnd, uint16 info_class)
3200 DEBUG(5, ("init_q_query_dom_info\n"));
3202 memcpy(&in->pol, hnd, sizeof(in->pol));
3204 in->info_class = info_class;
3207 /*******************************************************************
3208 Reads or writes an LSA_Q_QUERY_DOM_INFO_POLICY structure.
3209 ********************************************************************/
3211 BOOL lsa_io_q_query_dom_info(const char *desc, LSA_Q_QUERY_DOM_INFO_POLICY *in, prs_struct *ps, int depth)
3213 prs_debug(ps, depth, desc, "lsa_io_q_query_dom_info");
3219 if(!smb_io_pol_hnd("pol", &in->pol, ps, depth))
3222 if(!prs_uint16("info_class", ps, depth, &in->info_class))
3228 /*******************************************************************
3229 Reads or writes an LSA_R_QUERY_DOM_INFO_POLICY structure.
3230 ********************************************************************/
3232 static BOOL lsa_io_dominfo_query_3(const char *desc, LSA_DOM_INFO_POLICY_KERBEROS *krb_policy,
3233 prs_struct *ps, int depth)
3235 if (!prs_align_uint64(ps))
3241 if (!prs_uint32("enforce_restrictions", ps, depth, &krb_policy->enforce_restrictions))
3244 if (!prs_align_uint64(ps))
3247 if (!smb_io_nttime("service_tkt_lifetime", ps, depth, &krb_policy->service_tkt_lifetime))
3250 if (!prs_align_uint64(ps))
3253 if (!smb_io_nttime("user_tkt_lifetime", ps, depth, &krb_policy->user_tkt_lifetime))
3256 if (!prs_align_uint64(ps))
3259 if (!smb_io_nttime("user_tkt_renewaltime", ps, depth, &krb_policy->user_tkt_renewaltime))
3262 if (!prs_align_uint64(ps))
3265 if (!smb_io_nttime("clock_skew", ps, depth, &krb_policy->clock_skew))
3268 if (!prs_align_uint64(ps))
3271 if (!smb_io_nttime("unknown6", ps, depth, &krb_policy->unknown6))
3277 static BOOL lsa_io_dom_info_query(const char *desc, prs_struct *ps, int depth, LSA_DOM_INFO_UNION *info)
3279 prs_debug(ps, depth, desc, "lsa_io_dom_info_query");
3282 if(!prs_align_uint16(ps))
3285 if(!prs_uint16("info_class", ps, depth, &info->info_class))
3288 switch (info->info_class) {
3290 if (!lsa_io_dominfo_query_3("krb_policy", &info->krb_policy, ps, depth))
3294 DEBUG(0,("unsupported info-level: %d\n", info->info_class));
3303 BOOL lsa_io_r_query_dom_info(const char *desc, LSA_R_QUERY_DOM_INFO_POLICY *out,
3304 prs_struct *ps, int depth)
3306 prs_debug(ps, depth, desc, "lsa_io_r_query_dom_info");
3309 if (!prs_pointer("dominfo", ps, depth, (void**)&out->info,
3310 sizeof(LSA_DOM_INFO_UNION),
3311 (PRS_POINTER_CAST)lsa_io_dom_info_query) )
3314 if(!prs_ntstatus("status", ps, depth, &out->status))