2 * Unix SMB/Netbios implementation.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-1997,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7 * Copyright (C) Paul Ashton 1997.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 extern int DEBUGLEVEL
;
30 /*******************************************************************
31 Inits a SAMR_Q_CLOSE_HND structure.
32 ********************************************************************/
34 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND
*q_c
, POLICY_HND
*hnd
)
36 DEBUG(5,("init_samr_q_close_hnd\n"));
38 memcpy(&q_c
->pol
, hnd
, sizeof(q_c
->pol
));
41 /*******************************************************************
42 Reads or writes a structure.
43 ********************************************************************/
45 BOOL
samr_io_q_close_hnd(char *desc
, SAMR_Q_CLOSE_HND
*q_u
, prs_struct
*ps
, int depth
)
50 prs_debug(ps
, depth
, desc
, "samr_io_q_close_hnd");
56 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
64 /*******************************************************************
65 Reads or writes a structure.
66 ********************************************************************/
68 BOOL
samr_io_r_close_hnd(char *desc
, SAMR_R_CLOSE_HND
*r_u
, prs_struct
*ps
, int depth
)
73 prs_debug(ps
, depth
, desc
, "samr_io_r_close_hnd");
79 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
84 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
91 /*******************************************************************
92 Reads or writes a structure.
93 ********************************************************************/
95 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN
*q_u
,
96 POLICY_HND
*connect_pol
, uint32 rid
,
99 DEBUG(5,("samr_init_q_open_domain\n"));
101 memcpy(&q_u
->connect_pol
, connect_pol
, sizeof(q_u
->connect_pol
));
103 init_dom_sid2(&q_u
->dom_sid
, sid
);
106 /*******************************************************************
107 Reads or writes a structure.
108 ********************************************************************/
110 BOOL
samr_io_q_open_domain(char *desc
, SAMR_Q_OPEN_DOMAIN
*q_u
, prs_struct
*ps
, int depth
)
115 prs_debug(ps
, depth
, desc
, "samr_io_q_open_domain");
121 if(!smb_io_pol_hnd("connect_pol", &q_u
->connect_pol
, ps
, depth
))
126 if(!prs_uint32("rid", ps
, depth
, &q_u
->rid
))
129 if(!smb_io_dom_sid2("sid", &q_u
->dom_sid
, ps
, depth
))
138 /*******************************************************************
139 Reads or writes a structure.
140 ********************************************************************/
142 BOOL
samr_io_r_open_domain(char *desc
, SAMR_R_OPEN_DOMAIN
*r_u
, prs_struct
*ps
, int depth
)
147 prs_debug(ps
, depth
, desc
, "samr_io_r_open_domain");
153 if(!smb_io_pol_hnd("domain_pol", &r_u
->domain_pol
, ps
, depth
))
158 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
164 /*******************************************************************
165 Reads or writes a structure.
166 ********************************************************************/
168 void init_samr_q_unknown_2c(SAMR_Q_UNKNOWN_2C
*q_u
, POLICY_HND
*user_pol
)
170 DEBUG(5,("samr_init_q_unknown_2c\n"));
172 memcpy(&q_u
->user_pol
, user_pol
, sizeof(q_u
->user_pol
));
176 /*******************************************************************
177 Reads or writes a structure.
178 ********************************************************************/
180 BOOL
samr_io_q_unknown_2c(char *desc
, SAMR_Q_UNKNOWN_2C
*q_u
, prs_struct
*ps
, int depth
)
185 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_2c");
191 if(!smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
))
199 /*******************************************************************
201 ********************************************************************/
203 void init_samr_r_unknown_2c(SAMR_R_UNKNOWN_2C
*q_u
, uint32 status
)
205 DEBUG(5,("samr_init_r_unknown_2c\n"));
207 q_u
->unknown_0
= 0x00160000;
208 q_u
->unknown_1
= 0x00000000;
209 q_u
->status
= status
;
213 /*******************************************************************
214 Reads or writes a structure.
215 ********************************************************************/
217 BOOL
samr_io_r_unknown_2c(char *desc
, SAMR_R_UNKNOWN_2C
*r_u
, prs_struct
*ps
, int depth
)
222 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_2c");
228 if(!prs_uint32("unknown_0", ps
, depth
, &r_u
->unknown_0
))
230 if(!prs_uint32("unknown_1", ps
, depth
, &r_u
->unknown_1
))
232 if(!prs_uint32("status ", ps
, depth
, &r_u
->status
))
238 /*******************************************************************
239 Inits a SAMR_Q_UNKNOWN_3 structure.
240 ********************************************************************/
242 void init_samr_q_unknown_3(SAMR_Q_UNKNOWN_3
*q_u
,
243 POLICY_HND
*user_pol
, uint16 switch_value
)
245 DEBUG(5,("samr_init_q_unknown_3\n"));
247 memcpy(&q_u
->user_pol
, user_pol
, sizeof(q_u
->user_pol
));
248 q_u
->switch_value
= switch_value
;
252 /*******************************************************************
253 Reads or writes a structure.
254 ********************************************************************/
256 BOOL
samr_io_q_unknown_3(char *desc
, SAMR_Q_UNKNOWN_3
*q_u
, prs_struct
*ps
, int depth
)
261 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_3");
267 if(!smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
))
273 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
281 /*******************************************************************
282 Inits a SAMR_Q_QUERY_DOMAIN_INFO structure.
283 ********************************************************************/
285 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO
*q_u
,
286 POLICY_HND
*domain_pol
, uint16 switch_value
)
288 DEBUG(5,("init_samr_q_query_dom_info\n"));
290 memcpy(&q_u
->domain_pol
, domain_pol
, sizeof(q_u
->domain_pol
));
291 q_u
->switch_value
= switch_value
;
294 /*******************************************************************
295 Reads or writes a structure.
296 ********************************************************************/
298 BOOL
samr_io_q_query_dom_info(char *desc
, SAMR_Q_QUERY_DOMAIN_INFO
*q_u
, prs_struct
*ps
, int depth
)
303 prs_debug(ps
, depth
, desc
, "samr_io_q_query_dom_info");
309 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
314 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
323 /*******************************************************************
325 ********************************************************************/
327 void init_unk_info2(SAM_UNK_INFO_2
*u_2
, char *domain
, char *server
)
329 int len_domain
= strlen(domain
);
330 int len_server
= strlen(server
);
332 u_2
->unknown_0
= 0x00000000;
333 u_2
->unknown_1
= 0x80000000;
334 u_2
->unknown_2
= 0x00000000;
337 init_uni_hdr(&u_2
->hdr_domain
, len_domain
);
338 init_uni_hdr(&u_2
->hdr_server
, len_server
);
340 u_2
->seq_num
= 0x10000000;
341 u_2
->unknown_3
= 0x00000000;
343 u_2
->unknown_4
= 0x00000001;
344 u_2
->unknown_5
= 0x00000003;
345 u_2
->unknown_6
= 0x00000001;
346 u_2
->num_domain_usrs
= 0x00000008;
347 u_2
->num_domain_grps
= 0x00000003;
348 u_2
->num_local_grps
= 0x00000003;
350 memset(u_2
->padding
, 0, sizeof(u_2
->padding
)); /* 12 bytes zeros */
352 init_unistr2(&u_2
->uni_domain
, domain
, len_domain
);
353 init_unistr2(&u_2
->uni_server
, server
, len_server
);
356 /*******************************************************************
357 Reads or writes a structure.
358 ********************************************************************/
360 BOOL
sam_io_unk_info2(char *desc
, SAM_UNK_INFO_2
*u_2
, prs_struct
*ps
, int depth
)
365 prs_debug(ps
, depth
, desc
, "sam_io_unk_info2");
368 if(!prs_uint32("unknown_0", ps
, depth
, &u_2
->unknown_0
)) /* 0x0000 0000 */
370 if(!prs_uint32("unknown_1", ps
, depth
, &u_2
->unknown_1
)) /* 0x8000 0000 */
372 if(!prs_uint32("unknown_2", ps
, depth
, &u_2
->unknown_2
)) /* 0x0000 0000 */
375 if(!prs_uint32("ptr_0", ps
, depth
, &u_2
->ptr_0
)) /* pointer to unknown structure */
377 if(!smb_io_unihdr("hdr_domain", &u_2
->hdr_domain
, ps
, depth
)) /* domain name unicode header */
379 if(!smb_io_unihdr("hdr_server", &u_2
->hdr_server
, ps
, depth
)) /* server name unicode header */
382 /* put all the data in here, at the moment, including what the above
383 pointer is referring to
386 if(!prs_uint32("seq_num ", ps
, depth
, &u_2
->seq_num
)) /* 0x0000 0099 or 0x1000 0000 */
388 if(!prs_uint32("unknown_3 ", ps
, depth
, &u_2
->unknown_3
)) /* 0x0000 0000 */
391 if(!prs_uint32("unknown_4 ", ps
, depth
, &u_2
->unknown_4
)) /* 0x0000 0001 */
393 if(!prs_uint32("unknown_5 ", ps
, depth
, &u_2
->unknown_5
)) /* 0x0000 0003 */
395 if(!prs_uint32("unknown_6 ", ps
, depth
, &u_2
->unknown_6
)) /* 0x0000 0001 */
397 if(!prs_uint32("num_domain_usrs ", ps
, depth
, &u_2
->num_domain_usrs
)) /* 0x0000 0008 */
399 if(!prs_uint32("num_domain_grps", ps
, depth
, &u_2
->num_domain_grps
)) /* 0x0000 0003 */
401 if(!prs_uint32("num_local_grps", ps
, depth
, &u_2
->num_local_grps
)) /* 0x0000 0003 */
404 if(!prs_uint8s(False
, "padding", ps
, depth
, u_2
->padding
, sizeof(u_2
->padding
))) /* 12 bytes zeros */
407 if(!smb_io_unistr2( "uni_domain", &u_2
->uni_domain
, u_2
->hdr_domain
.buffer
, ps
, depth
)) /* domain name unicode string */
409 if(!smb_io_unistr2( "uni_server", &u_2
->uni_server
, u_2
->hdr_server
.buffer
, ps
, depth
)) /* server name unicode string */
418 /*******************************************************************
419 Inits a SAMR_R_QUERY_DOMAIN_INFO structure.
420 ********************************************************************/
422 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO
*r_u
,
423 uint16 switch_value
, SAM_UNK_CTR
*ctr
,
426 DEBUG(5,("init_samr_r_query_dom_info\n"));
429 r_u
->switch_value
= 0;
430 r_u
->status
= status
; /* return status */
433 r_u
->switch_value
= switch_value
;
439 /*******************************************************************
440 Reads or writes a structure.
441 ********************************************************************/
443 BOOL
samr_io_r_query_dom_info(char *desc
, SAMR_R_QUERY_DOMAIN_INFO
*r_u
, prs_struct
*ps
, int depth
)
448 prs_debug(ps
, depth
, desc
, "samr_io_r_query_dom_info");
454 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
456 if(!prs_uint16("switch_value", ps
, depth
, &r_u
->switch_value
))
461 if (r_u
->ptr_0
!= 0 && r_u
->ctr
!= NULL
) {
462 switch (r_u
->switch_value
) {
464 if(!sam_io_unk_info2("unk_inf2", &r_u
->ctr
->info
.inf2
, ps
, depth
))
468 DEBUG(3,("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
478 /*******************************************************************
479 Inits a DOM_SID3 structure.
480 Calculate length by adding up the size of the components.
481 ********************************************************************/
483 void init_dom_sid3(DOM_SID3
*sid3
, uint16 unk_0
, uint16 unk_1
, DOM_SID
*sid
)
486 sid3
->len
= 2 + 8 + sid3
->sid
.num_auths
* 4;
489 /*******************************************************************
490 Reads or writes a SAM_SID3 structure.
492 this one's odd, because the length (in bytes) is specified at the beginning.
493 the length _includes_ the length of the length, too :-)
495 ********************************************************************/
497 static BOOL
sam_io_dom_sid3(char *desc
, DOM_SID3
*sid3
, prs_struct
*ps
, int depth
)
502 prs_debug(ps
, depth
, desc
, "sam_io_dom_sid3");
505 if(!prs_uint16("len", ps
, depth
, &sid3
->len
))
509 if(!smb_io_dom_sid("", &sid3
->sid
, ps
, depth
))
515 /*******************************************************************
516 Inits a SAMR_R_UNKNOWN3 structure.
521 unknown_4,5 : 0x0000 0014
524 unknown_7 : 0x5800 or 0x0070
526 ********************************************************************/
528 static void init_sam_sid_stuff(SAM_SID_STUFF
*stf
,
529 uint16 unknown_2
, uint16 unknown_3
,
530 uint32 unknown_4
, uint16 unknown_6
, uint16 unknown_7
,
531 int num_sid3s
, DOM_SID3 sid3
[MAX_SAM_SIDS
])
533 stf
->unknown_2
= unknown_2
;
534 stf
->unknown_3
= unknown_3
;
536 memset((char *)stf
->padding1
, '\0', sizeof(stf
->padding1
));
538 stf
->unknown_4
= unknown_4
;
539 stf
->unknown_5
= unknown_4
;
541 stf
->unknown_6
= unknown_6
;
542 stf
->unknown_7
= unknown_7
;
544 stf
->num_sids
= num_sid3s
;
546 stf
->padding2
= 0x0000;
548 memcpy(stf
->sid
, sid3
, sizeof(DOM_SID3
) * num_sid3s
);
551 /*******************************************************************
552 Reads or writes a SAM_SID_STUFF structure.
553 ********************************************************************/
555 static BOOL
sam_io_sid_stuff(char *desc
, SAM_SID_STUFF
*stf
, prs_struct
*ps
, int depth
)
562 DEBUG(5,("init_sam_sid_stuff\n"));
564 if(!prs_uint16("unknown_2", ps
, depth
, &stf
->unknown_2
))
566 if(!prs_uint16("unknown_3", ps
, depth
, &stf
->unknown_3
))
569 if(!prs_uint8s(False
, "padding1", ps
, depth
, stf
->padding1
, sizeof(stf
->padding1
)))
572 if(!prs_uint32("unknown_4", ps
, depth
, &stf
->unknown_4
))
574 if(!prs_uint32("unknown_5", ps
, depth
, &stf
->unknown_5
))
576 if(!prs_uint16("unknown_6", ps
, depth
, &stf
->unknown_6
))
578 if(!prs_uint16("unknown_7", ps
, depth
, &stf
->unknown_7
))
581 if(!prs_uint32("num_sids ", ps
, depth
, &stf
->num_sids
))
583 if(!prs_uint16("padding2 ", ps
, depth
, &stf
->padding2
))
586 SMB_ASSERT_ARRAY(stf
->sid
, stf
->num_sids
);
588 for (i
= 0; i
< stf
->num_sids
; i
++) {
589 if(!sam_io_dom_sid3("", &(stf
->sid
[i
]), ps
, depth
))
596 /*******************************************************************
597 Inits or writes a SAMR_R_UNKNOWN3 structure.
598 ********************************************************************/
600 void init_samr_r_unknown_3(SAMR_R_UNKNOWN_3
*r_u
,
601 uint16 unknown_2
, uint16 unknown_3
,
602 uint32 unknown_4
, uint16 unknown_6
, uint16 unknown_7
,
603 int num_sid3s
, DOM_SID3 sid3
[MAX_SAM_SIDS
],
606 DEBUG(5,("samr_init_r_unknown_3\n"));
614 init_sam_sid_stuff(&(r_u
->sid_stuff
), unknown_2
, unknown_3
,
615 unknown_4
, unknown_6
, unknown_7
,
619 r_u
->status
= status
;
622 /*******************************************************************
623 Reads or writes a SAMR_R_UNKNOWN_3 structure.
625 this one's odd, because the daft buggers use a different mechanism
626 for writing out the array of sids. they put the number of sids in
627 only one place: they've calculated the length of each sid and jumped
628 by that amount. then, retrospectively, the length of the whole buffer
629 is put at the beginning of the data stream.
633 ********************************************************************/
635 BOOL
samr_io_r_unknown_3(char *desc
, SAMR_R_UNKNOWN_3
*r_u
, prs_struct
*ps
, int depth
)
639 int ptr_sid_stuff
= 0;
644 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_3");
650 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
654 /* reading. do the length later */
655 if(!prs_uint32("sid_stuff_len0", ps
, depth
, &r_u
->sid_stuff_len0
))
659 ptr_len0
= prs_offset(ps
);
660 if(!prs_set_offset(ps
, ptr_len0
+ 4))
664 if (r_u
->ptr_0
!= 0) {
665 if(!prs_uint32("ptr_1 ", ps
, depth
, &r_u
->ptr_1
))
668 /* reading. do the length later */
669 if(!prs_uint32("sid_stuff_len1", ps
, depth
, &r_u
->sid_stuff_len1
))
673 ptr_len1
= prs_offset(ps
);
674 if(!prs_set_offset(ps
, ptr_len1
+ 4))
678 if (r_u
->ptr_1
!= 0) {
679 ptr_sid_stuff
= prs_offset(ps
);
680 if(!sam_io_sid_stuff("", &r_u
->sid_stuff
, ps
, depth
))
686 /* storing not reading. do the length, now. */
688 if (ptr_sid_stuff
!= 0) {
689 int old_len
= prs_offset(ps
);
690 uint32 sid_stuff_len
= old_len
- ptr_sid_stuff
;
692 if(!prs_set_offset(ps
, ptr_len0
))
694 if(!prs_uint32("sid_stuff_len0", ps
, depth
, &sid_stuff_len
))
697 if(!prs_set_offset(ps
, ptr_len1
))
699 if(!prs_uint32("sid_stuff_len1", ps
, depth
, &sid_stuff_len
))
702 if(!prs_set_offset(ps
, old_len
))
707 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
713 /*******************************************************************
714 Reads or writes a SAM_STR1 structure.
715 ********************************************************************/
717 static BOOL
sam_io_sam_str1(char *desc
, SAM_STR1
*sam
, uint32 acct_buf
,
718 uint32 name_buf
, uint32 desc_buf
, prs_struct
*ps
, int depth
)
723 prs_debug(ps
, depth
, desc
, "sam_io_sam_str1");
729 if(!smb_io_unistr2("unistr2", &sam
->uni_acct_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
731 if(!smb_io_unistr2("unistr2", &sam
->uni_full_name
, name_buf
, ps
, depth
)) /* full name unicode string */
733 if(!smb_io_unistr2("unistr2", &sam
->uni_acct_desc
, desc_buf
, ps
, depth
)) /* account description unicode string */
739 /*******************************************************************
740 Inits a SAM_ENTRY1 structure.
741 ********************************************************************/
743 static void init_sam_entry1(SAM_ENTRY1
*sam
, uint32 user_idx
,
744 uint32 len_sam_name
, uint32 len_sam_full
, uint32 len_sam_desc
,
745 uint32 rid_user
, uint16 acb_info
)
747 DEBUG(5,("init_sam_entry1\n"));
749 sam
->user_idx
= user_idx
;
750 sam
->rid_user
= rid_user
;
751 sam
->acb_info
= acb_info
;
754 init_uni_hdr(&sam
->hdr_acct_name
, len_sam_name
);
755 init_uni_hdr(&sam
->hdr_user_name
, len_sam_full
);
756 init_uni_hdr(&sam
->hdr_user_desc
, len_sam_desc
);
759 /*******************************************************************
760 Reads or writes a SAM_ENTRY1 structure.
761 ********************************************************************/
763 static BOOL
sam_io_sam_entry1(char *desc
, SAM_ENTRY1
*sam
, prs_struct
*ps
, int depth
)
768 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry1");
774 if(!prs_uint32("user_idx ", ps
, depth
, &sam
->user_idx
))
777 if(!prs_uint32("rid_user ", ps
, depth
, &sam
->rid_user
))
779 if(!prs_uint16("acb_info ", ps
, depth
, &sam
->acb_info
))
781 if(!prs_uint16("pad ", ps
, depth
, &sam
->pad
))
784 if(!smb_io_unihdr("unihdr", &sam
->hdr_acct_name
, ps
, depth
)) /* account name unicode string header */
786 if(!smb_io_unihdr("unihdr", &sam
->hdr_user_name
, ps
, depth
)) /* account name unicode string header */
788 if(!smb_io_unihdr("unihdr", &sam
->hdr_user_desc
, ps
, depth
)) /* account name unicode string header */
794 /*******************************************************************
795 Reads or writes a SAM_STR2 structure.
796 ********************************************************************/
798 static BOOL
sam_io_sam_str2(char *desc
, SAM_STR2
*sam
, uint32 acct_buf
, uint32 desc_buf
, prs_struct
*ps
, int depth
)
803 prs_debug(ps
, depth
, desc
, "sam_io_sam_str2");
809 if(!smb_io_unistr2("unistr2", &sam
->uni_srv_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
811 if(!smb_io_unistr2("unistr2", &sam
->uni_srv_desc
, desc_buf
, ps
, depth
)) /* account description unicode string */
817 /*******************************************************************
818 Inits a SAM_ENTRY2 structure.
819 ********************************************************************/
821 static void init_sam_entry2(SAM_ENTRY2
*sam
, uint32 user_idx
,
822 uint32 len_sam_name
, uint32 len_sam_desc
,
823 uint32 rid_user
, uint16 acb_info
)
825 DEBUG(5,("init_sam_entry2\n"));
827 sam
->user_idx
= user_idx
;
828 sam
->rid_user
= rid_user
;
829 sam
->acb_info
= acb_info
;
832 init_uni_hdr(&sam
->hdr_srv_name
, len_sam_name
);
833 init_uni_hdr(&sam
->hdr_srv_desc
, len_sam_desc
);
836 /*******************************************************************
837 Reads or writes a SAM_ENTRY2 structure.
838 ********************************************************************/
840 static BOOL
sam_io_sam_entry2(char *desc
, SAM_ENTRY2
*sam
, prs_struct
*ps
, int depth
)
845 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry2");
851 if(!prs_uint32("user_idx ", ps
, depth
, &sam
->user_idx
))
854 if(!prs_uint32("rid_user ", ps
, depth
, &sam
->rid_user
))
856 if(!prs_uint16("acb_info ", ps
, depth
, &sam
->acb_info
))
858 if(!prs_uint16("pad ", ps
, depth
, &sam
->pad
))
861 if(!smb_io_unihdr("unihdr", &sam
->hdr_srv_name
, ps
, depth
)) /* account name unicode string header */
863 if(!smb_io_unihdr("unihdr", &sam
->hdr_srv_desc
, ps
, depth
)) /* account name unicode string header */
869 /*******************************************************************
870 Reads or writes a SAM_STR3 structure.
871 ********************************************************************/
873 static BOOL
sam_io_sam_str3(char *desc
, SAM_STR3
*sam
, uint32 acct_buf
, uint32 desc_buf
, prs_struct
*ps
, int depth
)
878 prs_debug(ps
, depth
, desc
, "sam_io_sam_str3");
884 if(!smb_io_unistr2("unistr2", &sam
->uni_grp_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
886 if(!smb_io_unistr2("unistr2", &sam
->uni_grp_desc
, desc_buf
, ps
, depth
)) /* account description unicode string */
892 /*******************************************************************
893 Inits a SAM_ENTRY3 structure.
894 ********************************************************************/
896 static void init_sam_entry3(SAM_ENTRY3
*sam
, uint32 grp_idx
,
897 uint32 len_grp_name
, uint32 len_grp_desc
, uint32 rid_grp
)
899 DEBUG(5,("init_sam_entry3\n"));
901 sam
->grp_idx
= grp_idx
;
902 sam
->rid_grp
= rid_grp
;
903 sam
->attr
= 0x07; /* group rid attributes - gets ignored by nt 4.0 */
905 init_uni_hdr(&sam
->hdr_grp_name
, len_grp_name
);
906 init_uni_hdr(&sam
->hdr_grp_desc
, len_grp_desc
);
909 /*******************************************************************
910 Reads or writes a SAM_ENTRY3 structure.
911 ********************************************************************/
913 static BOOL
sam_io_sam_entry3(char *desc
, SAM_ENTRY3
*sam
, prs_struct
*ps
, int depth
)
918 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry3");
924 if(!prs_uint32("grp_idx", ps
, depth
, &sam
->grp_idx
))
927 if(!prs_uint32("rid_grp", ps
, depth
, &sam
->rid_grp
))
929 if(!prs_uint32("attr ", ps
, depth
, &sam
->attr
))
932 if(!smb_io_unihdr("unihdr", &sam
->hdr_grp_name
, ps
, depth
)) /* account name unicode string header */
934 if(!smb_io_unihdr("unihdr", &sam
->hdr_grp_desc
, ps
, depth
)) /* account name unicode string header */
940 /*******************************************************************
941 Inits a SAM_ENTRY structure.
942 ********************************************************************/
944 static void init_sam_entry(SAM_ENTRY
*sam
, uint32 len_sam_name
, uint32 rid
)
946 DEBUG(5,("init_sam_entry\n"));
949 init_uni_hdr(&sam
->hdr_name
, len_sam_name
);
952 /*******************************************************************
953 Reads or writes a SAM_ENTRY structure.
954 ********************************************************************/
956 static BOOL
sam_io_sam_entry(char *desc
, SAM_ENTRY
*sam
, prs_struct
*ps
, int depth
)
961 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry");
966 if(!prs_uint32("rid", ps
, depth
, &sam
->rid
))
968 if(!smb_io_unihdr("unihdr", &sam
->hdr_name
, ps
, depth
)) /* account name unicode string header */
975 /*******************************************************************
976 Inits a SAMR_Q_ENUM_DOM_USERS structure.
977 ********************************************************************/
979 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS
*q_e
, POLICY_HND
*pol
,
980 uint16 req_num_entries
, uint16 unk_0
,
981 uint16 acb_mask
, uint16 unk_1
, uint32 size
)
983 DEBUG(5,("init_q_enum_dom_users\n"));
985 memcpy(&q_e
->pol
, pol
, sizeof(*pol
));
987 q_e
->req_num_entries
= req_num_entries
; /* zero indicates lots */
988 q_e
->unknown_0
= unk_0
; /* this gets returned in the response */
989 q_e
->acb_mask
= acb_mask
;
990 q_e
->unknown_1
= unk_1
;
991 q_e
->max_size
= size
;
994 /*******************************************************************
995 Reads or writes a structure.
996 ********************************************************************/
998 BOOL
samr_io_q_enum_dom_users(char *desc
, SAMR_Q_ENUM_DOM_USERS
*q_e
, prs_struct
*ps
, int depth
)
1003 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_users");
1009 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
1014 if(!prs_uint16("req_num_entries", ps
, depth
, &q_e
->req_num_entries
))
1016 if(!prs_uint16("unknown_0 ", ps
, depth
, &q_e
->unknown_0
))
1019 if(!prs_uint16("acb_mask ", ps
, depth
, &q_e
->acb_mask
))
1021 if(!prs_uint16("unknown_1 ", ps
, depth
, &q_e
->unknown_1
))
1024 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1034 /*******************************************************************
1035 Inits a SAMR_R_ENUM_DOM_USERS structure.
1036 ********************************************************************/
1038 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS
*r_u
,
1039 uint16 total_num_entries
, uint16 unk_0
,
1040 uint32 num_sam_entries
, SAM_USER_INFO_21 pass
[MAX_SAM_ENTRIES
], uint32 status
)
1044 DEBUG(5,("init_samr_r_enum_dom_users\n"));
1046 if (num_sam_entries
>= MAX_SAM_ENTRIES
) {
1047 num_sam_entries
= MAX_SAM_ENTRIES
;
1048 DEBUG(5,("limiting number of entries to %d\n",
1052 r_u
->total_num_entries
= total_num_entries
;
1053 r_u
->unknown_0
= unk_0
;
1055 if (total_num_entries
> 0) {
1056 r_u
->ptr_entries1
= 1;
1057 r_u
->ptr_entries2
= 1;
1058 r_u
->num_entries2
= num_sam_entries
;
1059 r_u
->num_entries3
= num_sam_entries
;
1061 SMB_ASSERT_ARRAY(r_u
->sam
, num_sam_entries
);
1062 SMB_ASSERT_ARRAY(r_u
->uni_acct_name
, num_sam_entries
);
1064 for (i
= 0; i
< num_sam_entries
; i
++) {
1065 init_sam_entry(&(r_u
->sam
[i
]),
1066 pass
[i
].uni_user_name
.uni_str_len
,
1069 copy_unistr2(&r_u
->uni_acct_name
[i
], &(pass
[i
].uni_user_name
));
1072 r_u
->num_entries4
= num_sam_entries
;
1074 r_u
->ptr_entries1
= 0;
1075 r_u
->num_entries2
= num_sam_entries
;
1076 r_u
->ptr_entries2
= 1;
1079 r_u
->status
= status
;
1082 /*******************************************************************
1083 Reads or writes a structure.
1084 ********************************************************************/
1086 BOOL
samr_io_r_enum_dom_users(char *desc
, SAMR_R_ENUM_DOM_USERS
*r_u
, prs_struct
*ps
, int depth
)
1093 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_users");
1099 if(!prs_uint16("total_num_entries", ps
, depth
, &r_u
->total_num_entries
))
1101 if(!prs_uint16("unknown_0 ", ps
, depth
, &r_u
->unknown_0
))
1103 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
1106 if (r_u
->total_num_entries
!= 0 && r_u
->ptr_entries1
!= 0) {
1107 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
1109 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
1111 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
1114 SMB_ASSERT_ARRAY(r_u
->sam
, r_u
->num_entries2
);
1116 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1117 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
1121 SMB_ASSERT_ARRAY(r_u
->uni_acct_name
, r_u
->num_entries2
);
1123 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1124 if(!smb_io_unistr2("", &r_u
->uni_acct_name
[i
],
1125 r_u
->sam
[i
].hdr_name
.buffer
, ps
, depth
))
1132 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
1136 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1142 /*******************************************************************
1143 Inits a SAMR_Q_ENUM_DOM_ALIASES structure.
1144 ********************************************************************/
1146 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES
*q_e
, POLICY_HND
*pol
, uint32 size
)
1148 DEBUG(5,("init_q_enum_dom_aliases\n"));
1150 memcpy(&q_e
->pol
, pol
, sizeof(*pol
));
1153 q_e
->max_size
= size
;
1157 /*******************************************************************
1158 Reads or writes a structure.
1159 ********************************************************************/
1161 BOOL
samr_io_q_enum_dom_aliases(char *desc
, SAMR_Q_ENUM_DOM_ALIASES
*q_e
, prs_struct
*ps
, int depth
)
1166 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_aliases");
1172 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
1177 if(!prs_uint32("unknown_0", ps
, depth
, &q_e
->unknown_0
))
1179 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1189 /*******************************************************************
1190 Inits a SAMR_R_ENUM_DOM_ALIASES structure.
1191 ********************************************************************/
1193 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES
*r_u
,
1194 uint32 num_sam_entries
, SAM_USER_INFO_21 grps
[MAX_SAM_ENTRIES
],
1199 DEBUG(5,("init_samr_r_enum_dom_aliases\n"));
1201 if (num_sam_entries
>= MAX_SAM_ENTRIES
) {
1202 num_sam_entries
= MAX_SAM_ENTRIES
;
1203 DEBUG(5,("limiting number of entries to %d\n",
1207 r_u
->num_entries
= num_sam_entries
;
1209 if (num_sam_entries
> 0) {
1210 r_u
->ptr_entries
= 1;
1211 r_u
->num_entries2
= num_sam_entries
;
1212 r_u
->ptr_entries2
= 1;
1213 r_u
->num_entries3
= num_sam_entries
;
1215 SMB_ASSERT_ARRAY(r_u
->sam
, num_sam_entries
);
1217 for (i
= 0; i
< num_sam_entries
; i
++) {
1218 init_sam_entry(&r_u
->sam
[i
],
1219 grps
[i
].uni_user_name
.uni_str_len
,
1222 copy_unistr2(&r_u
->uni_grp_name
[i
], &(grps
[i
].uni_user_name
));
1225 r_u
->num_entries4
= num_sam_entries
;
1227 r_u
->ptr_entries
= 0;
1230 r_u
->status
= status
;
1233 /*******************************************************************
1234 Reads or writes a structure.
1235 ********************************************************************/
1237 BOOL
samr_io_r_enum_dom_aliases(char *desc
, SAMR_R_ENUM_DOM_ALIASES
*r_u
, prs_struct
*ps
, int depth
)
1244 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_aliases");
1250 if(!prs_uint32("num_entries", ps
, depth
, &r_u
->num_entries
))
1252 if(!prs_uint32("ptr_entries", ps
, depth
, &r_u
->ptr_entries
))
1255 if (r_u
->num_entries
!= 0 && r_u
->ptr_entries
!= 0) {
1256 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
1258 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
1260 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
1263 SMB_ASSERT_ARRAY(r_u
->sam
, r_u
->num_entries
);
1265 for (i
= 0; i
< r_u
->num_entries
; i
++) {
1266 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
1270 for (i
= 0; i
< r_u
->num_entries
; i
++) {
1271 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
], r_u
->sam
[i
].hdr_name
.buffer
, ps
, depth
))
1278 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
1282 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1289 /*******************************************************************
1290 Inits a SAMR_Q_QUERY_DISPINFO structure.
1291 ********************************************************************/
1293 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO
*q_e
, POLICY_HND
*pol
,
1294 uint16 switch_level
, uint32 start_idx
, uint32 size
)
1296 DEBUG(5,("init_q_query_dispinfo\n"));
1298 memcpy(&q_e
->pol
, pol
, sizeof(*pol
));
1300 q_e
->switch_level
= switch_level
;
1303 q_e
->start_idx
= start_idx
;
1304 q_e
->unknown_1
= 0x000007d0;
1305 q_e
->max_size
= size
;
1308 /*******************************************************************
1309 Reads or writes a structure.
1310 ********************************************************************/
1312 BOOL
samr_io_q_query_dispinfo(char *desc
, SAMR_Q_QUERY_DISPINFO
*q_e
, prs_struct
*ps
, int depth
)
1317 prs_debug(ps
, depth
, desc
, "samr_io_q_query_dispinfo");
1323 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
1328 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
1330 if(!prs_uint16("unknown_0 ", ps
, depth
, &q_e
->unknown_0
))
1332 if(!prs_uint32("start_idx ", ps
, depth
, &q_e
->start_idx
))
1334 if(!prs_uint32("unknown_1 ", ps
, depth
, &q_e
->unknown_1
))
1336 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1346 /*******************************************************************
1347 Inits a SAM_INFO_2 structure.
1348 ********************************************************************/
1350 void init_sam_info_2(SAM_INFO_2
*sam
, uint32 acb_mask
,
1351 uint32 start_idx
, uint32 num_sam_entries
,
1352 SAM_USER_INFO_21 pass
[MAX_SAM_ENTRIES
])
1357 DEBUG(5,("init_sam_info_2\n"));
1359 if (num_sam_entries
>= MAX_SAM_ENTRIES
) {
1360 num_sam_entries
= MAX_SAM_ENTRIES
;
1361 DEBUG(5,("limiting number of entries to %d\n",
1365 for (i
= start_idx
, entries_added
= 0; i
< num_sam_entries
; i
++) {
1366 if (IS_BITS_SET_ALL(pass
[i
].acb_info
, acb_mask
)) {
1367 init_sam_entry2(&sam
->sam
[entries_added
],
1368 start_idx
+ entries_added
+ 1,
1369 pass
[i
].uni_user_name
.uni_str_len
,
1370 pass
[i
].uni_acct_desc
.uni_str_len
,
1374 copy_unistr2(&sam
->str
[entries_added
].uni_srv_name
, &pass
[i
].uni_user_name
);
1375 copy_unistr2(&sam
->str
[entries_added
].uni_srv_desc
, &pass
[i
].uni_acct_desc
);
1380 sam
->num_entries
= entries_added
;
1381 sam
->ptr_entries
= 1;
1382 sam
->num_entries2
= entries_added
;
1386 /*******************************************************************
1387 Reads or writes a structure.
1388 ********************************************************************/
1390 static BOOL
sam_io_sam_info_2(char *desc
, SAM_INFO_2
*sam
, prs_struct
*ps
, int depth
)
1397 prs_debug(ps
, depth
, desc
, "sam_io_sam_info_2");
1403 if(!prs_uint32("num_entries ", ps
, depth
, &sam
->num_entries
))
1405 if(!prs_uint32("ptr_entries ", ps
, depth
, &sam
->ptr_entries
))
1408 if(!prs_uint32("num_entries2 ", ps
, depth
, &sam
->num_entries2
))
1411 SMB_ASSERT_ARRAY(sam
->sam
, sam
->num_entries
);
1413 for (i
= 0; i
< sam
->num_entries
; i
++) {
1414 if(!sam_io_sam_entry2("", &sam
->sam
[i
], ps
, depth
))
1418 for (i
= 0; i
< sam
->num_entries
; i
++) {
1419 if(!sam_io_sam_str2 ("", &sam
->str
[i
],
1420 sam
->sam
[i
].hdr_srv_name
.buffer
,
1421 sam
->sam
[i
].hdr_srv_desc
.buffer
,
1429 /*******************************************************************
1430 Inits a SAM_INFO_1 structure.
1431 ********************************************************************/
1433 void init_sam_info_1(SAM_INFO_1
*sam
, uint32 acb_mask
,
1434 uint32 start_idx
, uint32 num_sam_entries
,
1435 SAM_USER_INFO_21 pass
[MAX_SAM_ENTRIES
])
1440 DEBUG(5,("init_sam_info_1\n"));
1442 if (num_sam_entries
>= MAX_SAM_ENTRIES
) {
1443 num_sam_entries
= MAX_SAM_ENTRIES
;
1444 DEBUG(5,("limiting number of entries to %d\n",
1448 for (i
= start_idx
, entries_added
= 0; i
< num_sam_entries
; i
++) {
1449 if (IS_BITS_SET_ALL(pass
[i
].acb_info
, acb_mask
)) {
1450 init_sam_entry1(&sam
->sam
[entries_added
],
1451 start_idx
+ entries_added
+ 1,
1452 pass
[i
].uni_user_name
.uni_str_len
,
1453 pass
[i
].uni_full_name
.uni_str_len
,
1454 pass
[i
].uni_acct_desc
.uni_str_len
,
1458 copy_unistr2(&sam
->str
[entries_added
].uni_acct_name
, &pass
[i
].uni_user_name
);
1459 copy_unistr2(&sam
->str
[entries_added
].uni_full_name
, &pass
[i
].uni_full_name
);
1460 copy_unistr2(&sam
->str
[entries_added
].uni_acct_desc
, &pass
[i
].uni_acct_desc
);
1466 sam
->num_entries
= entries_added
;
1467 sam
->ptr_entries
= 1;
1468 sam
->num_entries2
= entries_added
;
1471 /*******************************************************************
1472 Reads or writes a structure.
1473 ********************************************************************/
1475 static BOOL
sam_io_sam_info_1(char *desc
, SAM_INFO_1
*sam
, prs_struct
*ps
, int depth
)
1482 prs_debug(ps
, depth
, desc
, "sam_io_sam_info_1");
1488 if(!prs_uint32("num_entries ", ps
, depth
, &sam
->num_entries
))
1490 if(!prs_uint32("ptr_entries ", ps
, depth
, &sam
->ptr_entries
))
1493 if(!prs_uint32("num_entries2 ", ps
, depth
, &sam
->num_entries2
))
1496 SMB_ASSERT_ARRAY(sam
->sam
, sam
->num_entries
);
1498 for (i
= 0; i
< sam
->num_entries
; i
++) {
1499 if(!sam_io_sam_entry1("", &sam
->sam
[i
], ps
, depth
))
1503 for (i
= 0; i
< sam
->num_entries
; i
++) {
1504 if(!sam_io_sam_str1 ("", &sam
->str
[i
],
1505 sam
->sam
[i
].hdr_acct_name
.buffer
,
1506 sam
->sam
[i
].hdr_user_name
.buffer
,
1507 sam
->sam
[i
].hdr_user_desc
.buffer
,
1515 /*******************************************************************
1516 Inits a SAMR_R_QUERY_DISPINFO structure.
1517 ********************************************************************/
1519 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO
*r_u
,
1520 uint16 switch_level
, SAM_INFO_CTR
*ctr
, uint32 status
)
1522 DEBUG(5,("init_samr_r_query_dispinfo\n"));
1524 if (status
== 0x0) {
1525 r_u
->unknown_0
= 0x0000001;
1526 r_u
->unknown_1
= 0x0000001;
1528 r_u
->unknown_0
= 0x0;
1529 r_u
->unknown_1
= 0x0;
1532 r_u
->switch_level
= switch_level
;
1534 r_u
->status
= status
;
1537 /*******************************************************************
1538 Reads or writes a structure.
1539 ********************************************************************/
1541 BOOL
samr_io_r_query_dispinfo(char *desc
, SAMR_R_QUERY_DISPINFO
*r_u
, prs_struct
*ps
, int depth
)
1546 prs_debug(ps
, depth
, desc
, "samr_io_r_query_dispinfo");
1552 if(!prs_uint32("unknown_0 ", ps
, depth
, &r_u
->unknown_0
))
1554 if(!prs_uint32("unknown_1 ", ps
, depth
, &r_u
->unknown_1
))
1556 if(!prs_uint16("switch_level ", ps
, depth
, &r_u
->switch_level
))
1562 switch (r_u
->switch_level
) {
1564 if(!sam_io_sam_info_1("users", r_u
->ctr
->sam
.info1
, ps
, depth
))
1568 if(!sam_io_sam_info_2("servers", r_u
->ctr
->sam
.info2
, ps
, depth
))
1572 DEBUG(5,("samr_io_r_query_dispinfo: unknown switch value\n"));
1576 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1582 /*******************************************************************
1583 Inits a SAMR_Q_ENUM_DOM_GROUPS structure.
1584 ********************************************************************/
1586 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS
*q_e
, POLICY_HND
*pol
,
1587 uint16 switch_level
, uint32 start_idx
, uint32 size
)
1589 DEBUG(5,("init_q_enum_dom_groups\n"));
1591 memcpy(&q_e
->pol
, pol
, sizeof(*pol
));
1593 q_e
->switch_level
= switch_level
;
1596 q_e
->start_idx
= start_idx
;
1597 q_e
->unknown_1
= 0x000007d0;
1598 q_e
->max_size
= size
;
1601 /*******************************************************************
1602 Reads or writes a structure.
1603 ********************************************************************/
1605 BOOL
samr_io_q_enum_dom_groups(char *desc
, SAMR_Q_ENUM_DOM_GROUPS
*q_e
, prs_struct
*ps
, int depth
)
1610 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_groups");
1616 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
1621 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
1623 if(!prs_uint16("unknown_0 ", ps
, depth
, &q_e
->unknown_0
))
1625 if(!prs_uint32("start_idx ", ps
, depth
, &q_e
->start_idx
))
1627 if(!prs_uint32("unknown_1 ", ps
, depth
, &q_e
->unknown_1
))
1629 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1639 /*******************************************************************
1640 Inits a SAMR_R_ENUM_DOM_GROUPS structure.
1641 ********************************************************************/
1643 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS
*r_u
,
1644 uint32 start_idx
, uint32 num_sam_entries
,
1645 SAM_USER_INFO_21 pass
[MAX_SAM_ENTRIES
],
1651 DEBUG(5,("init_samr_r_enum_dom_groups\n"));
1653 if (num_sam_entries
>= MAX_SAM_ENTRIES
) {
1654 num_sam_entries
= MAX_SAM_ENTRIES
;
1655 DEBUG(5,("limiting number of entries to %d\n",
1659 if (status
== 0x0) {
1660 for (i
= start_idx
, entries_added
= 0; i
< num_sam_entries
; i
++) {
1661 init_sam_entry3(&r_u
->sam
[entries_added
],
1662 start_idx
+ entries_added
+ 1,
1663 pass
[i
].uni_user_name
.uni_str_len
,
1664 pass
[i
].uni_acct_desc
.uni_str_len
,
1667 copy_unistr2(&r_u
->str
[entries_added
].uni_grp_name
,
1668 &pass
[i
].uni_user_name
);
1669 copy_unistr2(&r_u
->str
[entries_added
].uni_grp_desc
,
1670 &pass
[i
].uni_acct_desc
);
1675 if (entries_added
> 0) {
1676 r_u
->unknown_0
= 0x0000492;
1677 r_u
->unknown_1
= 0x000049a;
1679 r_u
->unknown_0
= 0x0;
1680 r_u
->unknown_1
= 0x0;
1682 r_u
->switch_level
= 3;
1683 r_u
->num_entries
= entries_added
;
1684 r_u
->ptr_entries
= 1;
1685 r_u
->num_entries2
= entries_added
;
1687 r_u
->switch_level
= 0;
1690 r_u
->status
= status
;
1693 /*******************************************************************
1694 Reads or writes a structure.
1695 ********************************************************************/
1697 BOOL
samr_io_r_enum_dom_groups(char *desc
, SAMR_R_ENUM_DOM_GROUPS
*r_u
, prs_struct
*ps
, int depth
)
1704 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_groups");
1710 if(!prs_uint32("unknown_0 ", ps
, depth
, &r_u
->unknown_0
))
1712 if(!prs_uint32("unknown_1 ", ps
, depth
, &r_u
->unknown_1
))
1714 if(!prs_uint32("switch_level ", ps
, depth
, &r_u
->switch_level
))
1717 if (r_u
->switch_level
!= 0) {
1718 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
1720 if(!prs_uint32("ptr_entries ", ps
, depth
, &r_u
->ptr_entries
))
1723 if(!prs_uint32("num_entries2 ", ps
, depth
, &r_u
->num_entries2
))
1726 SMB_ASSERT_ARRAY(r_u
->sam
, r_u
->num_entries
);
1728 for (i
= 0; i
< r_u
->num_entries
; i
++) {
1729 if(!sam_io_sam_entry3("", &r_u
->sam
[i
], ps
, depth
))
1733 for (i
= 0; i
< r_u
->num_entries
; i
++) {
1734 if(!sam_io_sam_str3 ("", &r_u
->str
[i
],
1735 r_u
->sam
[i
].hdr_grp_name
.buffer
,
1736 r_u
->sam
[i
].hdr_grp_desc
.buffer
,
1742 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1748 /*******************************************************************
1749 Inits a SAMR_Q_QUERY_ALIASINFO structure.
1750 ********************************************************************/
1752 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO
*q_e
,
1754 uint16 switch_level
)
1756 DEBUG(5,("init_q_query_aliasinfo\n"));
1758 memcpy(&q_e
->pol
, pol
, sizeof(*pol
));
1760 q_e
->switch_level
= switch_level
;
1763 /*******************************************************************
1764 Reads or writes a structure.
1765 ********************************************************************/
1767 BOOL
samr_io_q_query_aliasinfo(char *desc
, SAMR_Q_QUERY_ALIASINFO
*q_e
, prs_struct
*ps
, int depth
)
1772 prs_debug(ps
, depth
, desc
, "samr_io_q_query_aliasinfo");
1778 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
1783 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
1789 /*******************************************************************
1790 Inits a SAMR_R_QUERY_ALIASINFO structure.
1791 ********************************************************************/
1793 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO
*r_u
,
1794 uint16 switch_value
, char *acct_desc
,
1797 DEBUG(5,("init_samr_r_query_aliasinfo\n"));
1802 r_u
->switch_value
= switch_value
;
1804 switch (switch_value
) {
1807 int acct_len
= acct_desc
? strlen(acct_desc
) : 0;
1811 init_uni_hdr(&r_u
->alias
.info3
.hdr_acct_desc
, acct_len
);
1812 init_unistr2(&r_u
->alias
.info3
.uni_acct_desc
, acct_desc
, acct_len
);
1817 DEBUG(4,("init_samr_r_query_aliasinfo: unsupported switch level\n"));
1822 r_u
->status
= status
;
1825 /*******************************************************************
1826 Reads or writes a structure.
1827 ********************************************************************/
1829 BOOL
samr_io_r_query_aliasinfo(char *desc
, SAMR_R_QUERY_ALIASINFO
*r_u
, prs_struct
*ps
, int depth
)
1834 prs_debug(ps
, depth
, desc
, "samr_io_r_query_aliasinfo");
1840 if(!prs_uint32("ptr ", ps
, depth
, &r_u
->ptr
))
1843 if (r_u
->ptr
!= 0) {
1844 if(!prs_uint16("switch_value", ps
, depth
, &r_u
->switch_value
))
1849 if (r_u
->switch_value
!= 0) {
1850 switch (r_u
->switch_value
) {
1852 if(!smb_io_unihdr ("", &r_u
->alias
.info3
.hdr_acct_desc
, ps
, depth
))
1854 if(!smb_io_unistr2("", &r_u
->alias
.info3
.uni_acct_desc
,
1855 r_u
->alias
.info3
.hdr_acct_desc
.buffer
, ps
, depth
))
1859 DEBUG(4,("samr_io_r_query_aliasinfo: unsupported switch level\n"));
1868 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1874 /*******************************************************************
1875 Reads or writes a SAMR_Q_LOOKUP_IDS structure.
1876 ********************************************************************/
1878 BOOL
samr_io_q_lookup_ids(char *desc
, SAMR_Q_LOOKUP_IDS
*q_u
, prs_struct
*ps
, int depth
)
1886 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_ids");
1892 if(!smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
))
1897 if(!prs_uint32("num_sids1", ps
, depth
, &q_u
->num_sids1
))
1899 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
1901 if(!prs_uint32("num_sids2", ps
, depth
, &q_u
->num_sids2
))
1904 SMB_ASSERT_ARRAY(q_u
->ptr_sid
, q_u
->num_sids2
);
1906 for (i
= 0; i
< q_u
->num_sids2
; i
++) {
1907 slprintf(tmp
, sizeof(tmp
) - 1, "ptr[%02d]", i
);
1908 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->ptr_sid
[i
]))
1912 for (i
= 0; i
< q_u
->num_sids2
; i
++) {
1913 if (q_u
->ptr_sid
[i
] != 0) {
1914 slprintf(tmp
, sizeof(tmp
)-1, "sid[%02d]", i
);
1915 if(!smb_io_dom_sid2(tmp
, &q_u
->sid
[i
], ps
, depth
))
1926 /*******************************************************************
1927 Inits a SAMR_R_LOOKUP_IDS structure.
1928 ********************************************************************/
1930 void init_samr_r_lookup_ids(SAMR_R_LOOKUP_IDS
*r_u
,
1931 uint32 num_rids
, uint32
*rid
, uint32 status
)
1935 DEBUG(5,("init_samr_r_lookup_ids\n"));
1937 if (status
== 0x0) {
1938 r_u
->num_entries
= num_rids
;
1940 r_u
->num_entries2
= num_rids
;
1942 SMB_ASSERT_ARRAY(r_u
->rid
, num_rids
);
1944 for (i
= 0; i
< num_rids
; i
++) {
1945 r_u
->rid
[i
] = rid
[i
];
1948 r_u
->num_entries
= 0;
1950 r_u
->num_entries2
= 0;
1953 r_u
->status
= status
;
1956 /*******************************************************************
1957 Reads or writes a structure.
1958 ********************************************************************/
1960 BOOL
samr_io_r_lookup_ids(char *desc
, SAMR_R_LOOKUP_IDS
*r_u
, prs_struct
*ps
, int depth
)
1968 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_ids");
1974 if(!prs_uint32("num_entries", ps
, depth
, &r_u
->num_entries
))
1976 if(!prs_uint32("ptr ", ps
, depth
, &r_u
->ptr
))
1978 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
1981 if (r_u
->num_entries
!= 0) {
1982 SMB_ASSERT_ARRAY(r_u
->rid
, r_u
->num_entries2
);
1984 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1985 slprintf(tmp
, sizeof(tmp
)-1, "rid[%02d]", i
);
1986 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->rid
[i
]))
1991 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1997 /*******************************************************************
1998 Reads or writes a structure.
1999 ********************************************************************/
2001 BOOL
samr_io_q_lookup_names(char *desc
, SAMR_Q_LOOKUP_NAMES
*q_u
, prs_struct
*ps
, int depth
)
2008 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_names");
2013 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
2018 if(!prs_uint32("num_names1", ps
, depth
, &q_u
->num_names1
))
2020 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
2022 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
2024 if(!prs_uint32("num_names2", ps
, depth
, &q_u
->num_names2
))
2027 SMB_ASSERT_ARRAY(q_u
->hdr_name
, q_u
->num_names2
);
2029 for (i
= 0; i
< q_u
->num_names2
; i
++) {
2030 if(!smb_io_unihdr ("", &q_u
->hdr_name
[i
], ps
, depth
))
2033 for (i
= 0; i
< q_u
->num_names2
; i
++) {
2034 if(!smb_io_unistr2("", &q_u
->uni_name
[i
], q_u
->hdr_name
[i
].buffer
, ps
, depth
))
2042 /*******************************************************************
2043 Inits a SAMR_R_LOOKUP_NAMES structure.
2044 ********************************************************************/
2046 void init_samr_r_lookup_names(SAMR_R_LOOKUP_NAMES
*r_u
,
2047 uint32 num_rids
, uint32
*rid
, uint8
*type
, uint32 status
)
2051 DEBUG(5,("init_samr_r_lookup_names\n"));
2053 if (status
== 0x0) {
2054 r_u
->num_types1
= num_rids
;
2056 r_u
->num_types2
= num_rids
;
2058 r_u
->num_rids1
= num_rids
;
2060 r_u
->num_rids2
= num_rids
;
2062 SMB_ASSERT_ARRAY(r_u
->rid
, num_rids
);
2064 for (i
= 0; i
< num_rids
; i
++) {
2065 r_u
->rid
[i
] = rid
[i
];
2066 r_u
->type
[i
] = type
[i
];
2069 r_u
->num_types1
= 0;
2071 r_u
->num_types2
= 0;
2078 r_u
->status
= status
;
2081 /*******************************************************************
2082 Reads or writes a structure.
2083 ********************************************************************/
2085 BOOL
samr_io_r_lookup_names(char *desc
, SAMR_R_LOOKUP_NAMES
*r_u
, prs_struct
*ps
, int depth
)
2093 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_names");
2099 if(!prs_uint32("num_rids1", ps
, depth
, &r_u
->num_rids1
))
2101 if(!prs_uint32("ptr_rids ", ps
, depth
, &r_u
->ptr_rids
))
2104 if (r_u
->ptr_rids
!= 0) {
2105 if(!prs_uint32("num_rids2", ps
, depth
, &r_u
->num_rids2
))
2108 if (r_u
->num_rids2
!= r_u
->num_rids1
) {
2113 for (i
= 0; i
< r_u
->num_rids2
; i
++) {
2114 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
2115 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->rid
[i
]))
2120 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
2122 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
2125 if (r_u
->ptr_types
!= 0) {
2126 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
2129 if (r_u
->num_types2
!= r_u
->num_types1
) {
2134 for (i
= 0; i
< r_u
->num_types2
; i
++) {
2135 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
2136 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->type
[i
]))
2141 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
2147 /*******************************************************************
2148 Reads or writes a structure.
2149 ********************************************************************/
2151 BOOL
samr_io_q_unknown_12(char *desc
, SAMR_Q_UNKNOWN_12
*q_u
, prs_struct
*ps
, int depth
)
2159 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_12");
2165 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
2170 if(!prs_uint32("num_gids1", ps
, depth
, &q_u
->num_gids1
))
2172 if(!prs_uint32("rid ", ps
, depth
, &q_u
->rid
))
2174 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
2176 if(!prs_uint32("num_gids2", ps
, depth
, &q_u
->num_gids2
))
2179 SMB_ASSERT_ARRAY(q_u
->gid
, q_u
->num_gids2
);
2181 for (i
= 0; i
< q_u
->num_gids2
; i
++) {
2182 slprintf(tmp
, sizeof(tmp
) - 1, "gid[%02d] ", i
);
2183 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->gid
[i
]))
2193 /*******************************************************************
2194 Inits a SAMR_R_UNKNOWN_12 structure.
2195 ********************************************************************/
2197 void init_samr_r_unknown_12(SAMR_R_UNKNOWN_12
*r_u
,
2198 uint32 num_aliases
, fstring
*als_name
, uint32
*num_als_usrs
,
2203 DEBUG(5,("init_samr_r_unknown_12\n"));
2205 if (status
== 0x0) {
2206 r_u
->num_aliases1
= num_aliases
;
2207 r_u
->ptr_aliases
= 1;
2208 r_u
->num_aliases2
= num_aliases
;
2210 r_u
->num_als_usrs1
= num_aliases
;
2211 r_u
->ptr_als_usrs
= 1;
2212 r_u
->num_als_usrs2
= num_aliases
;
2214 SMB_ASSERT_ARRAY(r_u
->hdr_als_name
, num_aliases
);
2216 for (i
= 0; i
< num_aliases
; i
++) {
2217 int als_len
= als_name
[i
] != NULL
? strlen(als_name
[i
]) : 0;
2218 init_uni_hdr(&r_u
->hdr_als_name
[i
], als_len
);
2219 init_unistr2(&r_u
->uni_als_name
[i
], als_name
[i
], als_len
);
2220 r_u
->num_als_usrs
[i
] = num_als_usrs
[i
];
2223 r_u
->num_aliases1
= num_aliases
;
2224 r_u
->ptr_aliases
= 0;
2225 r_u
->num_aliases2
= num_aliases
;
2227 r_u
->num_als_usrs1
= num_aliases
;
2228 r_u
->ptr_als_usrs
= 0;
2229 r_u
->num_als_usrs2
= num_aliases
;
2232 r_u
->status
= status
;
2235 /*******************************************************************
2236 Reads or writes a structure.
2237 ********************************************************************/
2239 BOOL
samr_io_r_unknown_12(char *desc
, SAMR_R_UNKNOWN_12
*r_u
, prs_struct
*ps
, int depth
)
2247 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_12");
2253 if(!prs_uint32("num_aliases1", ps
, depth
, &r_u
->num_aliases1
))
2255 if(!prs_uint32("ptr_aliases ", ps
, depth
, &r_u
->ptr_aliases
))
2257 if(!prs_uint32("num_aliases2", ps
, depth
, &r_u
->num_aliases2
))
2260 if (r_u
->ptr_aliases
!= 0 && r_u
->num_aliases1
!= 0) {
2261 SMB_ASSERT_ARRAY(r_u
->hdr_als_name
, r_u
->num_aliases2
);
2263 for (i
= 0; i
< r_u
->num_aliases2
; i
++) {
2264 slprintf(tmp
, sizeof(tmp
) - 1, "als_hdr[%02d] ", i
);
2265 if(!smb_io_unihdr ("", &r_u
->hdr_als_name
[i
], ps
, depth
))
2268 for (i
= 0; i
< r_u
->num_aliases2
; i
++) {
2269 slprintf(tmp
, sizeof(tmp
) - 1, "als_str[%02d] ", i
);
2270 if(!smb_io_unistr2("", &r_u
->uni_als_name
[i
], r_u
->hdr_als_name
[i
].buffer
, ps
, depth
))
2278 if(!prs_uint32("num_als_usrs1", ps
, depth
, &r_u
->num_als_usrs1
))
2280 if(!prs_uint32("ptr_als_usrs ", ps
, depth
, &r_u
->ptr_als_usrs
))
2282 if(!prs_uint32("num_als_usrs2", ps
, depth
, &r_u
->num_als_usrs2
))
2285 if (r_u
->ptr_als_usrs
!= 0 && r_u
->num_als_usrs1
!= 0) {
2286 SMB_ASSERT_ARRAY(r_u
->num_als_usrs
, r_u
->num_als_usrs2
);
2288 for (i
= 0; i
< r_u
->num_als_usrs2
; i
++) {
2289 slprintf(tmp
, sizeof(tmp
) - 1, "als_usrs[%02d] ", i
);
2290 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->num_als_usrs
[i
]))
2295 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
2302 /*******************************************************************
2303 Inits a SAMR_Q_OPEN_USER struct.
2304 ********************************************************************/
2306 void init_samr_q_open_user(SAMR_Q_OPEN_USER
*q_u
,
2308 uint32 unk_0
, uint32 rid
)
2310 DEBUG(5,("samr_init_q_open_user\n"));
2312 memcpy(&q_u
->domain_pol
, pol
, sizeof(q_u
->domain_pol
));
2314 q_u
->unknown_0
= unk_0
;
2315 q_u
->user_rid
= rid
;
2318 /*******************************************************************
2319 Reads or writes a structure.
2320 ********************************************************************/
2322 BOOL
samr_io_q_open_user(char *desc
, SAMR_Q_OPEN_USER
*q_u
, prs_struct
*ps
, int depth
)
2327 prs_debug(ps
, depth
, desc
, "samr_io_q_open_user");
2333 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
2338 if(!prs_uint32("unknown_0", ps
, depth
, &q_u
->unknown_0
))
2340 if(!prs_uint32("user_rid ", ps
, depth
, &q_u
->user_rid
))
2349 /*******************************************************************
2350 Reads or writes a structure.
2351 ********************************************************************/
2353 BOOL
samr_io_r_open_user(char *desc
, SAMR_R_OPEN_USER
*r_u
, prs_struct
*ps
, int depth
)
2358 prs_debug(ps
, depth
, desc
, "samr_io_r_open_user");
2364 if(!smb_io_pol_hnd("user_pol", &r_u
->user_pol
, ps
, depth
))
2369 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
2375 /*******************************************************************
2376 Inits a SAMR_Q_QUERY_USERGROUPS structure.
2377 ********************************************************************/
2379 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS
*q_u
,
2382 DEBUG(5,("init_samr_q_query_usergroups\n"));
2384 memcpy(&q_u
->pol
, hnd
, sizeof(q_u
->pol
));
2387 /*******************************************************************
2388 Reads or writes a structure.
2389 ********************************************************************/
2391 BOOL
samr_io_q_query_usergroups(char *desc
, SAMR_Q_QUERY_USERGROUPS
*q_u
, prs_struct
*ps
, int depth
)
2396 prs_debug(ps
, depth
, desc
, "samr_io_q_query_usergroups");
2402 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
2410 /*******************************************************************
2411 Inits a SAMR_R_QUERY_USERGROUPS structure.
2412 ********************************************************************/
2414 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS
*r_u
,
2415 uint32 num_gids
, DOM_GID
*gid
, uint32 status
)
2417 DEBUG(5,("init_samr_r_query_usergroups\n"));
2419 if (status
== 0x0) {
2421 r_u
->num_entries
= num_gids
;
2423 r_u
->num_entries2
= num_gids
;
2428 r_u
->num_entries
= 0;
2432 r_u
->status
= status
;
2435 /*******************************************************************
2436 Reads or writes a structure.
2437 ********************************************************************/
2439 BOOL
samr_io_r_query_usergroups(char *desc
, SAMR_R_QUERY_USERGROUPS
*r_u
, prs_struct
*ps
, int depth
)
2446 prs_debug(ps
, depth
, desc
, "samr_io_r_query_usergroups");
2452 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
2455 if (r_u
->ptr_0
!= 0) {
2456 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
2458 if(!prs_uint32("ptr_1 ", ps
, depth
, &r_u
->ptr_1
))
2461 if (r_u
->num_entries
!= 0) {
2462 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
2465 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
2466 if(!smb_io_gid("", &r_u
->gid
[i
], ps
, depth
))
2472 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
2478 /*******************************************************************
2479 Inits a SAMR_Q_QUERY_USERINFO structure.
2480 ********************************************************************/
2482 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO
*q_u
,
2483 POLICY_HND
*hnd
, uint16 switch_value
)
2485 DEBUG(5,("init_samr_q_query_userinfo\n"));
2487 memcpy(&q_u
->pol
, hnd
, sizeof(q_u
->pol
));
2488 q_u
->switch_value
= switch_value
;
2491 /*******************************************************************
2492 Reads or writes a structure.
2493 ********************************************************************/
2495 BOOL
samr_io_q_query_userinfo(char *desc
, SAMR_Q_QUERY_USERINFO
*q_u
, prs_struct
*ps
, int depth
)
2500 prs_debug(ps
, depth
, desc
, "samr_io_q_query_userinfo");
2506 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
2511 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
)) /* 0x0015 or 0x0011 */
2517 /*******************************************************************
2518 Reads or writes a LOGON_HRS structure.
2519 ********************************************************************/
2521 static BOOL
sam_io_logon_hrs(char *desc
, LOGON_HRS
*hrs
, prs_struct
*ps
, int depth
)
2526 prs_debug(ps
, depth
, desc
, "sam_io_logon_hrs");
2532 if(!prs_uint32 ( "len ", ps
, depth
, &hrs
->len
))
2535 if (hrs
->len
> 64) {
2536 DEBUG(5,("sam_io_logon_hrs: truncating length\n"));
2540 if(!prs_uint8s (False
, "hours", ps
, depth
, hrs
->hours
, hrs
->len
))
2546 /*******************************************************************
2547 Inits a SAM_USER_INFO_10 structure.
2548 ********************************************************************/
2550 void init_sam_user_info10(SAM_USER_INFO_10
*usr
,
2553 DEBUG(5,("init_sam_user_info10\n"));
2555 usr
->acb_info
= acb_info
;
2558 /*******************************************************************
2559 Reads or writes a structure.
2560 ********************************************************************/
2562 BOOL
sam_io_user_info10(char *desc
, SAM_USER_INFO_10
*usr
, prs_struct
*ps
, int depth
)
2567 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info10");
2573 if(!prs_uint32("acb_info", ps
, depth
, &usr
->acb_info
))
2579 /*******************************************************************
2580 Inits a SAM_USER_INFO_11 structure.
2581 ********************************************************************/
2583 void init_sam_user_info11(SAM_USER_INFO_11
*usr
,
2593 DEBUG(5,("init_sam_user_info11\n"));
2595 len_mach_acct
= strlen(mach_acct
);
2597 memcpy(&usr
->expiry
,expiry
, sizeof(usr
->expiry
)); /* expiry time or something? */
2598 memset((char *)usr
->padding_1
, '\0', sizeof(usr
->padding_1
)); /* 0 - padding 24 bytes */
2600 init_uni_hdr(&usr
->hdr_mach_acct
, len_mach_acct
); /* unicode header for machine account */
2601 usr
->padding_2
= 0; /* 0 - padding 4 bytes */
2603 usr
->ptr_1
= 1; /* pointer */
2604 memset((char *)usr
->padding_3
, '\0', sizeof(usr
->padding_3
)); /* 0 - padding 32 bytes */
2605 usr
->padding_4
= 0; /* 0 - padding 4 bytes */
2607 usr
->ptr_2
= 1; /* pointer */
2608 usr
->padding_5
= 0; /* 0 - padding 4 bytes */
2610 usr
->ptr_3
= 1; /* pointer */
2611 memset((char *)usr
->padding_6
, '\0', sizeof(usr
->padding_6
)); /* 0 - padding 32 bytes */
2613 usr
->rid_user
= rid_user
;
2614 usr
->rid_group
= rid_group
;
2616 usr
->acct_ctrl
= acct_ctrl
;
2617 usr
->unknown_3
= 0x0000;
2619 usr
->unknown_4
= 0x003f; /* 0x003f - 16 bit unknown */
2620 usr
->unknown_5
= 0x003c; /* 0x003c - 16 bit unknown */
2622 memset((char *)usr
->padding_7
, '\0', sizeof(usr
->padding_7
)); /* 0 - padding 16 bytes */
2623 usr
->padding_8
= 0; /* 0 - padding 4 bytes */
2625 init_unistr2(&usr
->uni_mach_acct
, mach_acct
, len_mach_acct
); /* unicode string for machine account */
2627 memset((char *)usr
->padding_9
, '\0', sizeof(usr
->padding_9
)); /* 0 - padding 48 bytes */
2630 /*******************************************************************
2631 Reads or writes a structure.
2632 ********************************************************************/
2634 BOOL
sam_io_user_info11(char *desc
, SAM_USER_INFO_11
*usr
, prs_struct
*ps
, int depth
)
2639 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_24");
2645 if(!prs_uint8s (False
, "padding_0", ps
, depth
, usr
->padding_0
, sizeof(usr
->padding_0
)))
2648 if(!smb_io_time("time", &(usr
->expiry
), ps
, depth
))
2651 if(!prs_uint8s (False
, "padding_1", ps
, depth
, usr
->padding_1
, sizeof(usr
->padding_1
)))
2654 if(!smb_io_unihdr ("unihdr", &usr
->hdr_mach_acct
, ps
, depth
))
2656 if(!prs_uint32( "padding_2", ps
, depth
, &usr
->padding_2
))
2659 if(!prs_uint32( "ptr_1 ", ps
, depth
, &usr
->ptr_1
))
2661 if(!prs_uint8s (False
, "padding_3", ps
, depth
, usr
->padding_3
, sizeof(usr
->padding_3
)))
2663 if(!prs_uint32( "padding_4", ps
, depth
, &usr
->padding_4
))
2666 if(!prs_uint32( "ptr_2 ", ps
, depth
, &usr
->ptr_2
))
2668 if(!prs_uint32( "padding_5", ps
, depth
, &usr
->padding_5
))
2671 if(!prs_uint32( "ptr_3 ", ps
, depth
, &usr
->ptr_3
))
2673 if(!prs_uint8s(False
, "padding_6", ps
, depth
, usr
->padding_6
, sizeof(usr
->padding_6
)))
2676 if(!prs_uint32( "rid_user ", ps
, depth
, &usr
->rid_user
))
2678 if(!prs_uint32( "rid_group", ps
, depth
, &usr
->rid_group
))
2680 if(!prs_uint16( "acct_ctrl", ps
, depth
, &usr
->acct_ctrl
))
2682 if(!prs_uint16( "unknown_3", ps
, depth
, &usr
->unknown_3
))
2684 if(!prs_uint16( "unknown_4", ps
, depth
, &usr
->unknown_4
))
2686 if(!prs_uint16( "unknown_5", ps
, depth
, &usr
->unknown_5
))
2689 if(!prs_uint8s (False
, "padding_7", ps
, depth
, usr
->padding_7
, sizeof(usr
->padding_7
)))
2691 if(!prs_uint32( "padding_8", ps
, depth
, &usr
->padding_8
))
2694 if(!smb_io_unistr2("unistr2", &usr
->uni_mach_acct
, True
, ps
, depth
))
2699 if(!prs_uint8s(False
, "padding_9", ps
, depth
, usr
->padding_9
, sizeof(usr
->padding_9
)))
2705 /*************************************************************************
2706 init_sam_user_info21
2708 unknown_3 = 0x00ff ffff
2709 unknown_5 = 0x0002 0000
2710 unknown_6 = 0x0000 04ec
2712 *************************************************************************/
2714 void init_sam_user_info21(SAM_USER_INFO_21
*usr
,
2716 NTTIME
*logoff_time
,
2717 NTTIME
*kickoff_time
,
2718 NTTIME
*pass_last_set_time
,
2719 NTTIME
*pass_can_change_time
,
2720 NTTIME
*pass_must_change_time
,
2743 int len_user_name
= user_name
!= NULL
? strlen(user_name
) : 0;
2744 int len_full_name
= full_name
!= NULL
? strlen(full_name
) : 0;
2745 int len_home_dir
= home_dir
!= NULL
? strlen(home_dir
) : 0;
2746 int len_dir_drive
= dir_drive
!= NULL
? strlen(dir_drive
) : 0;
2747 int len_logon_script
= logon_script
!= NULL
? strlen(logon_script
) : 0;
2748 int len_profile_path
= profile_path
!= NULL
? strlen(profile_path
) : 0;
2749 int len_description
= description
!= NULL
? strlen(description
) : 0;
2750 int len_workstations
= workstations
!= NULL
? strlen(workstations
) : 0;
2751 int len_unknown_str
= unknown_str
!= NULL
? strlen(unknown_str
) : 0;
2752 int len_munged_dial
= munged_dial
!= NULL
? strlen(munged_dial
) : 0;
2754 usr
->logon_time
= *logon_time
;
2755 usr
->logoff_time
= *logoff_time
;
2756 usr
->kickoff_time
= *kickoff_time
;
2757 usr
->pass_last_set_time
= *pass_last_set_time
;
2758 usr
->pass_can_change_time
= *pass_can_change_time
;
2759 usr
->pass_must_change_time
= *pass_must_change_time
;
2761 init_uni_hdr(&usr
->hdr_user_name
, len_user_name
);
2762 init_uni_hdr(&usr
->hdr_full_name
, len_full_name
);
2763 init_uni_hdr(&usr
->hdr_home_dir
, len_home_dir
);
2764 init_uni_hdr(&usr
->hdr_dir_drive
, len_dir_drive
);
2765 init_uni_hdr(&usr
->hdr_logon_script
, len_logon_script
);
2766 init_uni_hdr(&usr
->hdr_profile_path
, len_profile_path
);
2767 init_uni_hdr(&usr
->hdr_acct_desc
, len_description
);
2768 init_uni_hdr(&usr
->hdr_workstations
, len_workstations
);
2769 init_uni_hdr(&usr
->hdr_unknown_str
, len_unknown_str
);
2770 init_uni_hdr(&usr
->hdr_munged_dial
, len_munged_dial
);
2772 memset((char *)usr
->nt_pwd
, '\0', sizeof(usr
->nt_pwd
));
2773 memset((char *)usr
->lm_pwd
, '\0', sizeof(usr
->lm_pwd
));
2775 usr
->user_rid
= user_rid
;
2776 usr
->group_rid
= group_rid
;
2777 usr
->acb_info
= acb_info
;
2778 usr
->unknown_3
= unknown_3
; /* 0x00ff ffff */
2780 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
2781 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
2782 usr
->unknown_5
= unknown_5
; /* 0x0002 0000 */
2784 memset((char *)usr
->padding1
, '\0', sizeof(usr
->padding1
));
2786 init_unistr2(&usr
->uni_user_name
, user_name
, len_user_name
);
2787 init_unistr2(&usr
->uni_full_name
, full_name
, len_full_name
);
2788 init_unistr2(&usr
->uni_home_dir
, home_dir
, len_home_dir
);
2789 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, len_dir_drive
);
2790 init_unistr2(&usr
->uni_logon_script
, logon_script
, len_logon_script
);
2791 init_unistr2(&usr
->uni_profile_path
, profile_path
, len_profile_path
);
2792 init_unistr2(&usr
->uni_acct_desc
, description
, len_description
);
2793 init_unistr2(&usr
->uni_workstations
, workstations
, len_workstations
);
2794 init_unistr2(&usr
->uni_unknown_str
, unknown_str
, len_unknown_str
);
2795 init_unistr2(&usr
->uni_munged_dial
, munged_dial
, len_munged_dial
);
2797 usr
->unknown_6
= unknown_6
; /* 0x0000 04ec */
2801 memcpy(&(usr
->logon_hrs
), hrs
, sizeof(usr
->logon_hrs
));
2803 memset(&(usr
->logon_hrs
), 0xff, sizeof(usr
->logon_hrs
));
2807 /*******************************************************************
2808 Reads or writes a structure.
2809 ********************************************************************/
2811 static BOOL
sam_io_user_info21(char *desc
, SAM_USER_INFO_21
*usr
, prs_struct
*ps
, int depth
)
2816 prs_debug(ps
, depth
, desc
, "lsa_io_user_info");
2822 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
2824 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
2826 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
2828 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
2830 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
2832 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
2835 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
2837 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
2839 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
2841 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
2843 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
2845 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
2847 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account description */
2849 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* workstations user can log on from */
2851 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
2853 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* workstations user can log on from */
2856 if(!prs_uint8s (False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
2858 if(!prs_uint8s (False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
2861 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
2863 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
2865 if(!prs_uint16("acb_info ", ps
, depth
, &usr
->acb_info
)) /* Group ID */
2870 if(!prs_uint32("unknown_3 ", ps
, depth
, &usr
->unknown_3
))
2872 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
2876 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
2878 if(!prs_uint32("unknown_5 ", ps
, depth
, &usr
->unknown_5
))
2881 if(!prs_uint8s (False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
2884 /* here begins pointed-to data */
2886 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
2888 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
2890 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
2892 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
2894 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
2896 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
2898 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user description unicode string */
2900 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
2902 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
2904 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
)) /* worksations user can log on from */
2907 if(!prs_uint32("unknown_6 ", ps
, depth
, &usr
->unknown_6
))
2909 if(!prs_uint32("padding4 ", ps
, depth
, &usr
->padding4
))
2912 if (usr
->ptr_logon_hrs
) {
2913 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
2922 /*******************************************************************
2923 Inits a SAMR_R_QUERY_USERINFO structure.
2924 ********************************************************************/
2926 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO
*r_u
,
2927 uint16 switch_value
, void *info
, uint32 status
)
2929 DEBUG(5,("init_samr_r_query_userinfo\n"));
2932 r_u
->switch_value
= 0;
2935 r_u
->switch_value
= switch_value
;
2937 switch (switch_value
) {
2940 r_u
->info
.id10
= (SAM_USER_INFO_10
*)info
;
2945 r_u
->info
.id11
= (SAM_USER_INFO_11
*)info
;
2950 r_u
->info
.id21
= (SAM_USER_INFO_21
*)info
;
2954 DEBUG(4,("init_samr_r_query_aliasinfo: unsupported switch level\n"));
2959 r_u
->status
= status
; /* return status */
2962 /*******************************************************************
2963 Reads or writes a structure.
2964 ********************************************************************/
2966 BOOL
samr_io_r_query_userinfo(char *desc
, SAMR_R_QUERY_USERINFO
*r_u
, prs_struct
*ps
, int depth
)
2971 prs_debug(ps
, depth
, desc
, "samr_io_r_query_userinfo");
2977 if(!prs_uint32("ptr ", ps
, depth
, &r_u
->ptr
))
2979 if(!prs_uint16("switch_value", ps
, depth
, &r_u
->switch_value
))
2984 if (r_u
->ptr
!= 0 && r_u
->switch_value
!= 0) {
2985 switch (r_u
->switch_value
) {
2987 if (r_u
->info
.id10
!= NULL
) {
2988 if(!sam_io_user_info10("", r_u
->info
.id10
, ps
, depth
))
2991 DEBUG(2,("samr_io_r_query_userinfo: info pointer not initialised\n"));
2997 if (r_u->info.id11 != NULL) {
2998 if(!sam_io_user_info11("", r_u->info.id11, ps, depth))
3001 DEBUG(2,("samr_io_r_query_userinfo: info pointer not initialised\n"));
3007 if (r_u
->info
.id21
!= NULL
) {
3008 if(!sam_io_user_info21("", r_u
->info
.id21
, ps
, depth
))
3011 DEBUG(2,("samr_io_r_query_userinfo: info pointer not initialised\n"));
3016 DEBUG(2,("samr_io_r_query_userinfo: unknown switch level\n"));
3021 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3027 /*******************************************************************
3028 Reads or writes a structure.
3029 ********************************************************************/
3031 BOOL
samr_io_q_unknown_32(char *desc
, SAMR_Q_UNKNOWN_32
*q_u
, prs_struct
*ps
, int depth
)
3036 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_32");
3042 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
3047 if(!smb_io_unihdr ("", &q_u
->hdr_mach_acct
, ps
, depth
))
3049 if(!smb_io_unistr2("", &q_u
->uni_mach_acct
, q_u
->hdr_mach_acct
.buffer
, ps
, depth
))
3055 if(!prs_uint32("acct_ctrl", ps
, depth
, &q_u
->acct_ctrl
))
3057 if(!prs_uint16("unknown_1", ps
, depth
, &q_u
->unknown_1
))
3059 if(!prs_uint16("unknown_2", ps
, depth
, &q_u
->unknown_2
))
3065 /*******************************************************************
3066 Reads or writes a structure.
3067 ********************************************************************/
3069 BOOL
samr_io_r_unknown_32(char *desc
, SAMR_R_UNKNOWN_32
*r_u
, prs_struct
*ps
, int depth
)
3074 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_32");
3080 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
3085 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3091 /*******************************************************************
3092 Inits a SAMR_Q_CONNECT structure.
3093 ********************************************************************/
3095 void init_samr_q_connect(SAMR_Q_CONNECT
*q_u
,
3096 char *srv_name
, uint32 unknown_0
)
3098 int len_srv_name
= strlen(srv_name
);
3100 DEBUG(5,("init_q_connect\n"));
3102 /* make PDC server name \\server */
3103 q_u
->ptr_srv_name
= len_srv_name
> 0 ? 1 : 0;
3104 init_unistr2(&q_u
->uni_srv_name
, srv_name
, len_srv_name
+1);
3106 /* example values: 0x0000 0002 */
3107 q_u
->unknown_0
= unknown_0
;
3110 /*******************************************************************
3111 Reads or writes a structure.
3112 ********************************************************************/
3114 BOOL
samr_io_q_connect(char *desc
, SAMR_Q_CONNECT
*q_u
, prs_struct
*ps
, int depth
)
3119 prs_debug(ps
, depth
, desc
, "samr_io_q_connect");
3125 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
3127 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
3133 if(!prs_uint32("unknown_0 ", ps
, depth
, &q_u
->unknown_0
))
3139 /*******************************************************************
3140 Reads or writes a structure.
3141 ********************************************************************/
3143 BOOL
samr_io_r_connect(char *desc
, SAMR_R_CONNECT
*r_u
, prs_struct
*ps
, int depth
)
3148 prs_debug(ps
, depth
, desc
, "samr_io_r_connect");
3154 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
3159 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3165 /*******************************************************************
3166 Inits a SAMR_Q_CONNECT_ANON structure.
3167 ********************************************************************/
3169 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON
*q_u
)
3171 DEBUG(5,("init_q_connect_anon\n"));
3174 q_u
->unknown_0
= 0x5c; /* server name (?!!) */
3175 q_u
->unknown_1
= 0x01;
3176 q_u
->unknown_2
= 0x20;
3180 /*******************************************************************
3181 Reads or writes a structure.
3182 ********************************************************************/
3184 BOOL
samr_io_q_connect_anon(char *desc
, SAMR_Q_CONNECT_ANON
*q_u
, prs_struct
*ps
, int depth
)
3189 prs_debug(ps
, depth
, desc
, "samr_io_q_connect_anon");
3195 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
3197 if(!prs_uint16("unknown_0", ps
, depth
, &q_u
->unknown_0
))
3199 if(!prs_uint16("unknown_1", ps
, depth
, &q_u
->unknown_1
))
3201 if(!prs_uint32("unknown_2", ps
, depth
, &q_u
->unknown_2
))
3207 /*******************************************************************
3208 Reads or writes a structure.
3209 ********************************************************************/
3211 BOOL
samr_io_r_connect_anon(char *desc
, SAMR_R_CONNECT_ANON
*r_u
, prs_struct
*ps
, int depth
)
3216 prs_debug(ps
, depth
, desc
, "samr_io_r_connect_anon");
3222 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
3227 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3233 /*******************************************************************
3234 Inits a SAMR_Q_OPEN_ALIAS structure.
3235 ********************************************************************/
3236 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS
*q_u
,
3237 uint32 unknown_0
, uint32 rid
)
3239 DEBUG(5,("init_q_open_alias\n"));
3241 /* example values: 0x0000 0008 */
3242 q_u
->unknown_0
= unknown_0
;
3244 q_u
->rid_alias
= rid
;
3247 /*******************************************************************
3248 Reads or writes a structure.
3249 ********************************************************************/
3251 BOOL
samr_io_q_open_alias(char *desc
, SAMR_Q_OPEN_ALIAS
*q_u
, prs_struct
*ps
, int depth
)
3256 prs_debug(ps
, depth
, desc
, "samr_io_q_open_alias");
3262 if(!prs_uint32("unknown_0", ps
, depth
, &q_u
->unknown_0
))
3264 if(!prs_uint32("rid_alias", ps
, depth
, &q_u
->rid_alias
))
3270 /*******************************************************************
3271 Reads or writes a structure.
3272 ********************************************************************/
3274 BOOL
samr_io_r_open_alias(char *desc
, SAMR_R_OPEN_ALIAS
*r_u
, prs_struct
*ps
, int depth
)
3279 prs_debug(ps
, depth
, desc
, "samr_io_r_open_alias");
3285 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
3290 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3296 /*******************************************************************
3297 Inits a SAMR_Q_UNKNOWN_12 structure.
3298 ********************************************************************/
3300 void init_samr_q_unknown_12(SAMR_Q_UNKNOWN_12
*q_u
,
3301 POLICY_HND
*pol
, uint32 rid
,
3302 uint32 num_gids
, uint32
*gid
)
3306 DEBUG(5,("init_samr_r_unknwon_12\n"));
3308 memcpy(&q_u
->pol
, pol
, sizeof(*pol
));
3310 q_u
->num_gids1
= num_gids
;
3313 q_u
->num_gids2
= num_gids
;
3315 for (i
= 0; i
< num_gids
; i
++) {
3316 q_u
->gid
[i
] = gid
[i
];
3320 /*******************************************************************
3321 Inits a SAMR_Q_UNKNOWN_21 structure.
3322 ********************************************************************/
3324 void init_samr_q_unknown_21(SAMR_Q_UNKNOWN_21
*q_c
,
3325 POLICY_HND
*hnd
, uint16 unk_1
, uint16 unk_2
)
3327 DEBUG(5,("init_samr_q_unknown_21\n"));
3329 memcpy(&q_c
->group_pol
, hnd
, sizeof(q_c
->group_pol
));
3330 q_c
->unknown_1
= unk_1
;
3331 q_c
->unknown_2
= unk_2
;
3335 /*******************************************************************
3336 Inits a SAMR_Q_UNKNOWN_13 structure.
3337 ********************************************************************/
3339 void init_samr_q_unknown_13(SAMR_Q_UNKNOWN_13
*q_c
,
3340 POLICY_HND
*hnd
, uint16 unk_1
, uint16 unk_2
)
3342 DEBUG(5,("init_samr_q_unknown_13\n"));
3344 memcpy(&q_c
->alias_pol
, hnd
, sizeof(q_c
->alias_pol
));
3345 q_c
->unknown_1
= unk_1
;
3346 q_c
->unknown_2
= unk_2
;
3349 /*******************************************************************
3350 Inits a SAMR_Q_UNKNOWN_38 structure.
3351 ********************************************************************/
3352 void init_samr_q_unknown_38(SAMR_Q_UNKNOWN_38
*q_u
, char *srv_name
)
3354 int len_srv_name
= strlen(srv_name
);
3356 DEBUG(5,("init_q_unknown_38\n"));
3359 init_uni_hdr(&q_u
->hdr_srv_name
, len_srv_name
);
3360 init_unistr2(&q_u
->uni_srv_name
, srv_name
, len_srv_name
);
3364 /*******************************************************************
3365 Reads or writes a structure.
3366 ********************************************************************/
3368 BOOL
samr_io_q_unknown_38(char *desc
, SAMR_Q_UNKNOWN_38
*q_u
, prs_struct
*ps
, int depth
)
3373 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_38");
3379 if(!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
3382 if (q_u
->ptr
!= 0) {
3383 if(!smb_io_unihdr ("", &q_u
->hdr_srv_name
, ps
, depth
))
3385 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->hdr_srv_name
.buffer
, ps
, depth
))
3392 /*******************************************************************
3393 Inits a SAMR_R_UNKNOWN_38 structure.
3394 ********************************************************************/
3396 void init_samr_r_unknown_38(SAMR_R_UNKNOWN_38
*r_u
)
3398 DEBUG(5,("init_r_unknown_38\n"));
3406 /*******************************************************************
3407 Reads or writes a structure.
3408 ********************************************************************/
3410 BOOL
samr_io_r_unknown_38(char *desc
, SAMR_R_UNKNOWN_38
*r_u
, prs_struct
*ps
, int depth
)
3415 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_38");
3421 if(!prs_uint16("unk_0", ps
, depth
, &r_u
->unk_0
))
3425 if(!prs_uint16("unk_1", ps
, depth
, &r_u
->unk_1
))
3429 if(!prs_uint16("unk_2", ps
, depth
, &r_u
->unk_2
))
3433 if(!prs_uint16("unk_3", ps
, depth
, &r_u
->unk_3
))
3441 /*******************************************************************
3442 make a SAMR_ENC_PASSWD structure.
3443 ********************************************************************/
3445 void init_enc_passwd(SAMR_ENC_PASSWD
*pwd
, char pass
[512])
3448 memcpy(pwd
->pass
, pass
, sizeof(pwd
->pass
));
3451 /*******************************************************************
3452 Reads or writes a SAMR_ENC_PASSWD structure.
3453 ********************************************************************/
3455 BOOL
samr_io_enc_passwd(char *desc
, SAMR_ENC_PASSWD
*pwd
, prs_struct
*ps
, int depth
)
3460 prs_debug(ps
, depth
, desc
, "samr_io_enc_passwd");
3466 if(!prs_uint32("ptr", ps
, depth
, &pwd
->ptr
))
3468 if(!prs_uint8s(False
, "pwd", ps
, depth
, pwd
->pass
, sizeof(pwd
->pass
)))
3474 /*******************************************************************
3475 Inits a SAMR_ENC_HASH structure.
3476 ********************************************************************/
3478 void init_enc_hash(SAMR_ENC_HASH
*hsh
, uchar hash
[16])
3481 memcpy(hsh
->hash
, hash
, sizeof(hsh
->hash
));
3484 /*******************************************************************
3485 Reads or writes a SAMR_ENC_HASH structure.
3486 ********************************************************************/
3488 BOOL
samr_io_enc_hash(char *desc
, SAMR_ENC_HASH
*hsh
, prs_struct
*ps
, int depth
)
3493 prs_debug(ps
, depth
, desc
, "samr_io_enc_hash");
3499 if(!prs_uint32("ptr ", ps
, depth
, &hsh
->ptr
))
3501 if(!prs_uint8s(False
, "hash", ps
, depth
, hsh
->hash
, sizeof(hsh
->hash
)))
3507 /*******************************************************************
3508 Inits a SAMR_R_UNKNOWN_38 structure.
3509 ********************************************************************/
3511 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER
*q_u
,
3512 char *dest_host
, char *user_name
,
3513 char nt_newpass
[516], uchar nt_oldhash
[16],
3514 char lm_newpass
[516], uchar lm_oldhash
[16])
3516 int len_dest_host
= strlen(dest_host
);
3517 int len_user_name
= strlen(user_name
);
3519 DEBUG(5,("init_samr_q_chgpasswd_user\n"));
3522 init_uni_hdr(&q_u
->hdr_dest_host
, len_dest_host
);
3523 init_unistr2(&q_u
->uni_dest_host
, dest_host
, len_dest_host
);
3524 init_uni_hdr(&q_u
->hdr_user_name
, len_user_name
);
3525 init_unistr2(&q_u
->uni_user_name
, user_name
, len_user_name
);
3527 init_enc_passwd(&q_u
->nt_newpass
, nt_newpass
);
3528 init_enc_hash(&q_u
->nt_oldhash
, nt_oldhash
);
3530 q_u
->unknown
= 0x01;
3532 init_enc_passwd(&q_u
->lm_newpass
, lm_newpass
);
3533 init_enc_hash (&q_u
->lm_oldhash
, lm_oldhash
);
3536 /*******************************************************************
3537 Reads or writes a structure.
3538 ********************************************************************/
3540 BOOL
samr_io_q_chgpasswd_user(char *desc
, SAMR_Q_CHGPASSWD_USER
*q_u
, prs_struct
*ps
, int depth
)
3545 prs_debug(ps
, depth
, desc
, "samr_io_q_chgpasswd_user");
3551 if(!prs_uint32("ptr_0", ps
, depth
, &q_u
->ptr_0
))
3554 if(!smb_io_unihdr ("", &q_u
->hdr_dest_host
, ps
, depth
))
3556 if(!smb_io_unistr2("", &q_u
->uni_dest_host
, q_u
->hdr_dest_host
.buffer
, ps
, depth
))
3558 if(!smb_io_unihdr ("", &q_u
->hdr_user_name
, ps
, depth
))
3560 if(!smb_io_unistr2("", &q_u
->uni_user_name
, q_u
->hdr_user_name
.buffer
, ps
, depth
))
3563 if(!samr_io_enc_passwd("nt_newpass", &q_u
->nt_newpass
, ps
, depth
))
3565 if(!samr_io_enc_hash ("nt_oldhash", &q_u
->nt_oldhash
, ps
, depth
))
3568 if(!prs_uint32("unknown", ps
, depth
, &q_u
->unknown
))
3571 if(!samr_io_enc_passwd("lm_newpass", &q_u
->lm_newpass
, ps
, depth
))
3573 if(!samr_io_enc_hash("lm_oldhash", &q_u
->lm_oldhash
, ps
, depth
))
3579 /*******************************************************************
3580 Inits a SAMR_R_CHGPASSWD_USER structure.
3581 ********************************************************************/
3583 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER
*r_u
, uint32 status
)
3585 DEBUG(5,("init_r_chgpasswd_user\n"));
3587 r_u
->status
= status
;
3590 /*******************************************************************
3591 Reads or writes a structure.
3592 ********************************************************************/
3594 BOOL
samr_io_r_chgpasswd_user(char *desc
, SAMR_R_CHGPASSWD_USER
*r_u
, prs_struct
*ps
, int depth
)
3599 prs_debug(ps
, depth
, desc
, "samr_io_r_chgpasswd_user");
3605 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))