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
, uint32 enum_context
,
512 uint32 req_num_domains
, uint32 num_domains
, TRUSTDOM
**td
)
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
;
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
;
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
)
557 prs_debug(ps
, depth
, desc
, "lsa_io_domain_list");
560 if(!prs_uint32("count", ps
, depth
, &domlist
->count
))
563 if ( domlist
->count
== 0 )
566 if ( UNMARSHALLING(ps
) ) {
567 if ( !(domlist
->domains
= PRS_ALLOC_MEM( ps
, DOMAIN_INFO
, domlist
->count
)) )
573 for ( i
=0; i
<domlist
->count
; i
++ ) {
574 if ( !prs_unistr4_hdr("name_header", ps
, depth
, &domlist
->domains
[i
].name
) )
576 if ( !smb_io_dom_sid2_p("sid_header", ps
, depth
, &domlist
->domains
[i
].sid
) )
582 for ( i
=0; i
<domlist
->count
; i
++ ) {
583 if ( !prs_unistr4_str("name", ps
, depth
, &domlist
->domains
[i
].name
) )
585 if( !smb_io_dom_sid2("sid", domlist
->domains
[i
].sid
, ps
, depth
) )
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");
602 if(!prs_uint32("enum_context", ps
, depth
, &out
->enum_context
))
605 if(!prs_uint32("count", ps
, depth
, &out
->count
))
608 if ( !prs_pointer("trusted_domains", ps
, depth
, (void**)&out
->domlist
, sizeof(DOMAIN_LIST
), (PRS_POINTER_CAST
)lsa_io_domain_list
))
611 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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
)
626 prs_debug(ps
, depth
, desc
, "lsa_io_dom_query");
632 if(!prs_uint16("uni_dom_max_len", ps
, depth
, &d_q
->uni_dom_max_len
)) /* domain name string length * 2 */
634 if(!prs_uint16("uni_dom_str_len", ps
, depth
, &d_q
->uni_dom_str_len
)) /* domain name string length * 2 */
637 if(!prs_uint32("buffer_dom_name", ps
, depth
, &d_q
->buffer_dom_name
)) /* undocumented domain name string buffer pointer */
639 if(!prs_uint32("buffer_dom_sid ", ps
, depth
, &d_q
->buffer_dom_sid
)) /* undocumented domain SID string buffer pointer */
642 if(!smb_io_unistr2("unistr2", &d_q
->uni_domain_name
, d_q
->buffer_dom_name
, ps
, depth
)) /* domain name (unicode string) */
648 if (d_q
->buffer_dom_sid
!= 0) {
649 if(!smb_io_dom_sid2("", &d_q
->dom_sid
, ps
, depth
)) /* domain SID */
652 memset((char *)&d_q
->dom_sid
, '\0', sizeof(d_q
->dom_sid
));
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
)
669 prs_debug(ps
, depth
, desc
, "lsa_io_dom_query_2");
675 if (!prs_uint32("auditing_enabled", ps
, depth
, &d_q
->auditing_enabled
))
677 if (!prs_uint32("ptr ", ps
, depth
, &ptr
))
679 if (!prs_uint32("count1", ps
, depth
, &d_q
->count1
))
681 if (!prs_uint32("count2", ps
, depth
, &d_q
->count2
))
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"));
693 if (!prs_uint32s(False
, "auditsettings", ps
, depth
, d_q
->auditsettings
, d_q
->count2
))
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
)
726 prs_debug(ps
, depth
, desc
, "lsa_io_dom_query_6");
729 if (!prs_uint16("server_role", ps
, depth
, &d_q
->server_role
))
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");
744 if(!prs_uint32("undoc_buffer", ps
, depth
, &out
->undoc_buffer
))
747 if (out
->undoc_buffer
!= 0) {
748 if(!prs_uint16("info_class", ps
, depth
, &out
->info_class
))
754 switch (out
->info_class
) {
756 if(!lsa_io_dom_query_2("", &out
->dom
.id2
, ps
, depth
))
760 if(!lsa_io_dom_query_3("", &out
->dom
.id3
, ps
, depth
))
764 if(!lsa_io_dom_query_5("", &out
->dom
.id5
, ps
, depth
))
768 if(!lsa_io_dom_query_6("", &out
->dom
.id6
, ps
, depth
))
780 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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
)
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"));
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"));
815 /* Copy across SIDs and SID pointers */
817 for (i
= 0; i
< num_entries
; i
++) {
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
,
832 prs_debug(ps
, depth
, desc
, "lsa_io_sid_enum");
838 if(!prs_uint32("num_entries ", ps
, depth
, &sen
->num_entries
))
840 if(!prs_uint32("ptr_sid_enum", ps
, depth
, &sen
->ptr_sid_enum
))
844 if the ptr is NULL, leave here. checked from a real w2k trace.
848 if (sen
->ptr_sid_enum
==0)
851 if(!prs_uint32("num_entries2", ps
, depth
, &sen
->num_entries2
))
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 "
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 "
870 for (i
= 0; i
< sen
->num_entries
; i
++) {
873 slprintf(temp
, sizeof(temp
) - 1, "ptr_sid[%d]", i
);
874 if(!prs_uint32(temp
, ps
, depth
, &sen
->ptr_sid
[i
])) {
879 for (i
= 0; i
< sen
->num_entries
; i
++) {
882 slprintf(temp
, sizeof(temp
) - 1, "sid[%d]", i
);
883 if(!smb_io_dom_sid2(temp
, &sen
->sid
[i
], ps
, depth
)) {
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
,
899 DEBUG(5, ("init_q_lookup_sids\n"));
903 memcpy(&q_l
->pol
, hnd
, sizeof(q_l
->pol
));
904 init_lsa_sid_enum(mem_ctx
, &q_l
->sids
, num_sids
, sids
);
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
,
916 prs_debug(ps
, depth
, desc
, "lsa_io_q_lookup_sids");
922 if(!smb_io_pol_hnd("pol_hnd", &q_s
->pol
, ps
, depth
)) /* policy handle */
924 if(!lsa_io_sid_enum("sids ", &q_s
->sids
, ps
, depth
)) /* sids to be looked up */
926 if(!lsa_io_trans_names("names ", &q_s
->names
, ps
, depth
)) /* translated names */
929 if(!prs_uint16("level", ps
, depth
, &q_s
->level
)) /* lookup level */
934 if(!prs_uint32("mapped_count", ps
, depth
, &q_s
->mapped_count
))
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
)
949 prs_debug(ps
, depth
, desc
, "lsa_io_trans_names");
955 if(!prs_uint32("num_entries ", ps
, depth
, &trn
->num_entries
))
957 if(!prs_uint32("ptr_trans_names", ps
, depth
, &trn
->ptr_trans_names
))
960 if (trn
->ptr_trans_names
!= 0) {
961 if(!prs_uint32("num_entries2 ", ps
, depth
,
965 if (UNMARSHALLING(ps
)) {
966 if ((trn
->name
= PRS_ALLOC_MEM(ps
, LSA_TRANS_NAME
, trn
->num_entries
)) == NULL
) {
970 if ((trn
->uni_name
= PRS_ALLOC_MEM(ps
, UNISTR2
, trn
->num_entries
)) == NULL
) {
975 for (i
= 0; i
< trn
->num_entries2
; i
++) {
977 slprintf(t
, sizeof(t
) - 1, "name[%d] ", i
);
979 if(!lsa_io_trans_name(t
, &trn
->name
[i
], ps
, depth
)) /* translated name */
983 for (i
= 0; i
< trn
->num_entries2
; i
++) {
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
))
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");
1010 if(!prs_uint32("ptr_dom_ref", ps
, depth
, &r_s
->ptr_dom_ref
))
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 */
1017 if(!lsa_io_trans_names("names ", r_s
->names
, ps
, depth
)) /* translated names */
1023 if(!prs_uint32("mapped_count", ps
, depth
, &r_s
->mapped_count
))
1026 if(!prs_ntstatus("status ", ps
, depth
, &r_s
->status
))
1032 /*******************************************************************
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
)
1041 DEBUG(5, ("init_q_lookup_names\n"));
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"));
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"));
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
)
1075 prs_debug(ps
, depth
, desc
, "lsa_io_q_lookup_names");
1081 if(!smb_io_pol_hnd("", &q_r
->pol
, ps
, depth
)) /* policy handle */
1086 if(!prs_uint32("num_entries ", ps
, depth
, &q_r
->num_entries
))
1088 if(!prs_uint32("num_entries2 ", ps
, depth
, &q_r
->num_entries2
))
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
)
1095 if ((q_r
->uni_name
= PRS_ALLOC_MEM(ps
, UNISTR2
, q_r
->num_entries
)) == NULL
)
1100 for (i
= 0; i
< q_r
->num_entries
; i
++) {
1103 if(!smb_io_unihdr("hdr_name", &q_r
->hdr_name
[i
], ps
, depth
)) /* pointer names */
1107 for (i
= 0; i
< q_r
->num_entries
; i
++) {
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 */
1116 if(!prs_uint32("num_trans_entries ", ps
, depth
, &q_r
->num_trans_entries
))
1118 if(!prs_uint32("ptr_trans_sids ", ps
, depth
, &q_r
->ptr_trans_sids
))
1120 if(!prs_uint32("lookup_level ", ps
, depth
, &q_r
->lookup_level
))
1122 if(!prs_uint32("mapped_count ", ps
, depth
, &q_r
->mapped_count
))
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
)
1136 prs_debug(ps
, depth
, desc
, "lsa_io_r_lookup_names");
1142 if(!prs_uint32("ptr_dom_ref", ps
, depth
, &out
->ptr_dom_ref
))
1145 if (out
->ptr_dom_ref
!= 0)
1146 if(!lsa_io_dom_r_ref("", out
->dom_ref
, ps
, depth
))
1149 if(!prs_uint32("num_entries", ps
, depth
, &out
->num_entries
))
1151 if(!prs_uint32("ptr_entries", ps
, depth
, &out
->ptr_entries
))
1154 if (out
->ptr_entries
!= 0) {
1155 if(!prs_uint32("num_entries2", ps
, depth
, &out
->num_entries2
))
1158 if (out
->num_entries2
!= out
->num_entries
) {
1163 if (UNMARSHALLING(ps
)) {
1164 if ((out
->dom_rid
= PRS_ALLOC_MEM(ps
, DOM_RID2
, out
->num_entries2
))
1166 DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n"));
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 */
1176 if(!prs_uint32("mapped_count", ps
, depth
, &out
->mapped_count
))
1179 if(!prs_ntstatus("status ", ps
, depth
, &out
->status
))
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");
1206 if(!smb_io_pol_hnd("", &in
->pol
, ps
, depth
))
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");
1221 if(!smb_io_pol_hnd("", &out
->pol
, ps
, depth
))
1224 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
1242 if(!smb_io_pol_hnd("", &in
->handle
, ps
, depth
))
1245 if(!prs_unistr4 ("secretname", ps
, depth
, &in
->secretname
))
1250 if(!prs_uint32("access", ps
, depth
, &in
->access
))
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");
1268 if(!smb_io_pol_hnd("", &out
->handle
, ps
, depth
))
1271 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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
)
1299 prs_debug(ps
, depth
, desc
, "lsa_io_q_enum_privs");
1302 if (!smb_io_pol_hnd("", &in
->pol
, ps
, depth
))
1305 if(!prs_uint32("enum_context ", ps
, depth
, &in
->enum_context
))
1307 if(!prs_uint32("pref_max_length", ps
, depth
, &in
->pref_max_length
))
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
)
1320 if (entries
== NULL
)
1323 prs_debug(ps
, depth
, desc
, "lsa_io_priv_entries");
1329 for (i
= 0; i
< count
; i
++) {
1330 if (!smb_io_unihdr("", &entries
[i
].hdr_name
, ps
, depth
))
1332 if(!prs_uint32("luid_low ", ps
, depth
, &entries
[i
].luid_low
))
1334 if(!prs_uint32("luid_high", ps
, depth
, &entries
[i
].luid_high
))
1338 for (i
= 0; i
< count
; i
++)
1339 if (!smb_io_unistr2("", &entries
[i
].name
, entries
[i
].hdr_name
.buffer
, ps
, depth
))
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
;
1357 if (entries
!=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
)
1376 prs_debug(ps
, depth
, desc
, "lsa_io_r_enum_privs");
1382 if(!prs_uint32("enum_context", ps
, depth
, &out
->enum_context
))
1384 if(!prs_uint32("count", ps
, depth
, &out
->count
))
1386 if(!prs_uint32("ptr", ps
, depth
, &out
->ptr
))
1390 if(!prs_uint32("count1", ps
, depth
, &out
->count1
))
1393 if (UNMARSHALLING(ps
))
1394 if (!(out
->privs
= PRS_ALLOC_MEM(ps
, LSA_PRIV_ENTRY
, out
->count1
)))
1397 if (!lsa_io_priv_entries("", out
->privs
, out
->count1
, ps
, depth
))
1404 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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
)
1428 prs_debug(ps
, depth
, desc
, "lsa_io_q_priv_get_dispname");
1434 if (!smb_io_pol_hnd("", &in
->pol
, ps
, depth
))
1437 if (!smb_io_unihdr("hdr_name", &in
->hdr_name
, ps
, depth
))
1440 if (!smb_io_unistr2("name", &in
->name
, in
->hdr_name
.buffer
, ps
, depth
))
1443 if(!prs_uint16("lang_id ", ps
, depth
, &in
->lang_id
))
1445 if(!prs_uint16("lang_id_sys", ps
, depth
, &in
->lang_id_sys
))
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
)
1459 prs_debug(ps
, depth
, desc
, "lsa_io_r_priv_get_dispname");
1465 if (!prs_uint32("ptr_info", ps
, depth
, &out
->ptr_info
))
1469 if (!smb_io_unihdr("hdr_name", &out
->hdr_desc
, ps
, depth
))
1472 if (!smb_io_unistr2("desc", &out
->desc
, out
->hdr_desc
.buffer
, ps
, depth
))
1479 if(!prs_uint16("lang_id", ps
, depth
, &out
->lang_id
))
1484 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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
)
1509 prs_debug(ps
, depth
, desc
, "lsa_io_q_enum_accounts");
1512 if (!smb_io_pol_hnd("", &in
->pol
, ps
, depth
))
1515 if(!prs_uint32("enum_context ", ps
, depth
, &in
->enum_context
))
1517 if(!prs_uint32("pref_max_length", ps
, depth
, &in
->pref_max_length
))
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
;
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
)
1552 prs_debug(ps
, depth
, desc
, "lsa_io_r_enum_accounts");
1558 if(!prs_uint32("enum_context", ps
, depth
, &out
->enum_context
))
1561 if (!lsa_io_sid_enum("sids", &out
->sids
, ps
, depth
))
1567 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
1586 if(!prs_uint32("ptr_srvname", ps
, depth
, &in
->ptr_srvname
))
1589 if(!smb_io_unistr2("uni2_srvname", &in
->uni2_srvname
, in
->ptr_srvname
, ps
, depth
)) /* server name to be looked up */
1595 if(!prs_uint32("unk1", ps
, depth
, &in
->unk1
))
1597 if(!prs_uint32("unk2", ps
, depth
, &in
->unk2
))
1599 if(!prs_uint32("unk3", ps
, depth
, &in
->unk3
))
1602 /* Don't bother to read or write at present... */
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");
1618 if(!prs_uint32("ptr_user_name", ps
, depth
, &out
->ptr_user_name
))
1620 if(!smb_io_unihdr("hdr_user_name", &out
->hdr_user_name
, ps
, depth
))
1622 if(!smb_io_unistr2("uni2_user_name", &out
->uni2_user_name
, out
->ptr_user_name
, ps
, depth
))
1628 if(!prs_uint32("unk1", ps
, depth
, &out
->unk1
))
1631 if(!prs_uint32("ptr_dom_name", ps
, depth
, &out
->ptr_dom_name
))
1633 if(!smb_io_unihdr("hdr_dom_name", &out
->hdr_dom_name
, ps
, depth
))
1635 if(!smb_io_unistr2("uni2_dom_name", &out
->uni2_dom_name
, out
->ptr_dom_name
, ps
, depth
))
1641 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
1668 if(!smb_io_pol_hnd("pol", &out
->pol
, ps
, depth
))
1671 if(!smb_io_dom_sid2("sid", &out
->sid
, ps
, depth
)) /* domain SID */
1674 if(!prs_uint32("access", ps
, depth
, &out
->access
))
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");
1692 if(!smb_io_pol_hnd("pol", &out
->pol
, ps
, depth
))
1695 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
1722 if(!smb_io_pol_hnd("pol", &out
->pol
, ps
, depth
))
1725 if(!smb_io_dom_sid2("sid", &out
->sid
, ps
, depth
)) /* domain SID */
1728 if(!prs_uint32("access", ps
, depth
, &out
->access
))
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");
1746 if(!smb_io_pol_hnd("pol", &out
->pol
, ps
, depth
))
1749 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
1774 if(!smb_io_pol_hnd("pol", &out
->pol
, ps
, depth
))
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");
1792 if(!prs_uint32("low", ps
, depth
, &out
->low
))
1795 if(!prs_uint32("high", ps
, depth
, &out
->high
))
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");
1813 if (!lsa_io_luid(desc
, &out
->luid
, ps
, depth
))
1816 if(!prs_uint32("attr", ps
, depth
, &out
->attr
))
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
)
1830 prs_debug(ps
, depth
, desc
, "lsa_io_privilege_set");
1836 if(!prs_uint32("count", ps
, depth
, &out
->count
))
1838 if(!prs_uint32("control", ps
, depth
, &out
->control
))
1841 for (i
=0; i
<out
->count
; i
++) {
1842 if (!lsa_io_luid_attr(desc
, &out
->set
[i
], ps
, depth
))
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
;
1856 if ( !NT_STATUS_IS_OK(ret
= privilege_set_init_by_ctx(mem_ctx
, &(out
->set
))) )
1859 out
->set
.count
= count
;
1861 if (!NT_STATUS_IS_OK(ret
= dup_luid_attr(out
->set
.mem_ctx
, &(out
->set
.set
), set
, count
)))
1864 DEBUG(10,("init_lsa_r_enum_privsaccount: %d privileges\n", out
->count
));
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");
1881 if(!prs_uint32("ptr", ps
, depth
, &out
->ptr
))
1885 if(!prs_uint32("count", ps
, depth
, &out
->count
))
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
))))
1894 if (!(out
->set
.set
= PRS_ALLOC_MEM(ps
,LUID_ATTR
,out
->count
)))
1899 if(!lsa_io_privilege_set(desc
, &out
->set
, ps
, depth
))
1903 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
1923 if(!smb_io_pol_hnd("pol", &out
->pol
, ps
, depth
))
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");
1941 if(!prs_uint32("access", ps
, depth
, &out
->access
))
1944 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
1963 if(!smb_io_pol_hnd("pol", &out
->pol
, ps
, depth
))
1966 if(!prs_uint32("access", ps
, depth
, &out
->access
))
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");
1984 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
2008 if(!smb_io_unihdr ("hdr", &string
->hdr
, ps
, depth
))
2010 if(!smb_io_unistr2("unistring", &string
->unistring
, string
->hdr
.buffer
, ps
, depth
))
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");
2028 if(!smb_io_pol_hnd("pol", &out
->pol
, ps
, depth
))
2030 if(!smb_io_lsa_string("privname", &out
->privname
, ps
, depth
))
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");
2048 if(!lsa_io_luid("luid", &out
->luid
, ps
, depth
))
2051 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
2070 if(!smb_io_pol_hnd("pol", &out
->pol
, ps
, depth
))
2073 if(!prs_uint32("count", ps
, depth
, &out
->count
))
2076 if (UNMARSHALLING(ps
) && out
->count
!=0) {
2077 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps
->mem_ctx
, &(out
->set
))))
2080 if (!(out
->set
.set
= PRS_ALLOC_MEM(ps
, LUID_ATTR
, out
->count
)))
2084 if(!lsa_io_privilege_set(desc
, &out
->set
, ps
, depth
))
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");
2102 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
2120 if(!smb_io_pol_hnd("pol", &out
->pol
, ps
, depth
))
2123 if(!prs_uint32("allrights", ps
, depth
, &out
->allrights
))
2126 if(!prs_uint32("ptr", ps
, depth
, &out
->ptr
))
2130 * JFM: I'm not sure at all if the count is inside the ptr
2131 * never seen one with ptr=0
2135 if(!prs_uint32("count", ps
, depth
, &out
->count
))
2138 if (UNMARSHALLING(ps
) && out
->count
!=0) {
2139 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps
->mem_ctx
, &(out
->set
))))
2142 if (!(out
->set
.set
= PRS_ALLOC_MEM(ps
, LUID_ATTR
, out
->count
)))
2146 if(!lsa_io_privilege_set(desc
, &out
->set
, ps
, depth
))
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");
2165 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
2191 if(!smb_io_unihdr("nb_name", &info
->hdr_nb_dom_name
, ps
, depth
))
2193 if(!smb_io_unihdr("dns_name", &info
->hdr_dns_dom_name
, ps
, depth
))
2195 if(!smb_io_unihdr("forest", &info
->hdr_forest_name
, ps
, depth
))
2200 if ( !smb_io_uuid("dom_guid", &info
->dom_guid
, ps
, depth
) )
2205 if(!prs_uint32("dom_sid", ps
, depth
, &info
->ptr_dom_sid
))
2208 if(!smb_io_unistr2("nb_name", &info
->uni_nb_dom_name
,
2209 info
->hdr_nb_dom_name
.buffer
, ps
, depth
))
2211 if(!smb_io_unistr2("dns_name", &info
->uni_dns_dom_name
,
2212 info
->hdr_dns_dom_name
.buffer
, ps
, depth
))
2214 if(!smb_io_unistr2("forest", &info
->uni_forest_name
,
2215 info
->hdr_forest_name
.buffer
, ps
, depth
))
2218 if(!smb_io_dom_sid2("dom_sid", &info
->dom_sid
, ps
, depth
))
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");
2250 if(!smb_io_pol_hnd("pol", &in
->pol
, ps
, depth
))
2253 if(!prs_uint16("info_class", ps
, depth
, &in
->info_class
))
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");
2272 if(!prs_uint32("ptr", ps
, depth
, &out
->ptr
))
2274 if(!prs_uint16("info_class", ps
, depth
, &out
->info_class
))
2276 switch(out
->info_class
) {
2278 if (!lsa_io_dns_dom_info("info12", &out
->info
.dns_dom_info
,
2283 DEBUG(0,("lsa_io_r_query_info2: unknown info class %d\n",
2290 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
2296 /*******************************************************************
2297 Inits an LSA_Q_ENUM_ACCT_RIGHTS structure.
2298 ********************************************************************/
2299 void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS
*in
,
2304 DEBUG(5, ("init_q_enum_acct_rights\n"));
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
)
2316 const char **privname_array
= NULL
;
2319 for ( i
=0; i
<privileges
->count
; i
++ ) {
2320 privname
= luid_to_privilege_name( &privileges
->set
[i
].luid
);
2322 if ( !add_string_to_array( get_talloc_ctx(), privname
, &privname_array
, &num_priv
) )
2323 return NT_STATUS_NO_MEMORY
;
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
)
2348 prs_debug(ps
, depth
, desc
, "lsa_io_q_enum_acct_rights");
2351 if (!smb_io_pol_hnd("", &in
->pol
, ps
, depth
))
2354 if(!smb_io_dom_sid2("sid", &in
->sid
, ps
, depth
))
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");
2369 if(!prs_uint32("count ", ps
, depth
, &out
->count
))
2372 if ( !prs_pointer("rights", ps
, depth
, (void**)&out
->rights
, sizeof(UNISTR4_ARRAY
), (PRS_POINTER_CAST
)prs_unistr4_array
) )
2378 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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"));
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
);
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");
2411 if (!smb_io_pol_hnd("", &in
->pol
, ps
, depth
))
2414 if(!smb_io_dom_sid2("sid", &in
->sid
, ps
, depth
))
2417 if(!prs_uint32("count", ps
, depth
, &in
->count
))
2420 if ( !prs_pointer("rights", ps
, depth
, (void**)&in
->rights
, sizeof(UNISTR4_ARRAY
), (PRS_POINTER_CAST
)prs_unistr4_array
) )
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");
2434 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
2441 /*******************************************************************
2442 Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure.
2443 ********************************************************************/
2444 void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS
*in
,
2449 const char **rights
)
2451 DEBUG(5, ("init_q_remove_acct_rights\n"));
2455 init_dom_sid2(&in
->sid
, sid
);
2457 in
->removeall
= removeall
;
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");
2473 if (!smb_io_pol_hnd("", &in
->pol
, ps
, depth
))
2476 if(!smb_io_dom_sid2("sid", &in
->sid
, ps
, depth
))
2479 if(!prs_uint32("removeall", ps
, depth
, &in
->removeall
))
2482 if(!prs_uint32("count", ps
, depth
, &in
->count
))
2485 if ( !prs_pointer("rights", ps
, depth
, (void**)&in
->rights
, sizeof(UNISTR4_ARRAY
), (PRS_POINTER_CAST
)prs_unistr4_array
) )
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");
2499 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
2529 if (!smb_io_pol_hnd("", &in
->handle
, ps
, depth
))
2532 if(!prs_uint32("count", ps
, depth
, &in
->count
))
2535 if(!smb_io_dom_sid("sid", &in
->sid
, ps
, depth
))
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");
2554 if(!smb_io_pol_hnd("pol", &q_o
->pol
, ps
, depth
))
2557 if(!smb_io_dom_sid2("sid", &q_o
->sid
, ps
, depth
))
2560 if(!prs_uint32("access", ps
, depth
, &q_o
->access_mask
))
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");
2578 if (!smb_io_pol_hnd("handle", &out
->handle
, ps
, depth
))
2581 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
2598 if(!smb_io_pol_hnd("", &in
->handle
, ps
, depth
))
2601 if(!prs_unistr4 ("secretname", ps
, depth
, &in
->secretname
))
2606 if(!prs_uint32("access", ps
, depth
, &in
->access
))
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");
2623 if (!smb_io_pol_hnd("", &out
->handle
, ps
, depth
))
2626 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
2643 if(!smb_io_pol_hnd("", &in
->handle
, ps
, depth
))
2646 if(!prs_unistr4 ("secretname", ps
, depth
, &in
->secretname
))
2651 if(!prs_uint32("access", ps
, depth
, &in
->access
))
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");
2668 if (!smb_io_pol_hnd("", &out
->handle
, ps
, depth
))
2671 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
2687 if ( !prs_uint32("size", ps
, depth
, &blob
->size
) )
2689 if ( !prs_uint32("size", ps
, depth
, &blob
->size
) )
2692 if ( !prs_io_unistr2_p(desc
, ps
, depth
, &blob
->data
) )
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");
2706 if ( !prs_align(ps
) )
2709 if ( !smb_io_pol_hnd("", &in
->handle
, ps
, depth
) )
2712 if ( !prs_pointer( "old_value", ps
, depth
, (void*)&in
->old_value
, sizeof(LSA_DATA_BLOB
), (PRS_POINTER_CAST
)lsa_io_data_blob
))
2715 if( !prs_align(ps
) )
2717 if ( !prs_pointer( "old_value", ps
, depth
, (void*)&in
->old_value
, sizeof(LSA_DATA_BLOB
), (PRS_POINTER_CAST
)lsa_io_data_blob
))
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");
2732 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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");
2749 if(!smb_io_pol_hnd("", &in
->handle
, ps
, depth
))
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");
2763 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
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"));
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"));
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
,
2805 DEBUG(5, ("init_q_query_trusted_domain_info_by_sid\n"));
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");
2826 if(!smb_io_pol_hnd("pol", &q_q
->pol
, ps
, depth
))
2829 if(!prs_uint16("info_class", ps
, depth
, &q_q
->info_class
))
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");
2850 if(!smb_io_pol_hnd("pol", &q_q
->pol
, ps
, depth
))
2856 if(!smb_io_dom_sid2("dom_sid", &q_q
->dom_sid
, ps
, depth
))
2859 if(!prs_uint16("info_class", ps
, depth
, &q_q
->info_class
))
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");
2879 if(!smb_io_pol_hnd("pol", &q_q
->pol
, ps
, depth
))
2885 if(!smb_io_lsa_string("domain_name", &q_q
->domain_name
, ps
, depth
))
2888 if(!prs_uint16("info_class", ps
, depth
, &q_q
->info_class
))
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");
2906 if(!prs_uint32("length", ps
, depth
, &buf_hdr
->length
))
2909 if(!prs_uint32("size", ps
, depth
, &buf_hdr
->size
))
2912 if (!prs_uint32("data_ptr", ps
, depth
, &buf_hdr
->data_ptr
))
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");
2927 if ( UNMARSHALLING(ps
) ) {
2928 if ( !(buf
->data
= PRS_ALLOC_MEM( ps
, uint8
, length
)) )
2932 if (!prs_uint32("size", ps
, depth
, &buf
->size
))
2935 if (!prs_uint32("offset", ps
, depth
, &buf
->offset
))
2938 if (!prs_uint32("length", ps
, depth
, &buf
->length
))
2941 if(!prs_uint8s(False
, "data", ps
, depth
, buf
->data
, size
))
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
))
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
))
2971 /*******************************************************************
2972 ********************************************************************/
2974 static BOOL
lsa_io_trustdom_query_4(const char *desc
, TRUSTED_DOMAIN_INFO_PASSWORD
*password
,
2975 prs_struct
*ps
, int depth
)
2980 if(!prs_uint32("ptr_password", ps
, depth
, &password
->ptr_password
))
2983 if(!prs_uint32("ptr_old_password", ps
, depth
, &password
->ptr_old_password
))
2986 if (&password
->ptr_password
) {
2988 if (!smb_io_lsa_data_buf_hdr("password_hdr", &password
->password_hdr
, ps
, depth
))
2991 if (!smb_io_lsa_data_buf("password", &password
->password
, ps
, depth
,
2992 password
->password_hdr
.length
, password
->password_hdr
.size
))
2996 if (&password
->ptr_old_password
) {
2998 if (!smb_io_lsa_data_buf_hdr("old_password_hdr", &password
->old_password_hdr
, ps
, depth
))
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
))
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");
3017 if(!prs_uint16("info_class", ps
, depth
, &info
->info_class
))
3023 switch (info
->info_class
) {
3025 if(!lsa_io_trustdom_query_1("name", &info
->name
, ps
, depth
))
3029 if(!lsa_io_trustdom_query_3("posix_offset", &info
->posix_offset
, ps
, depth
))
3033 if(!lsa_io_trustdom_query_4("password", &info
->password
, ps
, depth
))
3037 DEBUG(0,("unsupported info-level: %d\n", info
->info_class
));
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
)
3055 prs_debug(ps
, depth
, desc
, "lsa_io_r_query_trusted_domain_info");
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
) )
3066 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))