2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Paul Ashton 1997-2000,
7 * Copyright (C) Elrond 2000,
8 * Copyright (C) Jeremy Allison 2001,
9 * Copyright (C) Jean François Micouleau 1998-2001,
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #define DBGC_CLASS DBGC_RPC_PARSE
32 /*******************************************************************
33 inits a SAMR_Q_CLOSE_HND structure.
34 ********************************************************************/
36 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND
* q_c
, POLICY_HND
*hnd
)
38 DEBUG(5, ("init_samr_q_close_hnd\n"));
43 /*******************************************************************
44 reads or writes a structure.
45 ********************************************************************/
47 BOOL
samr_io_q_close_hnd(const char *desc
, SAMR_Q_CLOSE_HND
* q_u
,
48 prs_struct
*ps
, int depth
)
53 prs_debug(ps
, depth
, desc
, "samr_io_q_close_hnd");
59 return smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
);
62 /*******************************************************************
63 reads or writes a structure.
64 ********************************************************************/
66 BOOL
samr_io_r_close_hnd(const char *desc
, SAMR_R_CLOSE_HND
* r_u
,
67 prs_struct
*ps
, int depth
)
72 prs_debug(ps
, depth
, desc
, "samr_io_r_close_hnd");
78 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
81 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
87 /*******************************************************************
88 inits a SAMR_Q_LOOKUP_DOMAIN structure.
89 ********************************************************************/
91 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN
* q_u
,
92 POLICY_HND
*pol
, char *dom_name
)
94 DEBUG(5, ("init_samr_q_lookup_domain\n"));
96 q_u
->connect_pol
= *pol
;
98 init_unistr2(&q_u
->uni_domain
, dom_name
, UNI_FLAGS_NONE
);
99 init_uni_hdr(&q_u
->hdr_domain
, &q_u
->uni_domain
);
102 /*******************************************************************
103 reads or writes a structure.
104 ********************************************************************/
105 BOOL
samr_io_q_lookup_domain(const char *desc
, SAMR_Q_LOOKUP_DOMAIN
* q_u
,
106 prs_struct
*ps
, int depth
)
111 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_domain");
117 if(!smb_io_pol_hnd("connect_pol", &q_u
->connect_pol
, ps
, depth
))
120 if(!smb_io_unihdr("hdr_domain", &q_u
->hdr_domain
, ps
, depth
))
123 if(!smb_io_unistr2("uni_domain", &q_u
->uni_domain
, q_u
->hdr_domain
.buffer
, ps
, depth
))
129 /*******************************************************************
130 inits a SAMR_R_LOOKUP_DOMAIN structure.
131 ********************************************************************/
133 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN
* r_u
,
134 DOM_SID
*dom_sid
, NTSTATUS status
)
136 DEBUG(5, ("init_samr_r_lookup_domain\n"));
138 r_u
->status
= status
;
140 if (NT_STATUS_IS_OK(status
)) {
142 init_dom_sid2(&r_u
->dom_sid
, dom_sid
);
146 /*******************************************************************
147 reads or writes a structure.
148 ********************************************************************/
150 BOOL
samr_io_r_lookup_domain(const char *desc
, SAMR_R_LOOKUP_DOMAIN
* r_u
,
151 prs_struct
*ps
, int depth
)
156 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_domain");
162 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr_sid
))
165 if (r_u
->ptr_sid
!= 0) {
166 if(!smb_io_dom_sid2("sid", &r_u
->dom_sid
, ps
, depth
))
172 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
178 /*******************************************************************
179 reads or writes a structure.
180 ********************************************************************/
182 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN
* q_u
, POLICY_HND
*dom_pol
, DOM_SID
*sid
)
184 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
186 q_u
->dom_pol
= *dom_pol
;
187 init_dom_sid2(&q_u
->sid
, sid
);
190 /*******************************************************************
191 reads or writes a structure.
192 ********************************************************************/
194 BOOL
samr_io_q_remove_sid_foreign_domain(const char *desc
, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN
* q_u
,
195 prs_struct
*ps
, int depth
)
200 prs_debug(ps
, depth
, desc
, "samr_io_q_remove_sid_foreign_domain");
206 if(!smb_io_pol_hnd("domain_pol", &q_u
->dom_pol
, ps
, depth
))
209 if(!smb_io_dom_sid2("sid", &q_u
->sid
, ps
, depth
))
218 /*******************************************************************
219 reads or writes a structure.
220 ********************************************************************/
222 BOOL
samr_io_r_remove_sid_foreign_domain(const char *desc
, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN
* r_u
,
223 prs_struct
*ps
, int depth
)
228 prs_debug(ps
, depth
, desc
, "samr_io_r_remove_sid_foreign_domain");
234 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
240 /*******************************************************************
241 reads or writes a structure.
242 ********************************************************************/
244 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN
* q_u
,
245 POLICY_HND
*pol
, uint32 flags
,
248 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
252 init_dom_sid2(&q_u
->dom_sid
, sid
);
255 /*******************************************************************
256 reads or writes a structure.
257 ********************************************************************/
259 BOOL
samr_io_q_open_domain(const char *desc
, SAMR_Q_OPEN_DOMAIN
* q_u
,
260 prs_struct
*ps
, int depth
)
265 prs_debug(ps
, depth
, desc
, "samr_io_q_open_domain");
271 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
274 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
277 if(!smb_io_dom_sid2("sid", &q_u
->dom_sid
, ps
, depth
))
283 /*******************************************************************
284 reads or writes a structure.
285 ********************************************************************/
287 BOOL
samr_io_r_open_domain(const char *desc
, SAMR_R_OPEN_DOMAIN
* r_u
,
288 prs_struct
*ps
, int depth
)
293 prs_debug(ps
, depth
, desc
, "samr_io_r_open_domain");
299 if(!smb_io_pol_hnd("domain_pol", &r_u
->domain_pol
, ps
, depth
))
302 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
308 /*******************************************************************
309 reads or writes a structure.
310 ********************************************************************/
312 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO
* q_u
,
313 POLICY_HND
*user_pol
)
315 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
317 q_u
->user_pol
= *user_pol
;
320 /*******************************************************************
321 reads or writes a structure.
322 ********************************************************************/
324 BOOL
samr_io_q_get_usrdom_pwinfo(const char *desc
, SAMR_Q_GET_USRDOM_PWINFO
* q_u
,
325 prs_struct
*ps
, int depth
)
330 prs_debug(ps
, depth
, desc
, "samr_io_q_get_usrdom_pwinfo");
336 return smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
);
339 /*******************************************************************
341 ********************************************************************/
343 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO
*r_u
, NTSTATUS status
)
345 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
347 r_u
->min_pwd_length
= 0x0000;
351 * r_u->unknown_1 = 0x0015;
354 r_u
->unknown_1
= 0x01D1;
355 r_u
->unknown_1
= 0x0015;
357 r_u
->password_properties
= 0x00000000;
359 r_u
->status
= status
;
362 /*******************************************************************
363 reads or writes a structure.
364 ********************************************************************/
366 BOOL
samr_io_r_get_usrdom_pwinfo(const char *desc
, SAMR_R_GET_USRDOM_PWINFO
* r_u
,
367 prs_struct
*ps
, int depth
)
372 prs_debug(ps
, depth
, desc
, "samr_io_r_get_usrdom_pwinfo");
378 if(!prs_uint16("min_pwd_length", ps
, depth
, &r_u
->min_pwd_length
))
380 if(!prs_uint16("unknown_1", ps
, depth
, &r_u
->unknown_1
))
382 if(!prs_uint32("password_properties", ps
, depth
, &r_u
->password_properties
))
385 if(!prs_ntstatus("status ", ps
, depth
, &r_u
->status
))
392 /*******************************************************************
393 reads or writes a structure.
394 ********************************************************************/
396 BOOL
samr_io_q_set_sec_obj(const char *desc
, SAMR_Q_SET_SEC_OBJ
* q_u
,
397 prs_struct
*ps
, int depth
)
402 prs_debug(ps
, depth
, desc
, "samr_io_q_set_sec_obj");
408 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
411 if(!prs_uint32("sec_info", ps
, depth
, &q_u
->sec_info
))
414 if(!sec_io_desc_buf("sec_desc", &q_u
->buf
, ps
, depth
))
421 /*******************************************************************
422 reads or writes a structure.
423 ********************************************************************/
425 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ
* q_u
,
426 POLICY_HND
*user_pol
, uint32 sec_info
)
428 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
430 q_u
->user_pol
= *user_pol
;
431 q_u
->sec_info
= sec_info
;
435 /*******************************************************************
436 reads or writes a structure.
437 ********************************************************************/
439 BOOL
samr_io_q_query_sec_obj(const char *desc
, SAMR_Q_QUERY_SEC_OBJ
* q_u
,
440 prs_struct
*ps
, int depth
)
445 prs_debug(ps
, depth
, desc
, "samr_io_q_query_sec_obj");
451 if(!smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
))
454 if(!prs_uint32("sec_info", ps
, depth
, &q_u
->sec_info
))
460 /*******************************************************************
461 reads or writes a structure.
462 ********************************************************************/
464 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO
* q_u
,
465 POLICY_HND
*domain_pol
, uint16 switch_value
)
467 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
469 q_u
->domain_pol
= *domain_pol
;
470 q_u
->switch_value
= switch_value
;
473 /*******************************************************************
474 reads or writes a structure.
475 ********************************************************************/
477 BOOL
samr_io_q_query_dom_info(const char *desc
, SAMR_Q_QUERY_DOMAIN_INFO
* q_u
,
478 prs_struct
*ps
, int depth
)
483 prs_debug(ps
, depth
, desc
, "samr_io_q_query_dom_info");
489 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
492 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
499 /*******************************************************************
501 ********************************************************************/
503 void init_unk_info3(SAM_UNK_INFO_3
*u_3
, NTTIME nt_logout
)
505 u_3
->logout
.low
= nt_logout
.low
;
506 u_3
->logout
.high
= nt_logout
.high
;
509 /*******************************************************************
510 reads or writes a structure.
511 ********************************************************************/
513 static BOOL
sam_io_unk_info3(const char *desc
, SAM_UNK_INFO_3
* u_3
,
514 prs_struct
*ps
, int depth
)
519 prs_debug(ps
, depth
, desc
, "sam_io_unk_info3");
522 if(!smb_io_time("logout", &u_3
->logout
, ps
, depth
))
528 /*******************************************************************
530 ********************************************************************/
532 void init_unk_info6(SAM_UNK_INFO_6
* u_6
)
534 u_6
->unknown_0
= 0x00000000;
536 memset(u_6
->padding
, 0, sizeof(u_6
->padding
)); /* 12 bytes zeros */
539 /*******************************************************************
540 reads or writes a structure.
541 ********************************************************************/
543 static BOOL
sam_io_unk_info6(const char *desc
, SAM_UNK_INFO_6
* u_6
,
544 prs_struct
*ps
, int depth
)
549 prs_debug(ps
, depth
, desc
, "sam_io_unk_info6");
552 if(!prs_uint32("unknown_0", ps
, depth
, &u_6
->unknown_0
)) /* 0x0000 0000 */
554 if(!prs_uint32("ptr_0", ps
, depth
, &u_6
->ptr_0
)) /* pointer to unknown structure */
556 if(!prs_uint8s(False
, "padding", ps
, depth
, u_6
->padding
, sizeof(u_6
->padding
))) /* 12 bytes zeros */
562 /*******************************************************************
564 ********************************************************************/
566 void init_unk_info7(SAM_UNK_INFO_7
* u_7
, uint32 server_role
)
568 u_7
->server_role
= server_role
;
571 /*******************************************************************
572 reads or writes a structure.
573 ********************************************************************/
575 static BOOL
sam_io_unk_info7(const char *desc
, SAM_UNK_INFO_7
* u_7
,
576 prs_struct
*ps
, int depth
)
581 prs_debug(ps
, depth
, desc
, "sam_io_unk_info7");
584 if(!prs_uint16("server_role", ps
, depth
, &u_7
->server_role
))
590 /*******************************************************************
592 ********************************************************************/
594 void init_unk_info8(SAM_UNK_INFO_8
* u_8
, uint32 seq_num
)
596 unix_to_nt_time(&u_8
->domain_create_time
, 0);
597 u_8
->seq_num
.low
= seq_num
;
598 u_8
->seq_num
.high
= 0x0000;
601 /*******************************************************************
602 reads or writes a structure.
603 ********************************************************************/
605 static BOOL
sam_io_unk_info8(const char *desc
, SAM_UNK_INFO_8
* u_8
,
606 prs_struct
*ps
, int depth
)
611 prs_debug(ps
, depth
, desc
, "sam_io_unk_info8");
614 if (!prs_uint64("seq_num", ps
, depth
, &u_8
->seq_num
))
617 if(!smb_io_time("domain_create_time", &u_8
->domain_create_time
, ps
, depth
))
624 /*******************************************************************
626 ********************************************************************/
628 void init_unk_info12(SAM_UNK_INFO_12
* u_12
, NTTIME nt_lock_duration
, NTTIME nt_reset_time
, uint16 lockout
)
630 u_12
->duration
.low
= nt_lock_duration
.low
;
631 u_12
->duration
.high
= nt_lock_duration
.high
;
632 u_12
->reset_count
.low
= nt_reset_time
.low
;
633 u_12
->reset_count
.high
= nt_reset_time
.high
;
635 u_12
->bad_attempt_lockout
= lockout
;
638 /*******************************************************************
639 reads or writes a structure.
640 ********************************************************************/
642 static BOOL
sam_io_unk_info12(const char *desc
, SAM_UNK_INFO_12
* u_12
,
643 prs_struct
*ps
, int depth
)
648 prs_debug(ps
, depth
, desc
, "sam_io_unk_info12");
651 if(!smb_io_time("duration", &u_12
->duration
, ps
, depth
))
653 if(!smb_io_time("reset_count", &u_12
->reset_count
, ps
, depth
))
655 if(!prs_uint16("bad_attempt_lockout", ps
, depth
, &u_12
->bad_attempt_lockout
))
661 /*******************************************************************
663 ********************************************************************/
665 void init_unk_info5(SAM_UNK_INFO_5
* u_5
,const char *domain
)
667 init_unistr2(&u_5
->uni_domain
, domain
, UNI_FLAGS_NONE
);
668 init_uni_hdr(&u_5
->hdr_domain
, &u_5
->uni_domain
);
671 /*******************************************************************
672 reads or writes a structure.
673 ********************************************************************/
675 static BOOL
sam_io_unk_info5(const char *desc
, SAM_UNK_INFO_5
* u_5
,
676 prs_struct
*ps
, int depth
)
681 prs_debug(ps
, depth
, desc
, "sam_io_unk_info5");
684 if(!smb_io_unihdr("hdr_domain", &u_5
->hdr_domain
, ps
, depth
))
687 if(!smb_io_unistr2("uni_domain", &u_5
->uni_domain
, u_5
->hdr_domain
.buffer
, ps
, depth
))
693 /*******************************************************************
695 ********************************************************************/
697 void init_unk_info2(SAM_UNK_INFO_2
* u_2
,
698 const char *comment
, const char *domain
, const char *server
,
699 uint32 seq_num
, uint32 num_users
, uint32 num_groups
, uint32 num_alias
, NTTIME nt_logout
, uint32 server_role
)
701 u_2
->logout
.low
= nt_logout
.low
;
702 u_2
->logout
.high
= nt_logout
.high
;
704 u_2
->seq_num
.low
= seq_num
;
705 u_2
->seq_num
.high
= 0x00000000;
708 u_2
->unknown_4
= 0x00000001;
709 u_2
->server_role
= server_role
;
710 u_2
->unknown_6
= 0x00000001;
711 u_2
->num_domain_usrs
= num_users
;
712 u_2
->num_domain_grps
= num_groups
;
713 u_2
->num_local_grps
= num_alias
;
715 memset(u_2
->padding
, 0, sizeof(u_2
->padding
)); /* 12 bytes zeros */
717 init_unistr2(&u_2
->uni_comment
, comment
, UNI_FLAGS_NONE
);
718 init_uni_hdr(&u_2
->hdr_comment
, &u_2
->uni_comment
);
719 init_unistr2(&u_2
->uni_domain
, domain
, UNI_FLAGS_NONE
);
720 init_uni_hdr(&u_2
->hdr_domain
, &u_2
->uni_domain
);
721 init_unistr2(&u_2
->uni_server
, server
, UNI_FLAGS_NONE
);
722 init_uni_hdr(&u_2
->hdr_server
, &u_2
->uni_server
);
725 /*******************************************************************
726 reads or writes a structure.
727 ********************************************************************/
729 static BOOL
sam_io_unk_info2(const char *desc
, SAM_UNK_INFO_2
* u_2
,
730 prs_struct
*ps
, int depth
)
735 prs_debug(ps
, depth
, desc
, "sam_io_unk_info2");
738 if(!smb_io_time("logout", &u_2
->logout
, ps
, depth
))
740 if(!smb_io_unihdr("hdr_comment", &u_2
->hdr_comment
, ps
, depth
))
742 if(!smb_io_unihdr("hdr_domain", &u_2
->hdr_domain
, ps
, depth
))
744 if(!smb_io_unihdr("hdr_server", &u_2
->hdr_server
, ps
, depth
))
747 /* put all the data in here, at the moment, including what the above
748 pointer is referring to
751 if(!prs_uint64("seq_num ", ps
, depth
, &u_2
->seq_num
))
754 if(!prs_uint32("unknown_4 ", ps
, depth
, &u_2
->unknown_4
)) /* 0x0000 0001 */
756 if(!prs_uint32("server_role ", ps
, depth
, &u_2
->server_role
))
758 if(!prs_uint32("unknown_6 ", ps
, depth
, &u_2
->unknown_6
)) /* 0x0000 0001 */
760 if(!prs_uint32("num_domain_usrs ", ps
, depth
, &u_2
->num_domain_usrs
))
762 if(!prs_uint32("num_domain_grps", ps
, depth
, &u_2
->num_domain_grps
))
764 if(!prs_uint32("num_local_grps", ps
, depth
, &u_2
->num_local_grps
))
767 if(!smb_io_unistr2("uni_comment", &u_2
->uni_comment
, u_2
->hdr_comment
.buffer
, ps
, depth
))
769 if(!smb_io_unistr2("uni_domain", &u_2
->uni_domain
, u_2
->hdr_domain
.buffer
, ps
, depth
))
771 if(!smb_io_unistr2("uni_server", &u_2
->uni_server
, u_2
->hdr_server
.buffer
, ps
, depth
))
777 /*******************************************************************
779 ********************************************************************/
781 void init_unk_info1(SAM_UNK_INFO_1
*u_1
, uint16 min_pass_len
, uint16 pass_hist
,
782 uint32 password_properties
, NTTIME nt_expire
, NTTIME nt_min_age
)
784 u_1
->min_length_password
= min_pass_len
;
785 u_1
->password_history
= pass_hist
;
786 u_1
->password_properties
= password_properties
;
788 /* password never expire */
789 u_1
->expire
.high
= nt_expire
.high
;
790 u_1
->expire
.low
= nt_expire
.low
;
792 /* can change the password now */
793 u_1
->min_passwordage
.high
= nt_min_age
.high
;
794 u_1
->min_passwordage
.low
= nt_min_age
.low
;
798 /*******************************************************************
799 reads or writes a structure.
800 ********************************************************************/
802 static BOOL
sam_io_unk_info1(const char *desc
, SAM_UNK_INFO_1
* u_1
,
803 prs_struct
*ps
, int depth
)
808 prs_debug(ps
, depth
, desc
, "sam_io_unk_info1");
811 if(!prs_uint16("min_length_password", ps
, depth
, &u_1
->min_length_password
))
813 if(!prs_uint16("password_history", ps
, depth
, &u_1
->password_history
))
815 if(!prs_uint32("password_properties", ps
, depth
, &u_1
->password_properties
))
817 if(!smb_io_time("expire", &u_1
->expire
, ps
, depth
))
819 if(!smb_io_time("min_passwordage", &u_1
->min_passwordage
, ps
, depth
))
825 /*******************************************************************
826 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
827 ********************************************************************/
829 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO
* r_u
,
830 uint16 switch_value
, SAM_UNK_CTR
* ctr
,
833 DEBUG(5, ("init_samr_r_query_dom_info\n"));
836 r_u
->switch_value
= 0;
837 r_u
->status
= status
; /* return status */
839 if (NT_STATUS_IS_OK(status
)) {
840 r_u
->switch_value
= switch_value
;
846 /*******************************************************************
847 reads or writes a structure.
848 ********************************************************************/
850 BOOL
samr_io_r_query_dom_info(const char *desc
, SAMR_R_QUERY_DOMAIN_INFO
* r_u
,
851 prs_struct
*ps
, int depth
)
856 prs_debug(ps
, depth
, desc
, "samr_io_r_query_dom_info");
862 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
865 if (r_u
->ptr_0
!= 0 && r_u
->ctr
!= NULL
) {
866 if(!prs_uint16("switch_value", ps
, depth
, &r_u
->switch_value
))
871 switch (r_u
->switch_value
) {
873 if(!sam_io_unk_info12("unk_inf12", &r_u
->ctr
->info
.inf12
, ps
, depth
))
877 if(!sam_io_unk_info8("unk_inf8",&r_u
->ctr
->info
.inf8
, ps
,depth
))
881 if(!sam_io_unk_info7("unk_inf7",&r_u
->ctr
->info
.inf7
, ps
,depth
))
885 if(!sam_io_unk_info6("unk_inf6",&r_u
->ctr
->info
.inf6
, ps
,depth
))
889 if(!sam_io_unk_info5("unk_inf5",&r_u
->ctr
->info
.inf5
, ps
,depth
))
893 if(!sam_io_unk_info3("unk_inf3",&r_u
->ctr
->info
.inf3
, ps
,depth
))
897 if(!sam_io_unk_info2("unk_inf2",&r_u
->ctr
->info
.inf2
, ps
,depth
))
901 if(!sam_io_unk_info1("unk_inf1",&r_u
->ctr
->info
.inf1
, ps
,depth
))
905 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
907 r_u
->status
= NT_STATUS_INVALID_INFO_CLASS
;
915 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
921 /*******************************************************************
922 reads or writes a structure.
923 ********************************************************************/
925 void init_samr_q_set_sec_obj(SAMR_Q_SET_SEC_OBJ
* q_u
,
926 POLICY_HND
*pol
, uint32 sec_info
, SEC_DESC_BUF
*buf
)
928 DEBUG(5, ("samr_init_samr_q_set_sec_obj\n"));
931 q_u
->sec_info
= sec_info
;
936 /*******************************************************************
937 reads or writes a SAMR_R_SET_SEC_OBJ structure.
938 ********************************************************************/
940 BOOL
samr_io_r_set_sec_obj(const char *desc
, SAMR_R_SET_SEC_OBJ
* r_u
,
941 prs_struct
*ps
, int depth
)
946 prs_debug(ps
, depth
, desc
, "samr_io_r_set_sec_obj");
952 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
958 /*******************************************************************
959 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
960 ********************************************************************/
962 BOOL
samr_io_r_query_sec_obj(const char *desc
, SAMR_R_QUERY_SEC_OBJ
* r_u
,
963 prs_struct
*ps
, int depth
)
968 prs_debug(ps
, depth
, desc
, "samr_io_r_query_sec_obj");
974 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
977 if(!sec_io_desc_buf("sec", &r_u
->buf
, ps
, depth
))
981 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
987 /*******************************************************************
988 reads or writes a SAM_STR1 structure.
989 ********************************************************************/
991 static BOOL
sam_io_sam_str1(const char *desc
, SAM_STR1
* sam
, uint32 acct_buf
,
992 uint32 name_buf
, uint32 desc_buf
,
993 prs_struct
*ps
, int depth
)
998 prs_debug(ps
, depth
, desc
, "sam_io_sam_str1");
1003 if (!smb_io_unistr2("name", &sam
->uni_acct_name
, acct_buf
, ps
, depth
))
1006 if (!smb_io_unistr2("desc", &sam
->uni_acct_desc
, desc_buf
, ps
, depth
))
1009 if (!smb_io_unistr2("full", &sam
->uni_full_name
, name_buf
, ps
, depth
))
1015 /*******************************************************************
1016 inits a SAM_ENTRY1 structure.
1017 ********************************************************************/
1019 static void init_sam_entry1(SAM_ENTRY1
*sam
, uint32 user_idx
,
1020 UNISTR2
*sam_name
, UNISTR2
*sam_full
,
1021 UNISTR2
*sam_desc
, uint32 rid_user
,
1024 DEBUG(5, ("init_sam_entry1\n"));
1028 sam
->user_idx
= user_idx
;
1029 sam
->rid_user
= rid_user
;
1030 sam
->acb_info
= acb_info
;
1032 init_uni_hdr(&sam
->hdr_acct_name
, sam_name
);
1033 init_uni_hdr(&sam
->hdr_user_name
, sam_full
);
1034 init_uni_hdr(&sam
->hdr_user_desc
, sam_desc
);
1037 /*******************************************************************
1038 reads or writes a SAM_ENTRY1 structure.
1039 ********************************************************************/
1041 static BOOL
sam_io_sam_entry1(const char *desc
, SAM_ENTRY1
* sam
,
1042 prs_struct
*ps
, int depth
)
1047 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry1");
1053 if(!prs_uint32("user_idx ", ps
, depth
, &sam
->user_idx
))
1056 if(!prs_uint32("rid_user ", ps
, depth
, &sam
->rid_user
))
1058 if(!prs_uint32("acb_info ", ps
, depth
, &sam
->acb_info
))
1061 if (!smb_io_unihdr("hdr_acct_name", &sam
->hdr_acct_name
, ps
, depth
))
1063 if (!smb_io_unihdr("hdr_user_desc", &sam
->hdr_user_desc
, ps
, depth
))
1065 if (!smb_io_unihdr("hdr_user_name", &sam
->hdr_user_name
, ps
, depth
))
1071 /*******************************************************************
1072 reads or writes a SAM_STR2 structure.
1073 ********************************************************************/
1075 static BOOL
sam_io_sam_str2(const char *desc
, SAM_STR2
* sam
, uint32 acct_buf
,
1076 uint32 desc_buf
, prs_struct
*ps
, int depth
)
1081 prs_debug(ps
, depth
, desc
, "sam_io_sam_str2");
1087 if(!smb_io_unistr2("uni_srv_name", &sam
->uni_srv_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
1089 if(!smb_io_unistr2("uni_srv_desc", &sam
->uni_srv_desc
, desc_buf
, ps
, depth
)) /* account desc unicode string */
1095 /*******************************************************************
1096 inits a SAM_ENTRY2 structure.
1097 ********************************************************************/
1098 static void init_sam_entry2(SAM_ENTRY2
* sam
, uint32 user_idx
,
1099 UNISTR2
*sam_name
, UNISTR2
*sam_desc
,
1100 uint32 rid_user
, uint32 acb_info
)
1102 DEBUG(5, ("init_sam_entry2\n"));
1104 sam
->user_idx
= user_idx
;
1105 sam
->rid_user
= rid_user
;
1106 sam
->acb_info
= acb_info
;
1108 init_uni_hdr(&sam
->hdr_srv_name
, sam_name
);
1109 init_uni_hdr(&sam
->hdr_srv_desc
, sam_desc
);
1112 /*******************************************************************
1113 reads or writes a SAM_ENTRY2 structure.
1114 ********************************************************************/
1116 static BOOL
sam_io_sam_entry2(const char *desc
, SAM_ENTRY2
* sam
,
1117 prs_struct
*ps
, int depth
)
1122 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry2");
1128 if(!prs_uint32("user_idx ", ps
, depth
, &sam
->user_idx
))
1131 if(!prs_uint32("rid_user ", ps
, depth
, &sam
->rid_user
))
1133 if(!prs_uint32("acb_info ", ps
, depth
, &sam
->acb_info
))
1136 if(!smb_io_unihdr("unihdr", &sam
->hdr_srv_name
, ps
, depth
)) /* account name unicode string header */
1138 if(!smb_io_unihdr("unihdr", &sam
->hdr_srv_desc
, ps
, depth
)) /* account name unicode string header */
1144 /*******************************************************************
1145 reads or writes a SAM_STR3 structure.
1146 ********************************************************************/
1148 static BOOL
sam_io_sam_str3(const char *desc
, SAM_STR3
* sam
, uint32 acct_buf
,
1149 uint32 desc_buf
, prs_struct
*ps
, int depth
)
1154 prs_debug(ps
, depth
, desc
, "sam_io_sam_str3");
1160 if(!smb_io_unistr2("uni_grp_name", &sam
->uni_grp_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
1162 if(!smb_io_unistr2("uni_grp_desc", &sam
->uni_grp_desc
, desc_buf
, ps
, depth
)) /* account desc unicode string */
1168 /*******************************************************************
1169 inits a SAM_ENTRY3 structure.
1170 ********************************************************************/
1172 static void init_sam_entry3(SAM_ENTRY3
* sam
, uint32 grp_idx
,
1173 UNISTR2
*grp_name
, UNISTR2
*grp_desc
,
1176 DEBUG(5, ("init_sam_entry3\n"));
1178 sam
->grp_idx
= grp_idx
;
1179 sam
->rid_grp
= rid_grp
;
1180 sam
->attr
= 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1182 init_uni_hdr(&sam
->hdr_grp_name
, grp_name
);
1183 init_uni_hdr(&sam
->hdr_grp_desc
, grp_desc
);
1186 /*******************************************************************
1187 reads or writes a SAM_ENTRY3 structure.
1188 ********************************************************************/
1190 static BOOL
sam_io_sam_entry3(const char *desc
, SAM_ENTRY3
* sam
,
1191 prs_struct
*ps
, int depth
)
1196 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry3");
1202 if(!prs_uint32("grp_idx", ps
, depth
, &sam
->grp_idx
))
1205 if(!prs_uint32("rid_grp", ps
, depth
, &sam
->rid_grp
))
1207 if(!prs_uint32("attr ", ps
, depth
, &sam
->attr
))
1210 if(!smb_io_unihdr("unihdr", &sam
->hdr_grp_name
, ps
, depth
)) /* account name unicode string header */
1212 if(!smb_io_unihdr("unihdr", &sam
->hdr_grp_desc
, ps
, depth
)) /* account name unicode string header */
1218 /*******************************************************************
1219 inits a SAM_ENTRY4 structure.
1220 ********************************************************************/
1222 static void init_sam_entry4(SAM_ENTRY4
* sam
, uint32 user_idx
,
1223 uint32 len_acct_name
)
1225 DEBUG(5, ("init_sam_entry4\n"));
1227 sam
->user_idx
= user_idx
;
1228 init_str_hdr(&sam
->hdr_acct_name
, len_acct_name
+1, len_acct_name
, len_acct_name
!= 0);
1231 /*******************************************************************
1232 reads or writes a SAM_ENTRY4 structure.
1233 ********************************************************************/
1235 static BOOL
sam_io_sam_entry4(const char *desc
, SAM_ENTRY4
* sam
,
1236 prs_struct
*ps
, int depth
)
1241 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry4");
1247 if(!prs_uint32("user_idx", ps
, depth
, &sam
->user_idx
))
1249 if(!smb_io_strhdr("strhdr", &sam
->hdr_acct_name
, ps
, depth
))
1255 /*******************************************************************
1256 inits a SAM_ENTRY5 structure.
1257 ********************************************************************/
1259 static void init_sam_entry5(SAM_ENTRY5
* sam
, uint32 grp_idx
,
1260 uint32 len_grp_name
)
1262 DEBUG(5, ("init_sam_entry5\n"));
1264 sam
->grp_idx
= grp_idx
;
1265 init_str_hdr(&sam
->hdr_grp_name
, len_grp_name
, len_grp_name
,
1269 /*******************************************************************
1270 reads or writes a SAM_ENTRY5 structure.
1271 ********************************************************************/
1273 static BOOL
sam_io_sam_entry5(const char *desc
, SAM_ENTRY5
* sam
,
1274 prs_struct
*ps
, int depth
)
1279 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry5");
1285 if(!prs_uint32("grp_idx", ps
, depth
, &sam
->grp_idx
))
1287 if(!smb_io_strhdr("strhdr", &sam
->hdr_grp_name
, ps
, depth
))
1293 /*******************************************************************
1294 inits a SAM_ENTRY structure.
1295 ********************************************************************/
1297 void init_sam_entry(SAM_ENTRY
*sam
, UNISTR2
*uni2
, uint32 rid
)
1299 DEBUG(10, ("init_sam_entry: %d\n", rid
));
1302 init_uni_hdr(&sam
->hdr_name
, uni2
);
1305 /*******************************************************************
1306 reads or writes a SAM_ENTRY structure.
1307 ********************************************************************/
1309 static BOOL
sam_io_sam_entry(const char *desc
, SAM_ENTRY
* sam
,
1310 prs_struct
*ps
, int depth
)
1315 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry");
1320 if(!prs_uint32("rid", ps
, depth
, &sam
->rid
))
1322 if(!smb_io_unihdr("unihdr", &sam
->hdr_name
, ps
, depth
)) /* account name unicode string header */
1328 /*******************************************************************
1329 inits a SAMR_Q_ENUM_DOM_USERS structure.
1330 ********************************************************************/
1332 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS
* q_e
, POLICY_HND
*pol
,
1334 uint32 acb_mask
, uint32 size
)
1336 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1340 q_e
->start_idx
= start_idx
; /* zero indicates lots */
1341 q_e
->acb_mask
= acb_mask
;
1342 q_e
->max_size
= size
;
1345 /*******************************************************************
1346 reads or writes a structure.
1347 ********************************************************************/
1349 BOOL
samr_io_q_enum_dom_users(const char *desc
, SAMR_Q_ENUM_DOM_USERS
* q_e
,
1350 prs_struct
*ps
, int depth
)
1355 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_users");
1361 if(!smb_io_pol_hnd("domain_pol", &q_e
->pol
, ps
, depth
))
1364 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
1366 if(!prs_uint32("acb_mask ", ps
, depth
, &q_e
->acb_mask
))
1369 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1376 /*******************************************************************
1377 inits a SAMR_R_ENUM_DOM_USERS structure.
1378 ********************************************************************/
1380 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS
* r_u
,
1381 uint32 next_idx
, uint32 num_sam_entries
)
1383 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1385 r_u
->next_idx
= next_idx
;
1387 if (num_sam_entries
!= 0) {
1388 r_u
->ptr_entries1
= 1;
1389 r_u
->ptr_entries2
= 1;
1390 r_u
->num_entries2
= num_sam_entries
;
1391 r_u
->num_entries3
= num_sam_entries
;
1393 r_u
->num_entries4
= num_sam_entries
;
1395 r_u
->ptr_entries1
= 0;
1396 r_u
->num_entries2
= num_sam_entries
;
1397 r_u
->ptr_entries2
= 1;
1401 /*******************************************************************
1402 reads or writes a structure.
1403 ********************************************************************/
1405 BOOL
samr_io_r_enum_dom_users(const char *desc
, SAMR_R_ENUM_DOM_USERS
* r_u
,
1406 prs_struct
*ps
, int depth
)
1413 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_users");
1419 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
1421 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
1424 if (r_u
->ptr_entries1
!= 0) {
1425 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
1427 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
1429 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
1432 if (UNMARSHALLING(ps
) && (r_u
->num_entries2
!= 0)) {
1433 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
, r_u
->num_entries2
);
1434 r_u
->uni_acct_name
= PRS_ALLOC_MEM(ps
,UNISTR2
, r_u
->num_entries2
);
1437 if ((r_u
->sam
== NULL
|| r_u
->uni_acct_name
== NULL
) && r_u
->num_entries2
!= 0) {
1438 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1439 r_u
->num_entries4
= 0;
1440 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
1444 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1445 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
1449 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1450 if(!smb_io_unistr2("", &r_u
->uni_acct_name
[i
],r_u
->sam
[i
].hdr_name
.buffer
, ps
,depth
))
1459 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
1461 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
1467 /*******************************************************************
1468 inits a SAMR_Q_QUERY_DISPINFO structure.
1469 ********************************************************************/
1471 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO
* q_e
, POLICY_HND
*pol
,
1472 uint16 switch_level
, uint32 start_idx
,
1473 uint32 max_entries
, uint32 max_size
)
1475 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1477 q_e
->domain_pol
= *pol
;
1479 q_e
->switch_level
= switch_level
;
1481 q_e
->start_idx
= start_idx
;
1482 q_e
->max_entries
= max_entries
;
1483 q_e
->max_size
= max_size
;
1486 /*******************************************************************
1487 reads or writes a structure.
1488 ********************************************************************/
1490 BOOL
samr_io_q_query_dispinfo(const char *desc
, SAMR_Q_QUERY_DISPINFO
* q_e
,
1491 prs_struct
*ps
, int depth
)
1496 prs_debug(ps
, depth
, desc
, "samr_io_q_query_dispinfo");
1502 if(!smb_io_pol_hnd("domain_pol", &q_e
->domain_pol
, ps
, depth
))
1505 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
1510 if(!prs_uint32("start_idx ", ps
, depth
, &q_e
->start_idx
))
1512 if(!prs_uint32("max_entries ", ps
, depth
, &q_e
->max_entries
))
1514 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1520 /*******************************************************************
1521 inits a SAM_DISPINFO_1 structure.
1522 ********************************************************************/
1524 NTSTATUS
init_sam_dispinfo_1(TALLOC_CTX
*ctx
, SAM_DISPINFO_1
**sam
,
1525 uint32 num_entries
, uint32 start_idx
,
1526 struct samr_displayentry
*entries
)
1530 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries
));
1533 return NT_STATUS_OK
;
1535 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_1
, num_entries
);
1537 return NT_STATUS_NO_MEMORY
;
1539 (*sam
)->sam
=TALLOC_ARRAY(ctx
, SAM_ENTRY1
, num_entries
);
1540 if ((*sam
)->sam
== NULL
)
1541 return NT_STATUS_NO_MEMORY
;
1543 (*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR1
, num_entries
);
1544 if ((*sam
)->str
== NULL
)
1545 return NT_STATUS_NO_MEMORY
;
1547 for (i
= 0; i
< num_entries
; i
++) {
1548 init_unistr2(&(*sam
)->str
[i
].uni_acct_name
,
1549 entries
[i
].account_name
, UNI_FLAGS_NONE
);
1550 init_unistr2(&(*sam
)->str
[i
].uni_full_name
,
1551 entries
[i
].fullname
, UNI_FLAGS_NONE
);
1552 init_unistr2(&(*sam
)->str
[i
].uni_acct_desc
,
1553 entries
[i
].description
, UNI_FLAGS_NONE
);
1555 init_sam_entry1(&(*sam
)->sam
[i
], start_idx
+i
+1,
1556 &(*sam
)->str
[i
].uni_acct_name
,
1557 &(*sam
)->str
[i
].uni_full_name
,
1558 &(*sam
)->str
[i
].uni_acct_desc
,
1559 entries
[i
].rid
, entries
[i
].acct_flags
);
1562 return NT_STATUS_OK
;
1565 /*******************************************************************
1566 reads or writes a structure.
1567 ********************************************************************/
1569 static BOOL
sam_io_sam_dispinfo_1(const char *desc
, SAM_DISPINFO_1
* sam
,
1571 prs_struct
*ps
, int depth
)
1575 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_1");
1581 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1583 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY1
, num_entries
)) == NULL
) {
1584 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1588 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR1
, num_entries
)) == NULL
) {
1589 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1594 for (i
= 0; i
< num_entries
; i
++) {
1595 if(!sam_io_sam_entry1("", &sam
->sam
[i
], ps
, depth
))
1599 for (i
= 0; i
< num_entries
; i
++) {
1600 if(!sam_io_sam_str1("", &sam
->str
[i
],
1601 sam
->sam
[i
].hdr_acct_name
.buffer
,
1602 sam
->sam
[i
].hdr_user_name
.buffer
,
1603 sam
->sam
[i
].hdr_user_desc
.buffer
, ps
, depth
))
1610 /*******************************************************************
1611 inits a SAM_DISPINFO_2 structure.
1612 ********************************************************************/
1614 NTSTATUS
init_sam_dispinfo_2(TALLOC_CTX
*ctx
, SAM_DISPINFO_2
**sam
,
1615 uint32 num_entries
, uint32 start_idx
,
1616 struct samr_displayentry
*entries
)
1620 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries
));
1623 return NT_STATUS_OK
;
1625 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_2
, num_entries
);
1627 return NT_STATUS_NO_MEMORY
;
1629 (*sam
)->sam
= TALLOC_ARRAY(ctx
, SAM_ENTRY2
, num_entries
);
1630 if ((*sam
)->sam
== NULL
)
1631 return NT_STATUS_NO_MEMORY
;
1633 (*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR2
, num_entries
);
1634 if ((*sam
)->str
== NULL
)
1635 return NT_STATUS_NO_MEMORY
;
1637 for (i
= 0; i
< num_entries
; i
++) {
1638 init_unistr2(&(*sam
)->str
[i
].uni_srv_name
,
1639 entries
[i
].account_name
, UNI_FLAGS_NONE
);
1640 init_unistr2(&(*sam
)->str
[i
].uni_srv_desc
,
1641 entries
[i
].description
, UNI_FLAGS_NONE
);
1643 init_sam_entry2(&(*sam
)->sam
[i
], start_idx
+ i
+ 1,
1644 &(*sam
)->str
[i
].uni_srv_name
,
1645 &(*sam
)->str
[i
].uni_srv_desc
,
1646 entries
[i
].rid
, entries
[i
].acct_flags
);
1649 return NT_STATUS_OK
;
1652 /*******************************************************************
1653 reads or writes a structure.
1654 ********************************************************************/
1656 static BOOL
sam_io_sam_dispinfo_2(const char *desc
, SAM_DISPINFO_2
* sam
,
1658 prs_struct
*ps
, int depth
)
1665 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_2");
1671 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1673 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY2
, num_entries
)) == NULL
) {
1674 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1678 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR2
, num_entries
)) == NULL
) {
1679 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1684 for (i
= 0; i
< num_entries
; i
++) {
1685 if(!sam_io_sam_entry2("", &sam
->sam
[i
], ps
, depth
))
1689 for (i
= 0; i
< num_entries
; i
++) {
1690 if(!sam_io_sam_str2("", &sam
->str
[i
],
1691 sam
->sam
[i
].hdr_srv_name
.buffer
,
1692 sam
->sam
[i
].hdr_srv_desc
.buffer
, ps
, depth
))
1699 /*******************************************************************
1700 inits a SAM_DISPINFO_3 structure.
1701 ********************************************************************/
1703 NTSTATUS
init_sam_dispinfo_3(TALLOC_CTX
*ctx
, SAM_DISPINFO_3
**sam
,
1704 uint32 num_entries
, uint32 start_idx
,
1705 struct samr_displayentry
*entries
)
1709 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries
));
1712 return NT_STATUS_OK
;
1714 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_3
, num_entries
);
1716 return NT_STATUS_NO_MEMORY
;
1718 if (!((*sam
)->sam
=TALLOC_ARRAY(ctx
, SAM_ENTRY3
, num_entries
)))
1719 return NT_STATUS_NO_MEMORY
;
1721 if (!((*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR3
, num_entries
)))
1722 return NT_STATUS_NO_MEMORY
;
1724 for (i
= 0; i
< num_entries
; i
++) {
1725 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i
));
1727 init_unistr2(&(*sam
)->str
[i
].uni_grp_name
,
1728 entries
[i
].account_name
, UNI_FLAGS_NONE
);
1729 init_unistr2(&(*sam
)->str
[i
].uni_grp_desc
,
1730 entries
[i
].description
, UNI_FLAGS_NONE
);
1732 init_sam_entry3(&(*sam
)->sam
[i
], start_idx
+i
+1,
1733 &(*sam
)->str
[i
].uni_grp_name
,
1734 &(*sam
)->str
[i
].uni_grp_desc
,
1738 return NT_STATUS_OK
;
1741 /*******************************************************************
1742 reads or writes a structure.
1743 ********************************************************************/
1745 static BOOL
sam_io_sam_dispinfo_3(const char *desc
, SAM_DISPINFO_3
* sam
,
1747 prs_struct
*ps
, int depth
)
1754 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_3");
1760 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1762 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY3
, num_entries
)) == NULL
) {
1763 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1767 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR3
, num_entries
)) == NULL
) {
1768 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1773 for (i
= 0; i
< num_entries
; i
++) {
1774 if(!sam_io_sam_entry3("", &sam
->sam
[i
], ps
, depth
))
1778 for (i
= 0; i
< num_entries
; i
++) {
1779 if(!sam_io_sam_str3("", &sam
->str
[i
],
1780 sam
->sam
[i
].hdr_grp_name
.buffer
,
1781 sam
->sam
[i
].hdr_grp_desc
.buffer
, ps
, depth
))
1788 /*******************************************************************
1789 inits a SAM_DISPINFO_4 structure.
1790 ********************************************************************/
1792 NTSTATUS
init_sam_dispinfo_4(TALLOC_CTX
*ctx
, SAM_DISPINFO_4
**sam
,
1793 uint32 num_entries
, uint32 start_idx
,
1794 struct samr_displayentry
*entries
)
1798 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries
));
1801 return NT_STATUS_OK
;
1803 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_4
, num_entries
);
1805 return NT_STATUS_NO_MEMORY
;
1807 (*sam
)->sam
= TALLOC_ARRAY(ctx
, SAM_ENTRY4
, num_entries
);
1808 if ((*sam
)->sam
== NULL
)
1809 return NT_STATUS_NO_MEMORY
;
1811 (*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR4
, num_entries
);
1812 if ((*sam
)->str
== NULL
)
1813 return NT_STATUS_NO_MEMORY
;
1815 for (i
= 0; i
< num_entries
; i
++) {
1816 size_t len_sam_name
= strlen(entries
[i
].account_name
);
1818 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i
));
1820 init_sam_entry4(&(*sam
)->sam
[i
], start_idx
+ i
+ 1,
1823 init_string2(&(*sam
)->str
[i
].acct_name
,
1824 entries
[i
].account_name
, len_sam_name
+1,
1828 return NT_STATUS_OK
;
1831 /*******************************************************************
1832 reads or writes a structure.
1833 ********************************************************************/
1835 static BOOL
sam_io_sam_dispinfo_4(const char *desc
, SAM_DISPINFO_4
* sam
,
1837 prs_struct
*ps
, int depth
)
1844 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_4");
1850 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1852 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY4
, num_entries
)) == NULL
) {
1853 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1857 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR4
, num_entries
)) == NULL
) {
1858 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1863 for (i
= 0; i
< num_entries
; i
++) {
1864 if(!sam_io_sam_entry4("", &sam
->sam
[i
], ps
, depth
))
1868 for (i
= 0; i
< num_entries
; i
++) {
1869 if(!smb_io_string2("acct_name", &sam
->str
[i
].acct_name
,
1870 sam
->sam
[i
].hdr_acct_name
.buffer
, ps
, depth
))
1877 /*******************************************************************
1878 inits a SAM_DISPINFO_5 structure.
1879 ********************************************************************/
1881 NTSTATUS
init_sam_dispinfo_5(TALLOC_CTX
*ctx
, SAM_DISPINFO_5
**sam
,
1882 uint32 num_entries
, uint32 start_idx
,
1883 struct samr_displayentry
*entries
)
1885 uint32 len_sam_name
;
1888 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries
));
1891 return NT_STATUS_OK
;
1893 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_5
, num_entries
);
1895 return NT_STATUS_NO_MEMORY
;
1897 if (!((*sam
)->sam
=TALLOC_ARRAY(ctx
, SAM_ENTRY5
, num_entries
)))
1898 return NT_STATUS_NO_MEMORY
;
1900 if (!((*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR5
, num_entries
)))
1901 return NT_STATUS_NO_MEMORY
;
1903 for (i
= 0; i
< num_entries
; i
++) {
1904 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i
));
1906 len_sam_name
= strlen(entries
[i
].account_name
);
1908 init_sam_entry5(&(*sam
)->sam
[i
], start_idx
+i
+1, len_sam_name
);
1909 init_string2(&(*sam
)->str
[i
].grp_name
, entries
[i
].account_name
,
1910 len_sam_name
+1, len_sam_name
);
1913 return NT_STATUS_OK
;
1916 /*******************************************************************
1917 reads or writes a structure.
1918 ********************************************************************/
1920 static BOOL
sam_io_sam_dispinfo_5(const char *desc
, SAM_DISPINFO_5
* sam
,
1922 prs_struct
*ps
, int depth
)
1929 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_5");
1935 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1937 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY5
, num_entries
)) == NULL
) {
1938 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1942 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR5
, num_entries
)) == NULL
) {
1943 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1948 for (i
= 0; i
< num_entries
; i
++) {
1949 if(!sam_io_sam_entry5("", &sam
->sam
[i
], ps
, depth
))
1953 for (i
= 0; i
< num_entries
; i
++) {
1954 if(!smb_io_string2("grp_name", &sam
->str
[i
].grp_name
,
1955 sam
->sam
[i
].hdr_grp_name
.buffer
, ps
, depth
))
1962 /*******************************************************************
1963 inits a SAMR_R_QUERY_DISPINFO structure.
1964 ********************************************************************/
1966 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO
* r_u
,
1967 uint32 num_entries
, uint32 total_size
, uint32 data_size
,
1968 uint16 switch_level
, SAM_DISPINFO_CTR
* ctr
,
1971 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level
));
1973 r_u
->total_size
= total_size
;
1975 r_u
->data_size
= data_size
;
1977 r_u
->switch_level
= switch_level
;
1978 r_u
->num_entries
= num_entries
;
1981 r_u
->ptr_entries
= 0;
1983 r_u
->ptr_entries
= 1;
1985 r_u
->num_entries2
= num_entries
;
1988 r_u
->status
= status
;
1991 /*******************************************************************
1992 reads or writes a structure.
1993 ********************************************************************/
1995 BOOL
samr_io_r_query_dispinfo(const char *desc
, SAMR_R_QUERY_DISPINFO
* r_u
,
1996 prs_struct
*ps
, int depth
)
2001 prs_debug(ps
, depth
, desc
, "samr_io_r_query_dispinfo");
2007 if(!prs_uint32("total_size ", ps
, depth
, &r_u
->total_size
))
2009 if(!prs_uint32("data_size ", ps
, depth
, &r_u
->data_size
))
2011 if(!prs_uint16("switch_level", ps
, depth
, &r_u
->switch_level
))
2016 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
2018 if(!prs_uint32("ptr_entries ", ps
, depth
, &r_u
->ptr_entries
))
2021 if (r_u
->ptr_entries
==0) {
2024 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2030 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
2033 switch (r_u
->switch_level
) {
2035 if(!sam_io_sam_dispinfo_1("users", r_u
->ctr
->sam
.info1
,
2036 r_u
->num_entries
, ps
, depth
))
2040 if(!sam_io_sam_dispinfo_2("servers", r_u
->ctr
->sam
.info2
,
2041 r_u
->num_entries
, ps
, depth
))
2045 if(!sam_io_sam_dispinfo_3("groups", r_u
->ctr
->sam
.info3
,
2046 r_u
->num_entries
, ps
, depth
))
2050 if(!sam_io_sam_dispinfo_4("user list",
2051 r_u
->ctr
->sam
.info4
,
2052 r_u
->num_entries
, ps
, depth
))
2056 if(!sam_io_sam_dispinfo_5("group list",
2057 r_u
->ctr
->sam
.info5
,
2058 r_u
->num_entries
, ps
, depth
))
2062 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2068 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2074 /*******************************************************************
2075 inits a SAMR_Q_OPEN_GROUP structure.
2076 ********************************************************************/
2078 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP
* q_c
,
2080 uint32 access_mask
, uint32 rid
)
2082 DEBUG(5, ("init_samr_q_open_group\n"));
2084 q_c
->domain_pol
= *hnd
;
2085 q_c
->access_mask
= access_mask
;
2086 q_c
->rid_group
= rid
;
2089 /*******************************************************************
2090 reads or writes a structure.
2091 ********************************************************************/
2093 BOOL
samr_io_q_open_group(const char *desc
, SAMR_Q_OPEN_GROUP
* q_u
,
2094 prs_struct
*ps
, int depth
)
2099 prs_debug(ps
, depth
, desc
, "samr_io_q_open_group");
2105 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
2108 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
2110 if(!prs_uint32("rid_group", ps
, depth
, &q_u
->rid_group
))
2116 /*******************************************************************
2117 reads or writes a structure.
2118 ********************************************************************/
2120 BOOL
samr_io_r_open_group(const char *desc
, SAMR_R_OPEN_GROUP
* r_u
,
2121 prs_struct
*ps
, int depth
)
2126 prs_debug(ps
, depth
, desc
, "samr_io_r_open_group");
2132 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2135 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2141 /*******************************************************************
2142 inits a GROUP_INFO1 structure.
2143 ********************************************************************/
2145 void init_samr_group_info1(GROUP_INFO1
* gr1
,
2146 char *acct_name
, char *acct_desc
,
2149 DEBUG(5, ("init_samr_group_info1\n"));
2151 gr1
->group_attr
= (SE_GROUP_MANDATORY
|SE_GROUP_ENABLED_BY_DEFAULT
); /* why not | SE_GROUP_ENABLED ? */
2152 gr1
->num_members
= num_members
;
2154 init_unistr2(&gr1
->uni_acct_name
, acct_name
, UNI_FLAGS_NONE
);
2155 init_uni_hdr(&gr1
->hdr_acct_name
, &gr1
->uni_acct_name
);
2156 init_unistr2(&gr1
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
2157 init_uni_hdr(&gr1
->hdr_acct_desc
, &gr1
->uni_acct_desc
);
2160 /*******************************************************************
2161 reads or writes a structure.
2162 ********************************************************************/
2164 BOOL
samr_io_group_info1(const char *desc
, GROUP_INFO1
* gr1
,
2165 prs_struct
*ps
, int depth
)
2172 prs_debug(ps
, depth
, desc
, "samr_io_group_info1");
2175 if(!prs_uint16("level", ps
, depth
, &dummy
))
2181 if(!smb_io_unihdr("hdr_acct_name", &gr1
->hdr_acct_name
, ps
, depth
))
2184 if(!prs_uint32("group_attr", ps
, depth
, &gr1
->group_attr
))
2186 if(!prs_uint32("num_members", ps
, depth
, &gr1
->num_members
))
2189 if(!smb_io_unihdr("hdr_acct_desc", &gr1
->hdr_acct_desc
, ps
, depth
))
2192 if(!smb_io_unistr2("uni_acct_name", &gr1
->uni_acct_name
,
2193 gr1
->hdr_acct_name
.buffer
, ps
, depth
))
2196 if(!smb_io_unistr2("uni_acct_desc", &gr1
->uni_acct_desc
,
2197 gr1
->hdr_acct_desc
.buffer
, ps
, depth
))
2203 /*******************************************************************
2204 inits a GROUP_INFO2 structure.
2205 ********************************************************************/
2207 void init_samr_group_info2(GROUP_INFO2
* gr2
, const char *acct_name
)
2209 DEBUG(5, ("init_samr_group_info2\n"));
2212 init_unistr2(&gr2
->uni_acct_name
, acct_name
, UNI_FLAGS_NONE
);
2213 init_uni_hdr(&gr2
->hdr_acct_name
, &gr2
->uni_acct_name
);
2216 /*******************************************************************
2217 reads or writes a structure.
2218 ********************************************************************/
2220 BOOL
samr_io_group_info2(const char *desc
, GROUP_INFO2
*gr2
, prs_struct
*ps
, int depth
)
2225 prs_debug(ps
, depth
, desc
, "samr_io_group_info2");
2228 if(!prs_uint16("hdr_level", ps
, depth
, &gr2
->level
))
2231 if(!smb_io_unihdr("hdr_acct_name", &gr2
->hdr_acct_name
, ps
, depth
))
2233 if(!smb_io_unistr2("uni_acct_name", &gr2
->uni_acct_name
,
2234 gr2
->hdr_acct_name
.buffer
, ps
, depth
))
2240 /*******************************************************************
2241 inits a GROUP_INFO3 structure.
2242 ********************************************************************/
2244 void init_samr_group_info3(GROUP_INFO3
*gr3
)
2246 DEBUG(5, ("init_samr_group_info3\n"));
2248 gr3
->group_attr
= (SE_GROUP_MANDATORY
|SE_GROUP_ENABLED_BY_DEFAULT
); /* why not | SE_GROUP_ENABLED ? */
2251 /*******************************************************************
2252 reads or writes a structure.
2253 ********************************************************************/
2255 BOOL
samr_io_group_info3(const char *desc
, GROUP_INFO3
*gr3
, prs_struct
*ps
, int depth
)
2260 prs_debug(ps
, depth
, desc
, "samr_io_group_info3");
2266 if(!prs_uint32("group_attr", ps
, depth
, &gr3
->group_attr
))
2272 /*******************************************************************
2273 inits a GROUP_INFO4 structure.
2274 ********************************************************************/
2276 void init_samr_group_info4(GROUP_INFO4
* gr4
, const char *acct_desc
)
2278 DEBUG(5, ("init_samr_group_info4\n"));
2281 init_unistr2(&gr4
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
2282 init_uni_hdr(&gr4
->hdr_acct_desc
, &gr4
->uni_acct_desc
);
2285 /*******************************************************************
2286 reads or writes a structure.
2287 ********************************************************************/
2289 BOOL
samr_io_group_info4(const char *desc
, GROUP_INFO4
* gr4
,
2290 prs_struct
*ps
, int depth
)
2295 prs_debug(ps
, depth
, desc
, "samr_io_group_info4");
2298 if(!prs_uint16("hdr_level", ps
, depth
, &gr4
->level
))
2300 if(!smb_io_unihdr("hdr_acct_desc", &gr4
->hdr_acct_desc
, ps
, depth
))
2302 if(!smb_io_unistr2("uni_acct_desc", &gr4
->uni_acct_desc
,
2303 gr4
->hdr_acct_desc
.buffer
, ps
, depth
))
2309 /*******************************************************************
2310 inits a GROUP_INFO5 structure.
2311 ********************************************************************/
2313 void init_samr_group_info5(GROUP_INFO5
* gr5
,
2314 char *acct_name
, char *acct_desc
,
2317 DEBUG(5, ("init_samr_group_info5\n"));
2319 gr5
->group_attr
= (SE_GROUP_MANDATORY
|SE_GROUP_ENABLED_BY_DEFAULT
); /* why not | SE_GROUP_ENABLED ? */
2320 gr5
->num_members
= num_members
;
2322 init_unistr2(&gr5
->uni_acct_name
, acct_name
, UNI_FLAGS_NONE
);
2323 init_uni_hdr(&gr5
->hdr_acct_name
, &gr5
->uni_acct_name
);
2324 init_unistr2(&gr5
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
2325 init_uni_hdr(&gr5
->hdr_acct_desc
, &gr5
->uni_acct_desc
);
2328 /*******************************************************************
2329 reads or writes a structure.
2330 ********************************************************************/
2332 BOOL
samr_io_group_info5(const char *desc
, GROUP_INFO5
* gr5
,
2333 prs_struct
*ps
, int depth
)
2340 prs_debug(ps
, depth
, desc
, "samr_io_group_info5");
2343 if(!prs_uint16("level", ps
, depth
, &dummy
))
2349 if(!smb_io_unihdr("hdr_acct_name", &gr5
->hdr_acct_name
, ps
, depth
))
2352 if(!prs_uint32("group_attr", ps
, depth
, &gr5
->group_attr
))
2354 if(!prs_uint32("num_members", ps
, depth
, &gr5
->num_members
))
2357 if(!smb_io_unihdr("hdr_acct_desc", &gr5
->hdr_acct_desc
, ps
, depth
))
2360 if(!smb_io_unistr2("uni_acct_name", &gr5
->uni_acct_name
,
2361 gr5
->hdr_acct_name
.buffer
, ps
, depth
))
2364 if(!smb_io_unistr2("uni_acct_desc", &gr5
->uni_acct_desc
,
2365 gr5
->hdr_acct_desc
.buffer
, ps
, depth
))
2372 /*******************************************************************
2373 reads or writes a structure.
2374 ********************************************************************/
2376 static BOOL
samr_group_info_ctr(const char *desc
, GROUP_INFO_CTR
**ctr
,
2377 prs_struct
*ps
, int depth
)
2379 if (UNMARSHALLING(ps
))
2380 *ctr
= PRS_ALLOC_MEM(ps
,GROUP_INFO_CTR
,1);
2385 prs_debug(ps
, depth
, desc
, "samr_group_info_ctr");
2388 if(!prs_uint16("switch_value1", ps
, depth
, &(*ctr
)->switch_value1
))
2391 switch ((*ctr
)->switch_value1
) {
2393 if(!samr_io_group_info1("group_info1", &(*ctr
)->group
.info1
, ps
, depth
))
2397 if(!samr_io_group_info2("group_info2", &(*ctr
)->group
.info2
, ps
, depth
))
2401 if(!samr_io_group_info3("group_info3", &(*ctr
)->group
.info3
, ps
, depth
))
2405 if(!samr_io_group_info4("group_info4", &(*ctr
)->group
.info4
, ps
, depth
))
2409 if(!samr_io_group_info5("group_info5", &(*ctr
)->group
.info5
, ps
, depth
))
2413 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2420 /*******************************************************************
2421 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2422 ********************************************************************/
2424 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP
* q_e
,
2425 POLICY_HND
*pol
, const char *acct_desc
,
2428 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2432 init_unistr2(&q_e
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
2433 init_uni_hdr(&q_e
->hdr_acct_desc
, &q_e
->uni_acct_desc
);
2435 q_e
->access_mask
= access_mask
;
2438 /*******************************************************************
2439 reads or writes a structure.
2440 ********************************************************************/
2442 BOOL
samr_io_q_create_dom_group(const char *desc
, SAMR_Q_CREATE_DOM_GROUP
* q_e
,
2443 prs_struct
*ps
, int depth
)
2448 prs_debug(ps
, depth
, desc
, "samr_io_q_create_dom_group");
2454 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2457 if(!smb_io_unihdr("hdr_acct_desc", &q_e
->hdr_acct_desc
, ps
, depth
))
2459 if(!smb_io_unistr2("uni_acct_desc", &q_e
->uni_acct_desc
,
2460 q_e
->hdr_acct_desc
.buffer
, ps
, depth
))
2465 if(!prs_uint32("access", ps
, depth
, &q_e
->access_mask
))
2471 /*******************************************************************
2472 reads or writes a structure.
2473 ********************************************************************/
2475 BOOL
samr_io_r_create_dom_group(const char *desc
, SAMR_R_CREATE_DOM_GROUP
* r_u
,
2476 prs_struct
*ps
, int depth
)
2481 prs_debug(ps
, depth
, desc
, "samr_io_r_create_dom_group");
2487 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2490 if(!prs_uint32("rid ", ps
, depth
, &r_u
->rid
))
2492 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2498 /*******************************************************************
2499 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2500 ********************************************************************/
2502 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP
* q_c
,
2505 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2507 q_c
->group_pol
= *hnd
;
2510 /*******************************************************************
2511 reads or writes a structure.
2512 ********************************************************************/
2514 BOOL
samr_io_q_delete_dom_group(const char *desc
, SAMR_Q_DELETE_DOM_GROUP
* q_u
,
2515 prs_struct
*ps
, int depth
)
2520 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_group");
2526 if(!smb_io_pol_hnd("group_pol", &q_u
->group_pol
, ps
, depth
))
2532 /*******************************************************************
2533 reads or writes a structure.
2534 ********************************************************************/
2536 BOOL
samr_io_r_delete_dom_group(const char *desc
, SAMR_R_DELETE_DOM_GROUP
* r_u
,
2537 prs_struct
*ps
, int depth
)
2542 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_group");
2548 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2551 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2557 /*******************************************************************
2558 inits a SAMR_Q_DEL_GROUPMEM structure.
2559 ********************************************************************/
2561 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM
* q_e
,
2562 POLICY_HND
*pol
, uint32 rid
)
2564 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2570 /*******************************************************************
2571 reads or writes a structure.
2572 ********************************************************************/
2574 BOOL
samr_io_q_del_groupmem(const char *desc
, SAMR_Q_DEL_GROUPMEM
* q_e
,
2575 prs_struct
*ps
, int depth
)
2580 prs_debug(ps
, depth
, desc
, "samr_io_q_del_groupmem");
2586 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2589 if(!prs_uint32("rid", ps
, depth
, &q_e
->rid
))
2595 /*******************************************************************
2596 inits a SAMR_R_DEL_GROUPMEM structure.
2597 ********************************************************************/
2599 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM
* r_u
, POLICY_HND
*pol
,
2602 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2604 r_u
->status
= status
;
2607 /*******************************************************************
2608 reads or writes a structure.
2609 ********************************************************************/
2611 BOOL
samr_io_r_del_groupmem(const char *desc
, SAMR_R_DEL_GROUPMEM
* r_u
,
2612 prs_struct
*ps
, int depth
)
2617 prs_debug(ps
, depth
, desc
, "samr_io_r_del_groupmem");
2623 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2629 /*******************************************************************
2630 inits a SAMR_Q_ADD_GROUPMEM structure.
2631 ********************************************************************/
2633 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM
* q_e
,
2634 POLICY_HND
*pol
, uint32 rid
)
2636 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2640 q_e
->unknown
= 0x0005;
2643 /*******************************************************************
2644 reads or writes a structure.
2645 ********************************************************************/
2647 BOOL
samr_io_q_add_groupmem(const char *desc
, SAMR_Q_ADD_GROUPMEM
* q_e
,
2648 prs_struct
*ps
, int depth
)
2653 prs_debug(ps
, depth
, desc
, "samr_io_q_add_groupmem");
2659 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2662 if(!prs_uint32("rid ", ps
, depth
, &q_e
->rid
))
2664 if(!prs_uint32("unknown", ps
, depth
, &q_e
->unknown
))
2670 /*******************************************************************
2671 inits a SAMR_R_ADD_GROUPMEM structure.
2672 ********************************************************************/
2674 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM
* r_u
, POLICY_HND
*pol
,
2677 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2679 r_u
->status
= status
;
2682 /*******************************************************************
2683 reads or writes a structure.
2684 ********************************************************************/
2686 BOOL
samr_io_r_add_groupmem(const char *desc
, SAMR_R_ADD_GROUPMEM
* r_u
,
2687 prs_struct
*ps
, int depth
)
2692 prs_debug(ps
, depth
, desc
, "samr_io_r_add_groupmem");
2698 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2704 /*******************************************************************
2705 inits a SAMR_Q_SET_GROUPINFO structure.
2706 ********************************************************************/
2708 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO
* q_e
,
2709 POLICY_HND
*pol
, GROUP_INFO_CTR
* ctr
)
2711 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2717 /*******************************************************************
2718 reads or writes a structure.
2719 ********************************************************************/
2721 BOOL
samr_io_q_set_groupinfo(const char *desc
, SAMR_Q_SET_GROUPINFO
* q_e
,
2722 prs_struct
*ps
, int depth
)
2727 prs_debug(ps
, depth
, desc
, "samr_io_q_set_groupinfo");
2733 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2736 if(!samr_group_info_ctr("ctr", &q_e
->ctr
, ps
, depth
))
2742 /*******************************************************************
2743 inits a SAMR_R_SET_GROUPINFO structure.
2744 ********************************************************************/
2746 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO
* r_u
, NTSTATUS status
)
2748 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2750 r_u
->status
= status
;
2753 /*******************************************************************
2754 reads or writes a structure.
2755 ********************************************************************/
2757 BOOL
samr_io_r_set_groupinfo(const char *desc
, SAMR_R_SET_GROUPINFO
* r_u
,
2758 prs_struct
*ps
, int depth
)
2763 prs_debug(ps
, depth
, desc
, "samr_io_r_set_groupinfo");
2769 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2775 /*******************************************************************
2776 inits a SAMR_Q_QUERY_GROUPINFO structure.
2777 ********************************************************************/
2779 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO
* q_e
,
2780 POLICY_HND
*pol
, uint16 switch_level
)
2782 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2786 q_e
->switch_level
= switch_level
;
2789 /*******************************************************************
2790 reads or writes a structure.
2791 ********************************************************************/
2793 BOOL
samr_io_q_query_groupinfo(const char *desc
, SAMR_Q_QUERY_GROUPINFO
* q_e
,
2794 prs_struct
*ps
, int depth
)
2799 prs_debug(ps
, depth
, desc
, "samr_io_q_query_groupinfo");
2805 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2808 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
2814 /*******************************************************************
2815 inits a SAMR_R_QUERY_GROUPINFO structure.
2816 ********************************************************************/
2818 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO
* r_u
,
2819 GROUP_INFO_CTR
* ctr
, NTSTATUS status
)
2821 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2823 r_u
->ptr
= (NT_STATUS_IS_OK(status
) && ctr
!= NULL
) ? 1 : 0;
2825 r_u
->status
= status
;
2828 /*******************************************************************
2829 reads or writes a structure.
2830 ********************************************************************/
2832 BOOL
samr_io_r_query_groupinfo(const char *desc
, SAMR_R_QUERY_GROUPINFO
* r_u
,
2833 prs_struct
*ps
, int depth
)
2838 prs_debug(ps
, depth
, desc
, "samr_io_r_query_groupinfo");
2844 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
2847 if (r_u
->ptr
!= 0) {
2848 if(!samr_group_info_ctr("ctr", &r_u
->ctr
, ps
, depth
))
2854 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2860 /*******************************************************************
2861 inits a SAMR_Q_QUERY_GROUPMEM structure.
2862 ********************************************************************/
2864 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM
* q_c
, POLICY_HND
*hnd
)
2866 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2868 q_c
->group_pol
= *hnd
;
2871 /*******************************************************************
2872 reads or writes a structure.
2873 ********************************************************************/
2875 BOOL
samr_io_q_query_groupmem(const char *desc
, SAMR_Q_QUERY_GROUPMEM
* q_u
,
2876 prs_struct
*ps
, int depth
)
2881 prs_debug(ps
, depth
, desc
, "samr_io_q_query_groupmem");
2887 if(!smb_io_pol_hnd("group_pol", &q_u
->group_pol
, ps
, depth
))
2893 /*******************************************************************
2894 inits a SAMR_R_QUERY_GROUPMEM structure.
2895 ********************************************************************/
2897 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM
* r_u
,
2898 uint32 num_entries
, uint32
*rid
,
2899 uint32
*attr
, NTSTATUS status
)
2901 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2903 if (NT_STATUS_IS_OK(status
)) {
2905 r_u
->num_entries
= num_entries
;
2907 r_u
->ptr_attrs
= attr
!= NULL
? 1 : 0;
2908 r_u
->ptr_rids
= rid
!= NULL
? 1 : 0;
2910 r_u
->num_rids
= num_entries
;
2913 r_u
->num_attrs
= num_entries
;
2917 r_u
->num_entries
= 0;
2920 r_u
->status
= status
;
2923 /*******************************************************************
2924 reads or writes a structure.
2925 ********************************************************************/
2927 BOOL
samr_io_r_query_groupmem(const char *desc
, SAMR_R_QUERY_GROUPMEM
* r_u
,
2928 prs_struct
*ps
, int depth
)
2935 if (UNMARSHALLING(ps
))
2938 prs_debug(ps
, depth
, desc
, "samr_io_r_query_groupmem");
2944 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
2946 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
2949 if (r_u
->ptr
!= 0) {
2950 if(!prs_uint32("ptr_rids ", ps
, depth
, &r_u
->ptr_rids
))
2952 if(!prs_uint32("ptr_attrs", ps
, depth
, &r_u
->ptr_attrs
))
2955 if (r_u
->ptr_rids
!= 0) {
2956 if(!prs_uint32("num_rids", ps
, depth
, &r_u
->num_rids
))
2958 if (UNMARSHALLING(ps
) && r_u
->num_rids
!= 0) {
2959 r_u
->rid
= PRS_ALLOC_MEM(ps
,uint32
,r_u
->num_rids
);
2960 if (r_u
->rid
== NULL
)
2964 for (i
= 0; i
< r_u
->num_rids
; i
++) {
2965 if(!prs_uint32("", ps
, depth
, &r_u
->rid
[i
]))
2970 if (r_u
->ptr_attrs
!= 0) {
2971 if(!prs_uint32("num_attrs", ps
, depth
, &r_u
->num_attrs
))
2974 if (UNMARSHALLING(ps
) && r_u
->num_attrs
!= 0) {
2975 r_u
->attr
= PRS_ALLOC_MEM(ps
,uint32
,r_u
->num_attrs
);
2976 if (r_u
->attr
== NULL
)
2980 for (i
= 0; i
< r_u
->num_attrs
; i
++) {
2981 if(!prs_uint32("", ps
, depth
, &r_u
->attr
[i
]))
2987 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2993 /*******************************************************************
2994 inits a SAMR_Q_QUERY_USERGROUPS structure.
2995 ********************************************************************/
2997 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS
* q_u
,
3000 DEBUG(5, ("init_samr_q_query_usergroups\n"));
3005 /*******************************************************************
3006 reads or writes a structure.
3007 ********************************************************************/
3009 BOOL
samr_io_q_query_usergroups(const char *desc
, SAMR_Q_QUERY_USERGROUPS
* q_u
,
3010 prs_struct
*ps
, int depth
)
3015 prs_debug(ps
, depth
, desc
, "samr_io_q_query_usergroups");
3021 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
3027 /*******************************************************************
3028 inits a SAMR_R_QUERY_USERGROUPS structure.
3029 ********************************************************************/
3031 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS
* r_u
,
3032 uint32 num_gids
, DOM_GID
* gid
,
3035 DEBUG(5, ("init_samr_r_query_usergroups\n"));
3037 if (NT_STATUS_IS_OK(status
)) {
3039 r_u
->num_entries
= num_gids
;
3040 r_u
->ptr_1
= (num_gids
!= 0) ? 1 : 0;
3041 r_u
->num_entries2
= num_gids
;
3046 r_u
->num_entries
= 0;
3051 r_u
->status
= status
;
3054 /*******************************************************************
3055 reads or writes a structure.
3056 ********************************************************************/
3058 BOOL
samr_io_gids(const char *desc
, uint32
*num_gids
, DOM_GID
** gid
,
3059 prs_struct
*ps
, int depth
)
3065 prs_debug(ps
, depth
, desc
, "samr_io_gids");
3071 if(!prs_uint32("num_gids", ps
, depth
, num_gids
))
3074 if ((*num_gids
) != 0) {
3075 if (UNMARSHALLING(ps
)) {
3076 (*gid
) = PRS_ALLOC_MEM(ps
,DOM_GID
,*num_gids
);
3079 if ((*gid
) == NULL
) {
3083 for (i
= 0; i
< (*num_gids
); i
++) {
3084 if(!smb_io_gid("gids", &(*gid
)[i
], ps
, depth
))
3092 /*******************************************************************
3093 reads or writes a structure.
3094 ********************************************************************/
3096 BOOL
samr_io_r_query_usergroups(const char *desc
, SAMR_R_QUERY_USERGROUPS
* r_u
,
3097 prs_struct
*ps
, int depth
)
3102 prs_debug(ps
, depth
, desc
, "samr_io_r_query_usergroups");
3108 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
3111 if (r_u
->ptr_0
!= 0) {
3112 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
3114 if(!prs_uint32("ptr_1 ", ps
, depth
, &r_u
->ptr_1
))
3117 if (r_u
->num_entries
!= 0 && r_u
->ptr_1
!= 0) {
3118 if(!samr_io_gids("gids", &r_u
->num_entries2
, &r_u
->gid
, ps
, depth
))
3125 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3131 /*******************************************************************
3132 inits a SAMR_Q_ENUM_DOMAINS structure.
3133 ********************************************************************/
3135 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS
* q_e
,
3137 uint32 start_idx
, uint32 size
)
3139 DEBUG(5, ("init_samr_q_enum_domains\n"));
3143 q_e
->start_idx
= start_idx
;
3144 q_e
->max_size
= size
;
3147 /*******************************************************************
3148 reads or writes a structure.
3149 ********************************************************************/
3151 BOOL
samr_io_q_enum_domains(const char *desc
, SAMR_Q_ENUM_DOMAINS
* q_e
,
3152 prs_struct
*ps
, int depth
)
3157 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_domains");
3163 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
3166 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3168 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3174 /*******************************************************************
3175 inits a SAMR_R_ENUM_DOMAINS structure.
3176 ********************************************************************/
3178 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS
* r_u
,
3179 uint32 next_idx
, uint32 num_sam_entries
)
3181 DEBUG(5, ("init_samr_r_enum_domains\n"));
3183 r_u
->next_idx
= next_idx
;
3185 if (num_sam_entries
!= 0) {
3186 r_u
->ptr_entries1
= 1;
3187 r_u
->ptr_entries2
= 1;
3188 r_u
->num_entries2
= num_sam_entries
;
3189 r_u
->num_entries3
= num_sam_entries
;
3191 r_u
->num_entries4
= num_sam_entries
;
3193 r_u
->ptr_entries1
= 0;
3194 r_u
->num_entries2
= num_sam_entries
;
3195 r_u
->ptr_entries2
= 1;
3199 /*******************************************************************
3200 reads or writes a structure.
3201 ********************************************************************/
3203 BOOL
samr_io_r_enum_domains(const char *desc
, SAMR_R_ENUM_DOMAINS
* r_u
,
3204 prs_struct
*ps
, int depth
)
3211 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_domains");
3217 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3219 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3222 if (r_u
->ptr_entries1
!= 0) {
3223 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3225 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3227 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3230 if (UNMARSHALLING(ps
)) {
3231 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
,r_u
->num_entries2
);
3232 r_u
->uni_dom_name
= PRS_ALLOC_MEM(ps
,UNISTR2
,r_u
->num_entries2
);
3235 if ((r_u
->sam
== NULL
|| r_u
->uni_dom_name
== NULL
) && r_u
->num_entries2
!= 0) {
3236 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3237 r_u
->num_entries4
= 0;
3238 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3242 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3244 slprintf(tmp
, sizeof(tmp
) - 1, "dom[%d]", i
);
3245 if(!sam_io_sam_entry(tmp
, &r_u
->sam
[i
], ps
, depth
))
3249 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3251 slprintf(tmp
, sizeof(tmp
) - 1, "dom[%d]", i
);
3252 if(!smb_io_unistr2(tmp
, &r_u
->uni_dom_name
[i
],
3253 r_u
->sam
[i
].hdr_name
.buffer
, ps
,
3262 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3264 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3270 /*******************************************************************
3271 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3272 ********************************************************************/
3274 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS
* q_e
,
3276 uint32 start_idx
, uint32 size
)
3278 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3282 q_e
->start_idx
= start_idx
;
3283 q_e
->max_size
= size
;
3286 /*******************************************************************
3287 reads or writes a structure.
3288 ********************************************************************/
3290 BOOL
samr_io_q_enum_dom_groups(const char *desc
, SAMR_Q_ENUM_DOM_GROUPS
* q_e
,
3291 prs_struct
*ps
, int depth
)
3296 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_groups");
3302 if(!smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
))
3305 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3307 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3313 /*******************************************************************
3314 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3315 ********************************************************************/
3317 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS
* r_u
,
3318 uint32 next_idx
, uint32 num_sam_entries
)
3320 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3322 r_u
->next_idx
= next_idx
;
3324 if (num_sam_entries
!= 0) {
3325 r_u
->ptr_entries1
= 1;
3326 r_u
->ptr_entries2
= 1;
3327 r_u
->num_entries2
= num_sam_entries
;
3328 r_u
->num_entries3
= num_sam_entries
;
3330 r_u
->num_entries4
= num_sam_entries
;
3332 r_u
->ptr_entries1
= 0;
3333 r_u
->num_entries2
= num_sam_entries
;
3334 r_u
->ptr_entries2
= 1;
3338 /*******************************************************************
3339 reads or writes a structure.
3340 ********************************************************************/
3342 BOOL
samr_io_r_enum_dom_groups(const char *desc
, SAMR_R_ENUM_DOM_GROUPS
* r_u
,
3343 prs_struct
*ps
, int depth
)
3350 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_groups");
3356 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3358 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3361 if (r_u
->ptr_entries1
!= 0) {
3362 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3364 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3366 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3369 if (UNMARSHALLING(ps
)) {
3370 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
,r_u
->num_entries2
);
3371 r_u
->uni_grp_name
= PRS_ALLOC_MEM(ps
,UNISTR2
,r_u
->num_entries2
);
3374 if ((r_u
->sam
== NULL
|| r_u
->uni_grp_name
== NULL
) && r_u
->num_entries2
!= 0) {
3376 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3377 r_u
->num_entries4
= 0;
3378 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3382 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3383 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
3387 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3388 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
],
3389 r_u
->sam
[i
].hdr_name
.buffer
, ps
, depth
))
3396 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3398 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3404 /*******************************************************************
3405 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3406 ********************************************************************/
3408 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES
* q_e
,
3409 POLICY_HND
*pol
, uint32 start_idx
,
3412 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3416 q_e
->start_idx
= start_idx
;
3417 q_e
->max_size
= size
;
3421 /*******************************************************************
3422 reads or writes a structure.
3423 ********************************************************************/
3425 BOOL
samr_io_q_enum_dom_aliases(const char *desc
, SAMR_Q_ENUM_DOM_ALIASES
* q_e
,
3426 prs_struct
*ps
, int depth
)
3431 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_aliases");
3437 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
3440 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3442 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3448 /*******************************************************************
3449 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3450 ********************************************************************/
3452 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES
*r_u
, uint32 next_idx
, uint32 num_sam_entries
)
3454 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3456 r_u
->next_idx
= next_idx
;
3458 if (num_sam_entries
!= 0) {
3459 r_u
->ptr_entries1
= 1;
3460 r_u
->ptr_entries2
= 1;
3461 r_u
->num_entries2
= num_sam_entries
;
3462 r_u
->num_entries3
= num_sam_entries
;
3464 r_u
->num_entries4
= num_sam_entries
;
3466 r_u
->ptr_entries1
= 0;
3467 r_u
->num_entries2
= num_sam_entries
;
3468 r_u
->ptr_entries2
= 1;
3472 /*******************************************************************
3473 reads or writes a structure.
3474 ********************************************************************/
3476 BOOL
samr_io_r_enum_dom_aliases(const char *desc
, SAMR_R_ENUM_DOM_ALIASES
* r_u
,
3477 prs_struct
*ps
, int depth
)
3484 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_aliases");
3490 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3492 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3495 if (r_u
->ptr_entries1
!= 0) {
3496 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3498 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3500 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3503 if (UNMARSHALLING(ps
) && (r_u
->num_entries2
> 0)) {
3504 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
,r_u
->num_entries2
);
3505 r_u
->uni_grp_name
= PRS_ALLOC_MEM(ps
,UNISTR2
,r_u
->num_entries2
);
3508 if (r_u
->num_entries2
!= 0 &&
3509 (r_u
->sam
== NULL
|| r_u
->uni_grp_name
== NULL
)) {
3510 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3511 r_u
->num_entries4
= 0;
3512 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3516 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3517 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
3521 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3522 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
],
3523 r_u
->sam
[i
].hdr_name
.buffer
, ps
,
3531 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3533 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3539 /*******************************************************************
3540 inits a ALIAS_INFO1 structure.
3541 ********************************************************************/
3543 void init_samr_alias_info1(ALIAS_INFO1
* al1
, char *acct_name
, uint32 num_member
, char *acct_desc
)
3545 DEBUG(5, ("init_samr_alias_info1\n"));
3547 init_unistr4(&al1
->name
, acct_name
, UNI_FLAGS_NONE
);
3548 al1
->num_member
= num_member
;
3549 init_unistr4(&al1
->description
, acct_desc
, UNI_FLAGS_NONE
);
3552 /*******************************************************************
3553 reads or writes a structure.
3554 ********************************************************************/
3556 BOOL
samr_io_alias_info1(const char *desc
, ALIAS_INFO1
* al1
,
3557 prs_struct
*ps
, int depth
)
3562 prs_debug(ps
, depth
, desc
, "samr_io_alias_info1");
3568 if ( !prs_unistr4_hdr("name", ps
, depth
, &al1
->name
) )
3570 if ( !prs_uint32("num_member", ps
, depth
, &al1
->num_member
) )
3572 if ( !prs_unistr4_hdr("description", ps
, depth
, &al1
->description
) )
3575 if ( !prs_unistr4_str("name", ps
, depth
, &al1
->name
) )
3577 if ( !prs_align(ps
) )
3579 if ( !prs_unistr4_str("description", ps
, depth
, &al1
->description
) )
3581 if ( !prs_align(ps
) )
3587 /*******************************************************************
3588 inits a ALIAS_INFO3 structure.
3589 ********************************************************************/
3591 void init_samr_alias_info3(ALIAS_INFO3
* al3
, const char *acct_desc
)
3593 DEBUG(5, ("init_samr_alias_info3\n"));
3595 init_unistr4(&al3
->description
, acct_desc
, UNI_FLAGS_NONE
);
3598 /*******************************************************************
3599 reads or writes a structure.
3600 ********************************************************************/
3602 BOOL
samr_io_alias_info3(const char *desc
, ALIAS_INFO3
*al3
,
3603 prs_struct
*ps
, int depth
)
3608 prs_debug(ps
, depth
, desc
, "samr_io_alias_info3");
3614 if (!prs_unistr4("description", ps
, depth
, &al3
->description
))
3620 /*******************************************************************
3621 reads or writes a structure.
3622 ********************************************************************/
3624 BOOL
samr_io_alias_info2(const char *desc
, ALIAS_INFO2
*al2
,
3625 prs_struct
*ps
, int depth
)
3630 prs_debug(ps
, depth
, desc
, "samr_io_alias_info2");
3636 if (!prs_unistr4("name", ps
, depth
, &al2
->name
))
3642 /*******************************************************************
3643 reads or writes a structure.
3644 ********************************************************************/
3646 BOOL
samr_alias_info_ctr(const char *desc
, prs_struct
*ps
, int depth
, ALIAS_INFO_CTR
* ctr
)
3651 prs_debug(ps
, depth
, desc
, "samr_alias_info_ctr");
3654 if ( !prs_uint16("level", ps
, depth
, &ctr
->level
) )
3659 switch (ctr
->level
) {
3661 if(!samr_io_alias_info1("alias_info1", &ctr
->alias
.info1
, ps
, depth
))
3665 if(!samr_io_alias_info2("alias_info2", &ctr
->alias
.info2
, ps
, depth
))
3669 if(!samr_io_alias_info3("alias_info3", &ctr
->alias
.info3
, ps
, depth
))
3673 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3680 /*******************************************************************
3681 inits a SAMR_Q_QUERY_ALIASINFO structure.
3682 ********************************************************************/
3684 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO
* q_e
,
3685 POLICY_HND
*pol
, uint32 switch_level
)
3687 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3690 q_e
->level
= switch_level
;
3693 /*******************************************************************
3694 reads or writes a structure.
3695 ********************************************************************/
3697 BOOL
samr_io_q_query_aliasinfo(const char *desc
, SAMR_Q_QUERY_ALIASINFO
*in
,
3698 prs_struct
*ps
, int depth
)
3703 prs_debug(ps
, depth
, desc
, "samr_io_q_query_aliasinfo");
3709 if ( !smb_io_pol_hnd("pol", &(in
->pol
), ps
, depth
) )
3712 if ( !prs_uint16("level", ps
, depth
, &in
->level
) )
3718 /*******************************************************************
3719 inits a SAMR_R_QUERY_ALIASINFO structure.
3720 ********************************************************************/
3722 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO
*out
,
3723 ALIAS_INFO_CTR
* ctr
, NTSTATUS status
)
3725 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3728 out
->status
= status
;
3731 /*******************************************************************
3732 reads or writes a structure.
3733 ********************************************************************/
3735 BOOL
samr_io_r_query_aliasinfo(const char *desc
, SAMR_R_QUERY_ALIASINFO
*out
,
3736 prs_struct
*ps
, int depth
)
3741 prs_debug(ps
, depth
, desc
, "samr_io_r_query_aliasinfo");
3747 if ( !prs_pointer("alias", ps
, depth
, (void**)&out
->ctr
, sizeof(ALIAS_INFO_CTR
), (PRS_POINTER_CAST
)samr_alias_info_ctr
))
3752 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
3758 /*******************************************************************
3759 inits a SAMR_Q_SET_ALIASINFO structure.
3760 ********************************************************************/
3762 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO
* q_u
,
3763 POLICY_HND
*hnd
, ALIAS_INFO_CTR
* ctr
)
3765 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3767 q_u
->alias_pol
= *hnd
;
3771 /*******************************************************************
3772 reads or writes a structure.
3773 ********************************************************************/
3775 BOOL
samr_io_q_set_aliasinfo(const char *desc
, SAMR_Q_SET_ALIASINFO
* q_u
,
3776 prs_struct
*ps
, int depth
)
3781 prs_debug(ps
, depth
, desc
, "samr_io_q_set_aliasinfo");
3787 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
3789 if(!samr_alias_info_ctr("ctr", ps
, depth
, &q_u
->ctr
))
3795 /*******************************************************************
3796 reads or writes a structure.
3797 ********************************************************************/
3799 BOOL
samr_io_r_set_aliasinfo(const char *desc
, SAMR_R_SET_ALIASINFO
* r_u
,
3800 prs_struct
*ps
, int depth
)
3805 prs_debug(ps
, depth
, desc
, "samr_io_r_set_aliasinfo");
3810 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3816 /*******************************************************************
3817 inits a SAMR_Q_QUERY_USERALIASES structure.
3818 ********************************************************************/
3820 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES
* q_u
,
3823 uint32
*ptr_sid
, DOM_SID2
* sid
)
3825 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3829 q_u
->num_sids1
= num_sids
;
3831 q_u
->num_sids2
= num_sids
;
3833 q_u
->ptr_sid
= ptr_sid
;
3837 /*******************************************************************
3838 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3839 ********************************************************************/
3841 BOOL
samr_io_q_query_useraliases(const char *desc
, SAMR_Q_QUERY_USERALIASES
* q_u
,
3842 prs_struct
*ps
, int depth
)
3850 prs_debug(ps
, depth
, desc
, "samr_io_q_query_useraliases");
3856 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
3859 if(!prs_uint32("num_sids1", ps
, depth
, &q_u
->num_sids1
))
3861 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
3867 if(!prs_uint32("num_sids2", ps
, depth
, &q_u
->num_sids2
))
3870 if (UNMARSHALLING(ps
) && (q_u
->num_sids2
!= 0)) {
3871 q_u
->ptr_sid
= PRS_ALLOC_MEM(ps
,uint32
,q_u
->num_sids2
);
3872 if (q_u
->ptr_sid
== NULL
)
3875 q_u
->sid
= PRS_ALLOC_MEM(ps
, DOM_SID2
, q_u
->num_sids2
);
3876 if (q_u
->sid
== NULL
)
3880 for (i
= 0; i
< q_u
->num_sids2
; i
++) {
3881 slprintf(tmp
, sizeof(tmp
) - 1, "ptr[%02d]", i
);
3882 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->ptr_sid
[i
]))
3886 for (i
= 0; i
< q_u
->num_sids2
; i
++) {
3887 if (q_u
->ptr_sid
[i
] != 0) {
3888 slprintf(tmp
, sizeof(tmp
) - 1, "sid[%02d]", i
);
3889 if(!smb_io_dom_sid2(tmp
, &q_u
->sid
[i
], ps
, depth
))
3897 /*******************************************************************
3898 inits a SAMR_R_QUERY_USERALIASES structure.
3899 ********************************************************************/
3901 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES
* r_u
,
3902 uint32 num_rids
, uint32
*rid
,
3905 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3907 if (NT_STATUS_IS_OK(status
)) {
3908 r_u
->num_entries
= num_rids
;
3910 r_u
->num_entries2
= num_rids
;
3914 r_u
->num_entries
= 0;
3916 r_u
->num_entries2
= 0;
3919 r_u
->status
= status
;
3922 /*******************************************************************
3923 reads or writes a structure.
3924 ********************************************************************/
3926 BOOL
samr_io_rids(const char *desc
, uint32
*num_rids
, uint32
**rid
,
3927 prs_struct
*ps
, int depth
)
3934 prs_debug(ps
, depth
, desc
, "samr_io_rids");
3940 if(!prs_uint32("num_rids", ps
, depth
, num_rids
))
3943 if ((*num_rids
) != 0) {
3944 if (UNMARSHALLING(ps
)) {
3946 (*rid
) = PRS_ALLOC_MEM(ps
,uint32
, *num_rids
);
3951 for (i
= 0; i
< (*num_rids
); i
++) {
3952 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d]", i
);
3953 if(!prs_uint32(tmp
, ps
, depth
, &((*rid
)[i
])))
3961 /*******************************************************************
3962 reads or writes a structure.
3963 ********************************************************************/
3965 BOOL
samr_io_r_query_useraliases(const char *desc
, SAMR_R_QUERY_USERALIASES
* r_u
,
3966 prs_struct
*ps
, int depth
)
3971 prs_debug(ps
, depth
, desc
, "samr_io_r_query_useraliases");
3977 if(!prs_uint32("num_entries", ps
, depth
, &r_u
->num_entries
))
3979 if(!prs_uint32("ptr ", ps
, depth
, &r_u
->ptr
))
3982 if (r_u
->ptr
!= 0) {
3983 if(!samr_io_rids("rids", &r_u
->num_entries2
, &r_u
->rid
, ps
, depth
))
3989 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3995 /*******************************************************************
3996 inits a SAMR_Q_OPEN_ALIAS structure.
3997 ********************************************************************/
3999 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS
* q_u
, POLICY_HND
*pol
,
4000 uint32 access_mask
, uint32 rid
)
4002 DEBUG(5, ("init_samr_q_open_alias\n"));
4004 q_u
->dom_pol
= *pol
;
4005 q_u
->access_mask
= access_mask
;
4006 q_u
->rid_alias
= rid
;
4009 /*******************************************************************
4010 reads or writes a structure.
4011 ********************************************************************/
4013 BOOL
samr_io_q_open_alias(const char *desc
, SAMR_Q_OPEN_ALIAS
* q_u
,
4014 prs_struct
*ps
, int depth
)
4019 prs_debug(ps
, depth
, desc
, "samr_io_q_open_alias");
4025 if(!smb_io_pol_hnd("domain_pol", &q_u
->dom_pol
, ps
, depth
))
4028 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
4030 if(!prs_uint32("rid_alias", ps
, depth
, &q_u
->rid_alias
))
4036 /*******************************************************************
4037 reads or writes a structure.
4038 ********************************************************************/
4040 BOOL
samr_io_r_open_alias(const char *desc
, SAMR_R_OPEN_ALIAS
* r_u
,
4041 prs_struct
*ps
, int depth
)
4046 prs_debug(ps
, depth
, desc
, "samr_io_r_open_alias");
4052 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4055 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4061 /*******************************************************************
4062 inits a SAMR_Q_LOOKUP_RIDS structure.
4063 ********************************************************************/
4065 void init_samr_q_lookup_rids(TALLOC_CTX
*ctx
, SAMR_Q_LOOKUP_RIDS
* q_u
,
4066 POLICY_HND
*pol
, uint32 flags
,
4067 uint32 num_rids
, uint32
*rid
)
4069 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4073 q_u
->num_rids1
= num_rids
;
4076 q_u
->num_rids2
= num_rids
;
4077 q_u
->rid
= TALLOC_ZERO_ARRAY(ctx
, uint32
, num_rids
);
4078 if (q_u
->rid
== NULL
) {
4082 memcpy(q_u
->rid
, rid
, num_rids
* sizeof(q_u
->rid
[0]));
4086 /*******************************************************************
4087 reads or writes a structure.
4088 ********************************************************************/
4090 BOOL
samr_io_q_lookup_rids(const char *desc
, SAMR_Q_LOOKUP_RIDS
* q_u
,
4091 prs_struct
*ps
, int depth
)
4099 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_rids");
4102 if (UNMARSHALLING(ps
))
4108 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
4111 if(!prs_uint32("num_rids1", ps
, depth
, &q_u
->num_rids1
))
4113 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
4115 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
4117 if(!prs_uint32("num_rids2", ps
, depth
, &q_u
->num_rids2
))
4120 if (UNMARSHALLING(ps
) && (q_u
->num_rids2
!= 0)) {
4121 q_u
->rid
= PRS_ALLOC_MEM(ps
, uint32
, q_u
->num_rids2
);
4122 if (q_u
->rid
== NULL
)
4126 for (i
= 0; i
< q_u
->num_rids2
; i
++) {
4127 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
4128 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->rid
[i
]))
4135 /*******************************************************************
4136 inits a SAMR_R_LOOKUP_RIDS structure.
4137 ********************************************************************/
4139 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS
* r_u
,
4140 uint32 num_names
, UNIHDR
* hdr_name
,
4141 UNISTR2
*uni_name
, uint32
*type
)
4143 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4145 r_u
->hdr_name
= NULL
;
4146 r_u
->uni_name
= NULL
;
4149 if (num_names
!= 0) {
4150 r_u
->num_names1
= num_names
;
4152 r_u
->num_names2
= num_names
;
4154 r_u
->num_types1
= num_names
;
4156 r_u
->num_types2
= num_names
;
4158 r_u
->hdr_name
= hdr_name
;
4159 r_u
->uni_name
= uni_name
;
4162 r_u
->num_names1
= num_names
;
4164 r_u
->num_names2
= num_names
;
4166 r_u
->num_types1
= num_names
;
4168 r_u
->num_types2
= num_names
;
4172 /*******************************************************************
4173 reads or writes a structure.
4174 ********************************************************************/
4176 BOOL
samr_io_r_lookup_rids(const char *desc
, SAMR_R_LOOKUP_RIDS
* r_u
,
4177 prs_struct
*ps
, int depth
)
4184 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_rids");
4190 if(!prs_uint32("num_names1", ps
, depth
, &r_u
->num_names1
))
4192 if(!prs_uint32("ptr_names ", ps
, depth
, &r_u
->ptr_names
))
4195 if (r_u
->ptr_names
!= 0) {
4197 if(!prs_uint32("num_names2", ps
, depth
, &r_u
->num_names2
))
4201 if (UNMARSHALLING(ps
) && (r_u
->num_names2
!= 0)) {
4202 r_u
->hdr_name
= PRS_ALLOC_MEM(ps
, UNIHDR
, r_u
->num_names2
);
4203 if (r_u
->hdr_name
== NULL
)
4206 r_u
->uni_name
= PRS_ALLOC_MEM(ps
, UNISTR2
, r_u
->num_names2
);
4207 if (r_u
->uni_name
== NULL
)
4211 for (i
= 0; i
< r_u
->num_names2
; i
++) {
4212 slprintf(tmp
, sizeof(tmp
) - 1, "hdr[%02d] ", i
);
4213 if(!smb_io_unihdr("", &r_u
->hdr_name
[i
], ps
, depth
))
4216 for (i
= 0; i
< r_u
->num_names2
; i
++) {
4217 slprintf(tmp
, sizeof(tmp
) - 1, "str[%02d] ", i
);
4218 if(!smb_io_unistr2("", &r_u
->uni_name
[i
], r_u
->hdr_name
[i
].buffer
, ps
, depth
))
4226 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
4228 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
4231 if (r_u
->ptr_types
!= 0) {
4233 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
4236 if (UNMARSHALLING(ps
) && (r_u
->num_types2
!= 0)) {
4237 r_u
->type
= PRS_ALLOC_MEM(ps
, uint32
, r_u
->num_types2
);
4238 if (r_u
->type
== NULL
)
4242 for (i
= 0; i
< r_u
->num_types2
; i
++) {
4243 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
4244 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->type
[i
]))
4249 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4255 /*******************************************************************
4256 inits a SAMR_Q_OPEN_ALIAS structure.
4257 ********************************************************************/
4259 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS
* q_u
, POLICY_HND
*hnd
)
4261 DEBUG(5, ("init_samr_q_delete_alias\n"));
4263 q_u
->alias_pol
= *hnd
;
4266 /*******************************************************************
4267 reads or writes a structure.
4268 ********************************************************************/
4270 BOOL
samr_io_q_delete_alias(const char *desc
, SAMR_Q_DELETE_DOM_ALIAS
* q_u
,
4271 prs_struct
*ps
, int depth
)
4276 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_alias");
4282 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4288 /*******************************************************************
4289 reads or writes a structure.
4290 ********************************************************************/
4292 BOOL
samr_io_r_delete_alias(const char *desc
, SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4293 prs_struct
*ps
, int depth
)
4298 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_alias");
4304 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4306 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4312 /*******************************************************************
4313 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4314 ********************************************************************/
4316 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS
* q_u
,
4317 POLICY_HND
*hnd
, const char *acct_desc
)
4319 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4321 q_u
->dom_pol
= *hnd
;
4323 init_unistr2(&q_u
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
4324 init_uni_hdr(&q_u
->hdr_acct_desc
, &q_u
->uni_acct_desc
);
4326 q_u
->access_mask
= MAXIMUM_ALLOWED_ACCESS
;
4329 /*******************************************************************
4330 reads or writes a structure.
4331 ********************************************************************/
4333 BOOL
samr_io_q_create_dom_alias(const char *desc
, SAMR_Q_CREATE_DOM_ALIAS
* q_u
,
4334 prs_struct
*ps
, int depth
)
4339 prs_debug(ps
, depth
, desc
, "samr_io_q_create_dom_alias");
4345 if(!smb_io_pol_hnd("dom_pol", &q_u
->dom_pol
, ps
, depth
))
4348 if(!smb_io_unihdr("hdr_acct_desc", &q_u
->hdr_acct_desc
, ps
, depth
))
4350 if(!smb_io_unistr2("uni_acct_desc", &q_u
->uni_acct_desc
,
4351 q_u
->hdr_acct_desc
.buffer
, ps
, depth
))
4356 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
4362 /*******************************************************************
4363 reads or writes a structure.
4364 ********************************************************************/
4366 BOOL
samr_io_r_create_dom_alias(const char *desc
, SAMR_R_CREATE_DOM_ALIAS
* r_u
,
4367 prs_struct
*ps
, int depth
)
4372 prs_debug(ps
, depth
, desc
, "samr_io_r_create_dom_alias");
4378 if(!smb_io_pol_hnd("alias_pol", &r_u
->alias_pol
, ps
, depth
))
4381 if(!prs_uint32("rid", ps
, depth
, &r_u
->rid
))
4384 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4390 /*******************************************************************
4391 inits a SAMR_Q_ADD_ALIASMEM structure.
4392 ********************************************************************/
4394 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM
* q_u
, POLICY_HND
*hnd
,
4397 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4399 q_u
->alias_pol
= *hnd
;
4400 init_dom_sid2(&q_u
->sid
, sid
);
4403 /*******************************************************************
4404 reads or writes a structure.
4405 ********************************************************************/
4407 BOOL
samr_io_q_add_aliasmem(const char *desc
, SAMR_Q_ADD_ALIASMEM
* q_u
,
4408 prs_struct
*ps
, int depth
)
4413 prs_debug(ps
, depth
, desc
, "samr_io_q_add_aliasmem");
4419 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4421 if(!smb_io_dom_sid2("sid ", &q_u
->sid
, ps
, depth
))
4427 /*******************************************************************
4428 reads or writes a structure.
4429 ********************************************************************/
4431 BOOL
samr_io_r_add_aliasmem(const char *desc
, SAMR_R_ADD_ALIASMEM
* r_u
,
4432 prs_struct
*ps
, int depth
)
4437 prs_debug(ps
, depth
, desc
, "samr_io_r_add_aliasmem");
4443 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4449 /*******************************************************************
4450 inits a SAMR_Q_DEL_ALIASMEM structure.
4451 ********************************************************************/
4453 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM
* q_u
, POLICY_HND
*hnd
,
4456 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4458 q_u
->alias_pol
= *hnd
;
4459 init_dom_sid2(&q_u
->sid
, sid
);
4462 /*******************************************************************
4463 reads or writes a structure.
4464 ********************************************************************/
4466 BOOL
samr_io_q_del_aliasmem(const char *desc
, SAMR_Q_DEL_ALIASMEM
* q_u
,
4467 prs_struct
*ps
, int depth
)
4472 prs_debug(ps
, depth
, desc
, "samr_io_q_del_aliasmem");
4478 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4480 if(!smb_io_dom_sid2("sid ", &q_u
->sid
, ps
, depth
))
4486 /*******************************************************************
4487 reads or writes a structure.
4488 ********************************************************************/
4490 BOOL
samr_io_r_del_aliasmem(const char *desc
, SAMR_R_DEL_ALIASMEM
* r_u
,
4491 prs_struct
*ps
, int depth
)
4496 prs_debug(ps
, depth
, desc
, "samr_io_r_del_aliasmem");
4502 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4508 /*******************************************************************
4509 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4510 ********************************************************************/
4512 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS
* q_c
,
4515 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4517 q_c
->alias_pol
= *hnd
;
4520 /*******************************************************************
4521 reads or writes a structure.
4522 ********************************************************************/
4524 BOOL
samr_io_q_delete_dom_alias(const char *desc
, SAMR_Q_DELETE_DOM_ALIAS
* q_u
,
4525 prs_struct
*ps
, int depth
)
4530 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_alias");
4536 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4542 /*******************************************************************
4543 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4544 ********************************************************************/
4546 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4549 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4551 r_u
->status
= status
;
4554 /*******************************************************************
4555 reads or writes a structure.
4556 ********************************************************************/
4558 BOOL
samr_io_r_delete_dom_alias(const char *desc
, SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4559 prs_struct
*ps
, int depth
)
4564 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_alias");
4570 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4573 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4579 /*******************************************************************
4580 inits a SAMR_Q_QUERY_ALIASMEM structure.
4581 ********************************************************************/
4583 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM
* q_c
,
4586 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4588 q_c
->alias_pol
= *hnd
;
4591 /*******************************************************************
4592 reads or writes a structure.
4593 ********************************************************************/
4595 BOOL
samr_io_q_query_aliasmem(const char *desc
, SAMR_Q_QUERY_ALIASMEM
* q_u
,
4596 prs_struct
*ps
, int depth
)
4601 prs_debug(ps
, depth
, desc
, "samr_io_q_query_aliasmem");
4607 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4613 /*******************************************************************
4614 inits a SAMR_R_QUERY_ALIASMEM structure.
4615 ********************************************************************/
4617 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM
* r_u
,
4618 uint32 num_sids
, DOM_SID2
* sid
,
4621 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4623 if (NT_STATUS_IS_OK(status
)) {
4624 r_u
->num_sids
= num_sids
;
4625 r_u
->ptr
= (num_sids
!= 0) ? 1 : 0;
4626 r_u
->num_sids1
= num_sids
;
4634 r_u
->status
= status
;
4637 /*******************************************************************
4638 reads or writes a structure.
4639 ********************************************************************/
4641 BOOL
samr_io_r_query_aliasmem(const char *desc
, SAMR_R_QUERY_ALIASMEM
* r_u
,
4642 prs_struct
*ps
, int depth
)
4649 prs_debug(ps
, depth
, desc
, "samr_io_r_query_aliasmem");
4655 if(!prs_uint32("num_sids ", ps
, depth
, &r_u
->num_sids
))
4657 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
4660 if (r_u
->ptr
!= 0 && r_u
->num_sids
!= 0) {
4661 uint32
*ptr_sid
= NULL
;
4663 if(!prs_uint32("num_sids1", ps
, depth
, &r_u
->num_sids1
))
4666 ptr_sid
= TALLOC_ARRAY(ps
->mem_ctx
, uint32
, r_u
->num_sids1
);
4671 for (i
= 0; i
< r_u
->num_sids1
; i
++) {
4673 if(!prs_uint32("ptr_sid", ps
, depth
, &ptr_sid
[i
]))
4677 if (UNMARSHALLING(ps
)) {
4678 r_u
->sid
= TALLOC_ARRAY(ps
->mem_ctx
, DOM_SID2
, r_u
->num_sids1
);
4681 for (i
= 0; i
< r_u
->num_sids1
; i
++) {
4682 if (ptr_sid
[i
] != 0) {
4683 if(!smb_io_dom_sid2("sid", &r_u
->sid
[i
], ps
, depth
))
4691 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4697 /*******************************************************************
4698 inits a SAMR_Q_LOOKUP_NAMES structure.
4699 ********************************************************************/
4701 NTSTATUS
init_samr_q_lookup_names(TALLOC_CTX
*ctx
, SAMR_Q_LOOKUP_NAMES
* q_u
,
4702 POLICY_HND
*pol
, uint32 flags
,
4703 uint32 num_names
, const char **name
)
4707 DEBUG(5, ("init_samr_q_lookup_names\n"));
4711 q_u
->num_names1
= num_names
;
4714 q_u
->num_names2
= num_names
;
4716 if (!(q_u
->hdr_name
= TALLOC_ZERO_ARRAY(ctx
, UNIHDR
, num_names
)))
4717 return NT_STATUS_NO_MEMORY
;
4719 if (!(q_u
->uni_name
= TALLOC_ZERO_ARRAY(ctx
, UNISTR2
, num_names
)))
4720 return NT_STATUS_NO_MEMORY
;
4722 for (i
= 0; i
< num_names
; i
++) {
4723 init_unistr2(&q_u
->uni_name
[i
], name
[i
], UNI_FLAGS_NONE
); /* unicode string for machine account */
4724 init_uni_hdr(&q_u
->hdr_name
[i
], &q_u
->uni_name
[i
]); /* unicode header for user_name */
4727 return NT_STATUS_OK
;
4730 /*******************************************************************
4731 reads or writes a structure.
4732 ********************************************************************/
4734 BOOL
samr_io_q_lookup_names(const char *desc
, SAMR_Q_LOOKUP_NAMES
* q_u
,
4735 prs_struct
*ps
, int depth
)
4742 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_names");
4745 if (UNMARSHALLING(ps
))
4751 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
4754 if(!prs_uint32("num_names1", ps
, depth
, &q_u
->num_names1
))
4756 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
4758 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
4760 if(!prs_uint32("num_names2", ps
, depth
, &q_u
->num_names2
))
4763 if (UNMARSHALLING(ps
) && (q_u
->num_names2
!= 0)) {
4764 q_u
->hdr_name
= PRS_ALLOC_MEM(ps
, UNIHDR
, q_u
->num_names2
);
4765 q_u
->uni_name
= PRS_ALLOC_MEM(ps
, UNISTR2
, q_u
->num_names2
);
4766 if (!q_u
->hdr_name
|| !q_u
->uni_name
)
4770 for (i
= 0; i
< q_u
->num_names2
; i
++) {
4771 if(!smb_io_unihdr("", &q_u
->hdr_name
[i
], ps
, depth
))
4775 for (i
= 0; i
< q_u
->num_names2
; i
++) {
4776 if(!smb_io_unistr2("", &q_u
->uni_name
[i
], q_u
->hdr_name
[i
].buffer
, ps
, depth
))
4783 /*******************************************************************
4784 inits a SAMR_R_LOOKUP_NAMES structure.
4785 ********************************************************************/
4787 NTSTATUS
init_samr_r_lookup_names(TALLOC_CTX
*ctx
, SAMR_R_LOOKUP_NAMES
* r_u
,
4789 uint32
*rid
, uint32
*type
,
4792 DEBUG(5, ("init_samr_r_lookup_names\n"));
4794 if (NT_STATUS_IS_OK(status
) && (num_rids
!= 0)) {
4797 r_u
->num_types1
= num_rids
;
4799 r_u
->num_types2
= num_rids
;
4801 r_u
->num_rids1
= num_rids
;
4803 r_u
->num_rids2
= num_rids
;
4805 if (!(r_u
->rids
= TALLOC_ZERO_ARRAY(ctx
, uint32
, num_rids
)))
4806 return NT_STATUS_NO_MEMORY
;
4807 if (!(r_u
->types
= TALLOC_ZERO_ARRAY(ctx
, uint32
, num_rids
)))
4808 return NT_STATUS_NO_MEMORY
;
4810 if (!r_u
->rids
|| !r_u
->types
)
4813 for (i
= 0; i
< num_rids
; i
++) {
4814 r_u
->rids
[i
] = rid
[i
];
4815 r_u
->types
[i
] = type
[i
];
4820 r_u
->num_types1
= 0;
4822 r_u
->num_types2
= 0;
4832 r_u
->status
= status
;
4834 return NT_STATUS_OK
;
4837 /*******************************************************************
4838 reads or writes a structure.
4839 ********************************************************************/
4841 BOOL
samr_io_r_lookup_names(const char *desc
, SAMR_R_LOOKUP_NAMES
* r_u
,
4842 prs_struct
*ps
, int depth
)
4850 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_names");
4853 if (UNMARSHALLING(ps
))
4859 if(!prs_uint32("num_rids1", ps
, depth
, &r_u
->num_rids1
))
4861 if(!prs_uint32("ptr_rids ", ps
, depth
, &r_u
->ptr_rids
))
4864 if (r_u
->ptr_rids
!= 0) {
4865 if(!prs_uint32("num_rids2", ps
, depth
, &r_u
->num_rids2
))
4868 if (r_u
->num_rids2
!= r_u
->num_rids1
) {
4873 if (UNMARSHALLING(ps
))
4874 r_u
->rids
= PRS_ALLOC_MEM(ps
, uint32
, r_u
->num_rids2
);
4877 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4881 for (i
= 0; i
< r_u
->num_rids2
; i
++) {
4882 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
4883 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->rids
[i
]))
4888 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
4890 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
4893 if (r_u
->ptr_types
!= 0) {
4894 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
4897 if (r_u
->num_types2
!= r_u
->num_types1
) {
4902 if (UNMARSHALLING(ps
))
4903 r_u
->types
= PRS_ALLOC_MEM(ps
, uint32
, r_u
->num_types2
);
4906 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4910 for (i
= 0; i
< r_u
->num_types2
; i
++) {
4911 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
4912 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->types
[i
]))
4917 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4923 /*******************************************************************
4924 inits a SAMR_Q_DELETE_DOM_USER structure.
4925 ********************************************************************/
4927 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER
* q_c
,
4930 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4932 q_c
->user_pol
= *hnd
;
4935 /*******************************************************************
4936 reads or writes a structure.
4937 ********************************************************************/
4939 BOOL
samr_io_q_delete_dom_user(const char *desc
, SAMR_Q_DELETE_DOM_USER
* q_u
,
4940 prs_struct
*ps
, int depth
)
4945 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_user");
4951 if(!smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
))
4957 /*******************************************************************
4958 reads or writes a structure.
4959 ********************************************************************/
4961 BOOL
samr_io_r_delete_dom_user(const char *desc
, SAMR_R_DELETE_DOM_USER
* r_u
,
4962 prs_struct
*ps
, int depth
)
4967 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_user");
4973 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4975 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4981 /*******************************************************************
4982 reads or writes a structure.
4983 ********************************************************************/
4985 void init_samr_q_open_user(SAMR_Q_OPEN_USER
* q_u
,
4987 uint32 access_mask
, uint32 rid
)
4989 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4991 q_u
->domain_pol
= *pol
;
4992 q_u
->access_mask
= access_mask
;
4993 q_u
->user_rid
= rid
;
4996 /*******************************************************************
4997 reads or writes a structure.
4998 ********************************************************************/
5000 BOOL
samr_io_q_open_user(const char *desc
, SAMR_Q_OPEN_USER
* q_u
,
5001 prs_struct
*ps
, int depth
)
5006 prs_debug(ps
, depth
, desc
, "samr_io_q_open_user");
5012 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
5015 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
5017 if(!prs_uint32("user_rid ", ps
, depth
, &q_u
->user_rid
))
5023 /*******************************************************************
5024 reads or writes a structure.
5025 ********************************************************************/
5027 BOOL
samr_io_r_open_user(const char *desc
, SAMR_R_OPEN_USER
* r_u
,
5028 prs_struct
*ps
, int depth
)
5033 prs_debug(ps
, depth
, desc
, "samr_io_r_open_user");
5039 if(!smb_io_pol_hnd("user_pol", &r_u
->user_pol
, ps
, depth
))
5042 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
5049 /*******************************************************************
5050 reads or writes a structure.
5051 ********************************************************************/
5053 void init_samr_q_create_user(SAMR_Q_CREATE_USER
* q_u
,
5056 uint32 acb_info
, uint32 access_mask
)
5058 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5060 q_u
->domain_pol
= *pol
;
5062 init_unistr2(&q_u
->uni_name
, name
, UNI_FLAGS_NONE
);
5063 init_uni_hdr(&q_u
->hdr_name
, &q_u
->uni_name
);
5065 q_u
->acb_info
= acb_info
;
5066 q_u
->access_mask
= access_mask
;
5069 /*******************************************************************
5070 reads or writes a structure.
5071 ********************************************************************/
5073 BOOL
samr_io_q_create_user(const char *desc
, SAMR_Q_CREATE_USER
* q_u
,
5074 prs_struct
*ps
, int depth
)
5079 prs_debug(ps
, depth
, desc
, "samr_io_q_create_user");
5085 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
5088 if(!smb_io_unihdr("hdr_name", &q_u
->hdr_name
, ps
, depth
))
5090 if(!smb_io_unistr2("uni_name", &q_u
->uni_name
, q_u
->hdr_name
.buffer
, ps
, depth
))
5095 if(!prs_uint32("acb_info ", ps
, depth
, &q_u
->acb_info
))
5097 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
5103 /*******************************************************************
5104 reads or writes a structure.
5105 ********************************************************************/
5107 BOOL
samr_io_r_create_user(const char *desc
, SAMR_R_CREATE_USER
* r_u
,
5108 prs_struct
*ps
, int depth
)
5113 prs_debug(ps
, depth
, desc
, "samr_io_r_create_user");
5119 if(!smb_io_pol_hnd("user_pol", &r_u
->user_pol
, ps
, depth
))
5122 if(!prs_uint32("access_granted", ps
, depth
, &r_u
->access_granted
))
5124 if(!prs_uint32("user_rid ", ps
, depth
, &r_u
->user_rid
))
5126 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
5132 /*******************************************************************
5133 inits a SAMR_Q_QUERY_USERINFO structure.
5134 ********************************************************************/
5136 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO
* q_u
,
5137 const POLICY_HND
*hnd
, uint16 switch_value
)
5139 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5142 q_u
->switch_value
= switch_value
;
5145 /*******************************************************************
5146 reads or writes a structure.
5147 ********************************************************************/
5149 BOOL
samr_io_q_query_userinfo(const char *desc
, SAMR_Q_QUERY_USERINFO
* q_u
,
5150 prs_struct
*ps
, int depth
)
5155 prs_debug(ps
, depth
, desc
, "samr_io_q_query_userinfo");
5161 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
5164 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
)) /* 0x0015 or 0x0011 */
5170 /*******************************************************************
5171 reads or writes a LOGON_HRS structure.
5172 ********************************************************************/
5174 static BOOL
sam_io_logon_hrs(const char *desc
, LOGON_HRS
* hrs
,
5175 prs_struct
*ps
, int depth
)
5180 prs_debug(ps
, depth
, desc
, "sam_io_logon_hrs");
5186 if(!prs_uint32("maxlen", ps
, depth
, &hrs
->max_len
))
5189 if(!prs_uint32("offset", ps
, depth
, &hrs
->offset
))
5192 if(!prs_uint32("len ", ps
, depth
, &hrs
->len
))
5195 if (hrs
->len
> sizeof(hrs
->hours
)) {
5196 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs
->len
));
5197 hrs
->len
= sizeof(hrs
->hours
);
5200 if(!prs_uint8s(False
, "hours", ps
, depth
, hrs
->hours
, hrs
->len
))
5206 /*******************************************************************
5207 inits a SAM_USER_INFO_18 structure.
5208 ********************************************************************/
5210 void init_sam_user_info18(SAM_USER_INFO_18
* usr
,
5211 const uint8 lm_pwd
[16], const uint8 nt_pwd
[16])
5213 DEBUG(5, ("init_sam_user_info18\n"));
5215 usr
->lm_pwd_active
=
5216 memcpy(usr
->lm_pwd
, lm_pwd
, sizeof(usr
->lm_pwd
)) ? 1 : 0;
5217 usr
->nt_pwd_active
=
5218 memcpy(usr
->nt_pwd
, nt_pwd
, sizeof(usr
->nt_pwd
)) ? 1 : 0;
5221 /*******************************************************************
5222 reads or writes a structure.
5223 ********************************************************************/
5225 static BOOL
sam_io_user_info18(const char *desc
, SAM_USER_INFO_18
* u
,
5226 prs_struct
*ps
, int depth
)
5231 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info18");
5237 if(!prs_uint8s(False
, "lm_pwd", ps
, depth
, u
->lm_pwd
, sizeof(u
->lm_pwd
)))
5239 if(!prs_uint8s(False
, "nt_pwd", ps
, depth
, u
->nt_pwd
, sizeof(u
->nt_pwd
)))
5242 if(!prs_uint8("lm_pwd_active", ps
, depth
, &u
->lm_pwd_active
))
5244 if(!prs_uint8("nt_pwd_active", ps
, depth
, &u
->nt_pwd_active
))
5250 /*******************************************************************
5251 inits a SAM_USER_INFO_7 structure.
5252 ********************************************************************/
5254 void init_sam_user_info7(SAM_USER_INFO_7
* usr
, const char *name
)
5256 DEBUG(5, ("init_sam_user_info7\n"));
5258 init_unistr2(&usr
->uni_name
, name
, UNI_FLAGS_NONE
); /* unicode string for name */
5259 init_uni_hdr(&usr
->hdr_name
, &usr
->uni_name
); /* unicode header for name */
5263 /*******************************************************************
5264 reads or writes a structure.
5265 ********************************************************************/
5267 static BOOL
sam_io_user_info7(const char *desc
, SAM_USER_INFO_7
* usr
,
5268 prs_struct
*ps
, int depth
)
5273 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info7");
5279 if(!smb_io_unihdr("unihdr", &usr
->hdr_name
, ps
, depth
))
5282 if(!smb_io_unistr2("unistr2", &usr
->uni_name
, True
, ps
, depth
))
5288 /*******************************************************************
5289 inits a SAM_USER_INFO_9 structure.
5290 ********************************************************************/
5292 void init_sam_user_info9(SAM_USER_INFO_9
* usr
, uint32 rid_group
)
5294 DEBUG(5, ("init_sam_user_info9\n"));
5296 usr
->rid_group
= rid_group
;
5299 /*******************************************************************
5300 reads or writes a structure.
5301 ********************************************************************/
5303 static BOOL
sam_io_user_info9(const char *desc
, SAM_USER_INFO_9
* usr
,
5304 prs_struct
*ps
, int depth
)
5309 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info9");
5315 if(!prs_uint32("rid_group", ps
, depth
, &usr
->rid_group
))
5321 /*******************************************************************
5322 inits a SAM_USER_INFO_16 structure.
5323 ********************************************************************/
5325 void init_sam_user_info16(SAM_USER_INFO_16
* usr
, uint32 acb_info
)
5327 DEBUG(5, ("init_sam_user_info16\n"));
5329 usr
->acb_info
= acb_info
;
5332 /*******************************************************************
5333 reads or writes a structure.
5334 ********************************************************************/
5336 static BOOL
sam_io_user_info16(const char *desc
, SAM_USER_INFO_16
* usr
,
5337 prs_struct
*ps
, int depth
)
5342 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info16");
5348 if(!prs_uint32("acb_info", ps
, depth
, &usr
->acb_info
))
5354 /*******************************************************************
5355 inits a SAM_USER_INFO_17 structure.
5356 ********************************************************************/
5358 void init_sam_user_info17(SAM_USER_INFO_17
* usr
,
5361 uint32 rid_user
, uint32 rid_group
, uint16 acct_ctrl
)
5363 DEBUG(5, ("init_sam_user_info17\n"));
5365 memcpy(&usr
->expiry
, expiry
, sizeof(usr
->expiry
)); /* expiry time or something? */
5366 ZERO_STRUCT(usr
->padding_1
); /* 0 - padding 24 bytes */
5368 usr
->padding_2
= 0; /* 0 - padding 4 bytes */
5370 usr
->ptr_1
= 1; /* pointer */
5371 ZERO_STRUCT(usr
->padding_3
); /* 0 - padding 32 bytes */
5372 usr
->padding_4
= 0; /* 0 - padding 4 bytes */
5374 usr
->ptr_2
= 1; /* pointer */
5375 usr
->padding_5
= 0; /* 0 - padding 4 bytes */
5377 usr
->ptr_3
= 1; /* pointer */
5378 ZERO_STRUCT(usr
->padding_6
); /* 0 - padding 32 bytes */
5380 usr
->rid_user
= rid_user
;
5381 usr
->rid_group
= rid_group
;
5383 usr
->acct_ctrl
= acct_ctrl
;
5384 usr
->unknown_3
= 0x0000;
5386 usr
->unknown_4
= 0x003f; /* 0x003f - 16 bit unknown */
5387 usr
->unknown_5
= 0x003c; /* 0x003c - 16 bit unknown */
5389 ZERO_STRUCT(usr
->padding_7
); /* 0 - padding 16 bytes */
5390 usr
->padding_8
= 0; /* 0 - padding 4 bytes */
5392 init_unistr2(&usr
->uni_mach_acct
, mach_acct
, UNI_FLAGS_NONE
); /* unicode string for machine account */
5393 init_uni_hdr(&usr
->hdr_mach_acct
, &usr
->uni_mach_acct
); /* unicode header for machine account */
5396 /*******************************************************************
5397 reads or writes a structure.
5398 ********************************************************************/
5400 static BOOL
sam_io_user_info17(const char *desc
, SAM_USER_INFO_17
* usr
,
5401 prs_struct
*ps
, int depth
)
5406 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_17");
5412 if(!prs_uint8s(False
, "padding_0", ps
, depth
, usr
->padding_0
, sizeof(usr
->padding_0
)))
5415 if(!smb_io_time("time", &usr
->expiry
, ps
, depth
))
5418 if(!prs_uint8s(False
, "padding_1", ps
, depth
, usr
->padding_1
, sizeof(usr
->padding_1
)))
5421 if(!smb_io_unihdr("unihdr", &usr
->hdr_mach_acct
, ps
, depth
))
5424 if(!prs_uint32("padding_2", ps
, depth
, &usr
->padding_2
))
5427 if(!prs_uint32("ptr_1 ", ps
, depth
, &usr
->ptr_1
))
5429 if(!prs_uint8s(False
, "padding_3", ps
, depth
, usr
->padding_3
, sizeof(usr
->padding_3
)))
5432 if(!prs_uint32("padding_4", ps
, depth
, &usr
->padding_4
))
5435 if(!prs_uint32("ptr_2 ", ps
, depth
, &usr
->ptr_2
))
5437 if(!prs_uint32("padding_5", ps
, depth
, &usr
->padding_5
))
5440 if(!prs_uint32("ptr_3 ", ps
, depth
, &usr
->ptr_3
))
5442 if(!prs_uint8s(False
, "padding_6", ps
, depth
, usr
->padding_6
,sizeof(usr
->padding_6
)))
5445 if(!prs_uint32("rid_user ", ps
, depth
, &usr
->rid_user
))
5447 if(!prs_uint32("rid_group", ps
, depth
, &usr
->rid_group
))
5449 if(!prs_uint16("acct_ctrl", ps
, depth
, &usr
->acct_ctrl
))
5451 if(!prs_uint16("unknown_3", ps
, depth
, &usr
->unknown_3
))
5453 if(!prs_uint16("unknown_4", ps
, depth
, &usr
->unknown_4
))
5455 if(!prs_uint16("unknown_5", ps
, depth
, &usr
->unknown_5
))
5458 if(!prs_uint8s(False
, "padding_7", ps
, depth
, usr
->padding_7
, sizeof(usr
->padding_7
)))
5461 if(!prs_uint32("padding_8", ps
, depth
, &(usr
->padding_8
)))
5464 if(!smb_io_unistr2("unistr2", &usr
->uni_mach_acct
, True
, ps
, depth
))
5470 if(!prs_uint8s(False
, "padding_9", ps
, depth
, usr
->padding_9
, sizeof(usr
->padding_9
)))
5476 /*************************************************************************
5478 *************************************************************************/
5480 void init_sam_user_info24(SAM_USER_INFO_24
* usr
, char newpass
[516], uint16 pw_len
)
5482 DEBUG(10, ("init_sam_user_info24:\n"));
5483 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5484 usr
->pw_len
= pw_len
;
5487 /*******************************************************************
5488 reads or writes a structure.
5489 ********************************************************************/
5491 static BOOL
sam_io_user_info24(const char *desc
, SAM_USER_INFO_24
* usr
,
5492 prs_struct
*ps
, int depth
)
5497 prs_debug(ps
, depth
, desc
, "sam_io_user_info24");
5503 if(!prs_uint8s(False
, "password", ps
, depth
, usr
->pass
,
5507 if (MARSHALLING(ps
) && (usr
->pw_len
!= 0)) {
5508 if (!prs_uint16("pw_len", ps
, depth
, &usr
->pw_len
))
5510 } else if (UNMARSHALLING(ps
)) {
5511 if (!prs_uint16("pw_len", ps
, depth
, &usr
->pw_len
))
5518 /*******************************************************************
5519 reads or writes a structure.
5520 ********************************************************************/
5522 static BOOL
sam_io_user_info26(const char *desc
, SAM_USER_INFO_26
* usr
,
5523 prs_struct
*ps
, int depth
)
5528 prs_debug(ps
, depth
, desc
, "sam_io_user_info26");
5534 if(!prs_uint8s(False
, "password", ps
, depth
, usr
->pass
,
5538 if (!prs_uint8("pw_len", ps
, depth
, &usr
->pw_len
))
5545 /*************************************************************************
5546 init_sam_user_info23
5548 unknown_6 = 0x0000 04ec
5550 *************************************************************************/
5552 void init_sam_user_info23W(SAM_USER_INFO_23
* usr
, NTTIME
* logon_time
, /* all zeros */
5553 NTTIME
* logoff_time
, /* all zeros */
5554 NTTIME
* kickoff_time
, /* all zeros */
5555 NTTIME
* pass_last_set_time
, /* all zeros */
5556 NTTIME
* pass_can_change_time
, /* all zeros */
5557 NTTIME
* pass_must_change_time
, /* all zeros */
5568 uint32 user_rid
, /* 0x0000 0000 */
5571 uint32 fields_present
,
5574 uint16 bad_password_count
,
5578 usr
->logon_time
= *logon_time
; /* all zeros */
5579 usr
->logoff_time
= *logoff_time
; /* all zeros */
5580 usr
->kickoff_time
= *kickoff_time
; /* all zeros */
5581 usr
->pass_last_set_time
= *pass_last_set_time
; /* all zeros */
5582 usr
->pass_can_change_time
= *pass_can_change_time
; /* all zeros */
5583 usr
->pass_must_change_time
= *pass_must_change_time
; /* all zeros */
5585 ZERO_STRUCT(usr
->nt_pwd
);
5586 ZERO_STRUCT(usr
->lm_pwd
);
5588 usr
->user_rid
= user_rid
; /* 0x0000 0000 */
5589 usr
->group_rid
= group_rid
;
5590 usr
->acb_info
= acb_info
;
5591 usr
->fields_present
= fields_present
; /* 09f8 27fa */
5593 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5594 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5596 if (nt_time_is_zero(pass_must_change_time
)) {
5597 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5599 usr
->passmustchange
=0;
5602 ZERO_STRUCT(usr
->padding1
);
5603 ZERO_STRUCT(usr
->padding2
);
5605 usr
->bad_password_count
= bad_password_count
;
5606 usr
->logon_count
= logon_count
;
5608 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5610 copy_unistr2(&usr
->uni_user_name
, user_name
);
5611 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
5613 copy_unistr2(&usr
->uni_full_name
, full_name
);
5614 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
5616 copy_unistr2(&usr
->uni_home_dir
, home_dir
);
5617 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
5619 copy_unistr2(&usr
->uni_dir_drive
, dir_drive
);
5620 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
5622 copy_unistr2(&usr
->uni_logon_script
, log_scr
);
5623 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
5625 copy_unistr2(&usr
->uni_profile_path
, prof_path
);
5626 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
5628 copy_unistr2(&usr
->uni_acct_desc
, desc
);
5629 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
5631 copy_unistr2(&usr
->uni_workstations
, wkstas
);
5632 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
5634 copy_unistr2(&usr
->uni_unknown_str
, unk_str
);
5635 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
5637 copy_unistr2(&usr
->uni_munged_dial
, mung_dial
);
5638 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
5641 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5643 ZERO_STRUCT(usr
->logon_hrs
);
5647 /*************************************************************************
5648 init_sam_user_info23
5650 unknown_6 = 0x0000 04ec
5652 *************************************************************************/
5654 void init_sam_user_info23A(SAM_USER_INFO_23
* usr
, NTTIME
* logon_time
, /* all zeros */
5655 NTTIME
* logoff_time
, /* all zeros */
5656 NTTIME
* kickoff_time
, /* all zeros */
5657 NTTIME
* pass_last_set_time
, /* all zeros */
5658 NTTIME
* pass_can_change_time
, /* all zeros */
5659 NTTIME
* pass_must_change_time
, /* all zeros */
5660 char *user_name
, /* NULL */
5662 char *home_dir
, char *dir_drive
, char *log_scr
,
5663 char *prof_path
, const char *desc
, char *wkstas
,
5664 char *unk_str
, char *mung_dial
, uint32 user_rid
, /* 0x0000 0000 */
5665 uint32 group_rid
, uint32 acb_info
,
5666 uint32 fields_present
, uint16 logon_divs
,
5667 LOGON_HRS
* hrs
, uint16 bad_password_count
, uint16 logon_count
,
5670 DATA_BLOB blob
= base64_decode_data_blob(mung_dial
);
5672 usr
->logon_time
= *logon_time
; /* all zeros */
5673 usr
->logoff_time
= *logoff_time
; /* all zeros */
5674 usr
->kickoff_time
= *kickoff_time
; /* all zeros */
5675 usr
->pass_last_set_time
= *pass_last_set_time
; /* all zeros */
5676 usr
->pass_can_change_time
= *pass_can_change_time
; /* all zeros */
5677 usr
->pass_must_change_time
= *pass_must_change_time
; /* all zeros */
5679 ZERO_STRUCT(usr
->nt_pwd
);
5680 ZERO_STRUCT(usr
->lm_pwd
);
5682 usr
->user_rid
= user_rid
; /* 0x0000 0000 */
5683 usr
->group_rid
= group_rid
;
5684 usr
->acb_info
= acb_info
;
5685 usr
->fields_present
= fields_present
; /* 09f8 27fa */
5687 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5688 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5690 if (nt_time_is_zero(pass_must_change_time
)) {
5691 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5693 usr
->passmustchange
=0;
5696 ZERO_STRUCT(usr
->padding1
);
5697 ZERO_STRUCT(usr
->padding2
);
5699 usr
->bad_password_count
= bad_password_count
;
5700 usr
->logon_count
= logon_count
;
5702 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5704 init_unistr2(&usr
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
5705 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
5707 init_unistr2(&usr
->uni_full_name
, full_name
, UNI_FLAGS_NONE
);
5708 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
5710 init_unistr2(&usr
->uni_home_dir
, home_dir
, UNI_FLAGS_NONE
);
5711 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
5713 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, UNI_FLAGS_NONE
);
5714 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
5716 init_unistr2(&usr
->uni_logon_script
, log_scr
, UNI_FLAGS_NONE
);
5717 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
5719 init_unistr2(&usr
->uni_profile_path
, prof_path
, UNI_FLAGS_NONE
);
5720 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
5722 init_unistr2(&usr
->uni_acct_desc
, desc
, UNI_FLAGS_NONE
);
5723 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
5725 init_unistr2(&usr
->uni_workstations
, wkstas
, UNI_FLAGS_NONE
);
5726 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
5728 init_unistr2(&usr
->uni_unknown_str
, unk_str
, UNI_FLAGS_NONE
);
5729 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
5731 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &blob
);
5732 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
5734 data_blob_free(&blob
);
5737 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5739 ZERO_STRUCT(usr
->logon_hrs
);
5743 /*******************************************************************
5744 reads or writes a structure.
5745 ********************************************************************/
5747 static BOOL
sam_io_user_info23(const char *desc
, SAM_USER_INFO_23
* usr
,
5748 prs_struct
*ps
, int depth
)
5753 prs_debug(ps
, depth
, desc
, "sam_io_user_info23");
5759 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
5761 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
5763 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
5765 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
5767 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
5769 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
5772 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
5774 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
5776 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
5778 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
5780 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
5782 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
5784 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
5786 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
5788 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
5790 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
5793 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
5795 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
5798 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
5800 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
5802 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
5805 if(!prs_uint32("fields_present ", ps
, depth
, &usr
->fields_present
))
5807 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
5811 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
5814 if(!prs_uint16("bad_password_count ", ps
, depth
, &usr
->bad_password_count
))
5816 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
))
5819 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
5821 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
5823 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
5827 if(!prs_uint8s(False
, "password ", ps
, depth
, usr
->pass
, sizeof(usr
->pass
)))
5830 /* here begins pointed-to data */
5832 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
5835 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
5838 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
5841 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
5844 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
5847 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
5850 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
5853 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
5856 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
5859 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
))
5862 /* ok, this is only guess-work (as usual) */
5863 if (usr
->ptr_logon_hrs
) {
5864 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
5871 /*******************************************************************
5872 reads or writes a structure.
5873 NB. This structure is *definately* incorrect. It's my best guess
5874 currently for W2K SP2. The password field is encrypted in a different
5875 way than normal... And there are definately other problems. JRA.
5876 ********************************************************************/
5878 static BOOL
sam_io_user_info25(const char *desc
, SAM_USER_INFO_25
* usr
, prs_struct
*ps
, int depth
)
5883 prs_debug(ps
, depth
, desc
, "sam_io_user_info25");
5889 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
5891 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
5893 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
5895 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
5897 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
5899 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
5902 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
5904 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
5906 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
5908 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
5910 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
5912 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
5914 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
5916 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
5918 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
5920 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
5923 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
5925 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
5928 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
5930 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
5932 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
5935 if(!prs_uint32s(False
, "unknown_6 ", ps
, depth
, usr
->unknown_6
, 6))
5938 if(!prs_uint8s(False
, "password ", ps
, depth
, usr
->pass
, sizeof(usr
->pass
)))
5941 /* here begins pointed-to data */
5943 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
5946 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
5949 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
5952 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
5955 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
5958 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
5961 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
5964 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
5967 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
5970 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
))
5973 #if 0 /* JRA - unknown... */
5974 /* ok, this is only guess-work (as usual) */
5975 if (usr
->ptr_logon_hrs
) {
5976 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
5985 /*************************************************************************
5986 init_sam_user_info21W
5988 unknown_6 = 0x0000 04ec
5990 *************************************************************************/
5992 void init_sam_user_info21W(SAM_USER_INFO_21
* usr
,
5993 NTTIME
* logon_time
,
5994 NTTIME
* logoff_time
,
5995 NTTIME
* kickoff_time
,
5996 NTTIME
* pass_last_set_time
,
5997 NTTIME
* pass_can_change_time
,
5998 NTTIME
* pass_must_change_time
,
6014 uint32 fields_present
,
6017 uint16 bad_password_count
,
6020 usr
->logon_time
= *logon_time
;
6021 usr
->logoff_time
= *logoff_time
;
6022 usr
->kickoff_time
= *kickoff_time
;
6023 usr
->pass_last_set_time
= *pass_last_set_time
;
6024 usr
->pass_can_change_time
= *pass_can_change_time
;
6025 usr
->pass_must_change_time
= *pass_must_change_time
;
6027 memcpy(usr
->lm_pwd
, lm_pwd
, sizeof(usr
->lm_pwd
));
6028 memcpy(usr
->nt_pwd
, nt_pwd
, sizeof(usr
->nt_pwd
));
6030 usr
->user_rid
= user_rid
;
6031 usr
->group_rid
= group_rid
;
6032 usr
->acb_info
= acb_info
;
6033 usr
->fields_present
= fields_present
; /* 0x00ff ffff */
6035 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
6036 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
6037 usr
->bad_password_count
= bad_password_count
;
6038 usr
->logon_count
= logon_count
;
6040 if (nt_time_is_zero(pass_must_change_time
)) {
6041 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
6043 usr
->passmustchange
=0;
6046 ZERO_STRUCT(usr
->padding1
);
6047 ZERO_STRUCT(usr
->padding2
);
6049 copy_unistr2(&usr
->uni_user_name
, user_name
);
6050 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
6052 copy_unistr2(&usr
->uni_full_name
, full_name
);
6053 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
6055 copy_unistr2(&usr
->uni_home_dir
, home_dir
);
6056 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
6058 copy_unistr2(&usr
->uni_dir_drive
, dir_drive
);
6059 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
6061 copy_unistr2(&usr
->uni_logon_script
, log_scr
);
6062 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
6064 copy_unistr2(&usr
->uni_profile_path
, prof_path
);
6065 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
6067 copy_unistr2(&usr
->uni_acct_desc
, desc
);
6068 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
6070 copy_unistr2(&usr
->uni_workstations
, wkstas
);
6071 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
6073 copy_unistr2(&usr
->uni_unknown_str
, unk_str
);
6074 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
6076 copy_unistr2(&usr
->uni_munged_dial
, mung_dial
);
6077 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
6080 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
6082 ZERO_STRUCT(usr
->logon_hrs
);
6086 /*************************************************************************
6087 init_sam_user_info21
6089 unknown_6 = 0x0000 04ec
6091 *************************************************************************/
6093 NTSTATUS
init_sam_user_info21A(SAM_USER_INFO_21
*usr
, struct samu
*pw
, DOM_SID
*domain_sid
)
6095 NTTIME logon_time
, logoff_time
, kickoff_time
,
6096 pass_last_set_time
, pass_can_change_time
,
6097 pass_must_change_time
;
6099 const char* user_name
= pdb_get_username(pw
);
6100 const char* full_name
= pdb_get_fullname(pw
);
6101 const char* home_dir
= pdb_get_homedir(pw
);
6102 const char* dir_drive
= pdb_get_dir_drive(pw
);
6103 const char* logon_script
= pdb_get_logon_script(pw
);
6104 const char* profile_path
= pdb_get_profile_path(pw
);
6105 const char* description
= pdb_get_acct_desc(pw
);
6106 const char* workstations
= pdb_get_workstations(pw
);
6107 const char* munged_dial
= pdb_get_munged_dial(pw
);
6108 DATA_BLOB munged_dial_blob
;
6111 const DOM_SID
*user_sid
;
6114 const DOM_SID
*group_sid
;
6117 munged_dial_blob
= base64_decode_data_blob(munged_dial
);
6119 munged_dial_blob
= data_blob(NULL
, 0);
6122 /* Create NTTIME structs */
6123 unix_to_nt_time (&logon_time
, pdb_get_logon_time(pw
));
6124 unix_to_nt_time (&logoff_time
, pdb_get_logoff_time(pw
));
6125 unix_to_nt_time (&kickoff_time
, pdb_get_kickoff_time(pw
));
6126 unix_to_nt_time (&pass_last_set_time
, pdb_get_pass_last_set_time(pw
));
6127 unix_to_nt_time (&pass_can_change_time
, pdb_get_pass_can_change_time(pw
));
6128 unix_to_nt_time (&pass_must_change_time
,pdb_get_pass_must_change_time(pw
));
6130 /* structure assignment */
6131 usr
->logon_time
= logon_time
;
6132 usr
->logoff_time
= logoff_time
;
6133 usr
->kickoff_time
= kickoff_time
;
6134 usr
->pass_last_set_time
= pass_last_set_time
;
6135 usr
->pass_can_change_time
= pass_can_change_time
;
6136 usr
->pass_must_change_time
= pass_must_change_time
;
6138 ZERO_STRUCT(usr
->nt_pwd
);
6139 ZERO_STRUCT(usr
->lm_pwd
);
6141 user_sid
= pdb_get_user_sid(pw
);
6143 if (!sid_peek_check_rid(domain_sid
, user_sid
, &user_rid
)) {
6144 fstring user_sid_string
;
6145 fstring domain_sid_string
;
6146 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6147 "the domain sid %s. Failing operation.\n",
6149 sid_to_string(user_sid_string
, user_sid
),
6150 sid_to_string(domain_sid_string
, domain_sid
)));
6151 data_blob_free(&munged_dial_blob
);
6152 return NT_STATUS_UNSUCCESSFUL
;
6155 group_sid
= pdb_get_group_sid(pw
);
6157 if (!sid_peek_check_rid(domain_sid
, group_sid
, &group_rid
)) {
6158 fstring group_sid_string
;
6159 fstring domain_sid_string
;
6160 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6161 "which conflicts with the domain sid %s. Failing operation.\n",
6163 sid_to_string(group_sid_string
, group_sid
),
6164 sid_to_string(domain_sid_string
, domain_sid
)));
6165 data_blob_free(&munged_dial_blob
);
6166 return NT_STATUS_UNSUCCESSFUL
;
6169 usr
->user_rid
= user_rid
;
6170 usr
->group_rid
= group_rid
;
6171 usr
->acb_info
= pdb_get_acct_ctrl(pw
);
6174 Look at a user on a real NT4 PDC with usrmgr, press
6175 'ok'. Then you will see that fields_present is set to
6176 0x08f827fa. Look at the user immediately after that again,
6177 and you will see that 0x00fffff is returned. This solves
6178 the problem that you get access denied after having looked
6182 usr
->fields_present
= pdb_build_fields_present(pw
);
6184 usr
->logon_divs
= pdb_get_logon_divs(pw
);
6185 usr
->ptr_logon_hrs
= pdb_get_hours(pw
) ? 1 : 0;
6186 usr
->bad_password_count
= pdb_get_bad_password_count(pw
);
6187 usr
->logon_count
= pdb_get_logon_count(pw
);
6189 if (pdb_get_pass_must_change_time(pw
) == 0) {
6190 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
6192 usr
->passmustchange
=0;
6195 ZERO_STRUCT(usr
->padding1
);
6196 ZERO_STRUCT(usr
->padding2
);
6198 init_unistr2(&usr
->uni_user_name
, user_name
, UNI_STR_TERMINATE
);
6199 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
6201 init_unistr2(&usr
->uni_full_name
, full_name
, UNI_STR_TERMINATE
);
6202 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
6204 init_unistr2(&usr
->uni_home_dir
, home_dir
, UNI_STR_TERMINATE
);
6205 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
6207 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, UNI_STR_TERMINATE
);
6208 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
6210 init_unistr2(&usr
->uni_logon_script
, logon_script
, UNI_STR_TERMINATE
);
6211 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
6213 init_unistr2(&usr
->uni_profile_path
, profile_path
, UNI_STR_TERMINATE
);
6214 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
6216 init_unistr2(&usr
->uni_acct_desc
, description
, UNI_STR_TERMINATE
);
6217 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
6219 init_unistr2(&usr
->uni_workstations
, workstations
, UNI_STR_TERMINATE
);
6220 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
6222 init_unistr2(&usr
->uni_unknown_str
, NULL
, UNI_STR_TERMINATE
);
6223 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
6225 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &munged_dial_blob
);
6226 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
6227 data_blob_free(&munged_dial_blob
);
6229 if (pdb_get_hours(pw
)) {
6230 usr
->logon_hrs
.max_len
= 1260;
6231 usr
->logon_hrs
.offset
= 0;
6232 usr
->logon_hrs
.len
= pdb_get_hours_len(pw
);
6233 memcpy(&usr
->logon_hrs
.hours
, pdb_get_hours(pw
), MAX_HOURS_LEN
);
6235 usr
->logon_hrs
.max_len
= 1260;
6236 usr
->logon_hrs
.offset
= 0;
6237 usr
->logon_hrs
.len
= 0;
6238 memset(&usr
->logon_hrs
, 0xff, sizeof(usr
->logon_hrs
));
6241 return NT_STATUS_OK
;
6244 /*******************************************************************
6245 reads or writes a structure.
6246 ********************************************************************/
6248 static BOOL
sam_io_user_info21(const char *desc
, SAM_USER_INFO_21
* usr
,
6249 prs_struct
*ps
, int depth
)
6254 prs_debug(ps
, depth
, desc
, "sam_io_user_info21");
6260 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
6262 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
6264 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
,depth
))
6266 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
6268 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
,depth
))
6270 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
6273 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
6275 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
6277 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
6279 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
6281 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
6283 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
6285 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
6287 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
6289 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
6291 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
6294 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
6296 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
6299 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
6301 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
6303 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
6306 if(!prs_uint32("fields_present ", ps
, depth
, &usr
->fields_present
))
6308 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
6312 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
6315 if(!prs_uint16("bad_password_count ", ps
, depth
, &usr
->bad_password_count
))
6317 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
))
6320 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
6322 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
6324 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
6327 /* here begins pointed-to data */
6329 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
,usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
6331 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
6333 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
6335 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
6337 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
6339 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
6341 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
6343 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
6345 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
6347 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
,usr
->hdr_munged_dial
.buffer
, ps
, depth
)) /* worksations user can log on from */
6350 /* ok, this is only guess-work (as usual) */
6351 if (usr
->ptr_logon_hrs
) {
6352 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
6359 void init_sam_user_info20A(SAM_USER_INFO_20
*usr
, struct samu
*pw
)
6361 const char *munged_dial
= pdb_get_munged_dial(pw
);
6362 DATA_BLOB blob
= base64_decode_data_blob(munged_dial
);
6364 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &blob
);
6365 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
6366 data_blob_free(&blob
);
6369 /*******************************************************************
6370 reads or writes a structure.
6371 ********************************************************************/
6373 static BOOL
sam_io_user_info20(const char *desc
, SAM_USER_INFO_20
*usr
,
6374 prs_struct
*ps
, int depth
)
6379 prs_debug(ps
, depth
, desc
, "sam_io_user_info20");
6385 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
6388 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
,usr
->hdr_munged_dial
.buffer
, ps
, depth
)) /* worksations user can log on from */
6394 /*******************************************************************
6395 inits a SAM_USERINFO_CTR structure.
6396 ********************************************************************/
6398 NTSTATUS
make_samr_userinfo_ctr_usr21(TALLOC_CTX
*ctx
, SAM_USERINFO_CTR
* ctr
,
6399 uint16 switch_value
,
6400 SAM_USER_INFO_21
* usr
)
6402 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6404 ctr
->switch_value
= switch_value
;
6405 ctr
->info
.id
= NULL
;
6407 switch (switch_value
) {
6409 ctr
->info
.id16
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_16
);
6410 if (ctr
->info
.id16
== NULL
)
6411 return NT_STATUS_NO_MEMORY
;
6413 init_sam_user_info16(ctr
->info
.id16
, usr
->acb_info
);
6416 /* whoops - got this wrong. i think. or don't understand what's happening. */
6420 info
= (void *)&id11
;
6422 expire
.low
= 0xffffffff;
6423 expire
.high
= 0x7fffffff;
6425 ctr
->info
.id
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_17
);
6426 init_sam_user_info11(ctr
->info
.id17
, &expire
,
6427 "BROOKFIELDS$", /* name */
6428 0x03ef, /* user rid */
6429 0x201, /* group rid */
6430 0x0080); /* acb info */
6436 ctr
->info
.id18
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_18
);
6437 if (ctr
->info
.id18
== NULL
)
6438 return NT_STATUS_NO_MEMORY
;
6440 init_sam_user_info18(ctr
->info
.id18
, usr
->lm_pwd
, usr
->nt_pwd
);
6444 SAM_USER_INFO_21
*cusr
;
6445 cusr
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_21
);
6446 ctr
->info
.id21
= cusr
;
6447 if (ctr
->info
.id21
== NULL
)
6448 return NT_STATUS_NO_MEMORY
;
6449 memcpy(cusr
, usr
, sizeof(*usr
));
6450 memset(cusr
->lm_pwd
, 0, sizeof(cusr
->lm_pwd
));
6451 memset(cusr
->nt_pwd
, 0, sizeof(cusr
->nt_pwd
));
6455 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6456 return NT_STATUS_INVALID_INFO_CLASS
;
6459 return NT_STATUS_OK
;
6462 /*******************************************************************
6463 inits a SAM_USERINFO_CTR structure.
6464 ********************************************************************/
6466 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR
* ctr
, DATA_BLOB
*sess_key
,
6467 uint16 switch_value
, void *info
)
6469 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6471 ctr
->switch_value
= switch_value
;
6472 ctr
->info
.id
= info
;
6474 switch (switch_value
) {
6476 SamOEMhashBlob(ctr
->info
.id24
->pass
, 516, sess_key
);
6477 dump_data(100, (char *)sess_key
->data
, sess_key
->length
);
6478 dump_data(100, (char *)ctr
->info
.id24
->pass
, 516);
6481 SamOEMhashBlob(ctr
->info
.id23
->pass
, 516, sess_key
);
6482 dump_data(100, (char *)sess_key
->data
, sess_key
->length
);
6483 dump_data(100, (char *)ctr
->info
.id23
->pass
, 516);
6488 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value
));
6492 /*******************************************************************
6493 reads or writes a structure.
6494 ********************************************************************/
6496 static BOOL
samr_io_userinfo_ctr(const char *desc
, SAM_USERINFO_CTR
**ppctr
,
6497 prs_struct
*ps
, int depth
)
6500 SAM_USERINFO_CTR
*ctr
;
6502 prs_debug(ps
, depth
, desc
, "samr_io_userinfo_ctr");
6505 if (UNMARSHALLING(ps
)) {
6506 ctr
= PRS_ALLOC_MEM(ps
,SAM_USERINFO_CTR
,1);
6514 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6516 if(!prs_uint16("switch_value", ps
, depth
, &ctr
->switch_value
))
6523 switch (ctr
->switch_value
) {
6525 if (UNMARSHALLING(ps
))
6526 ctr
->info
.id7
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_7
,1);
6527 if (ctr
->info
.id7
== NULL
) {
6528 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6531 ret
= sam_io_user_info7("", ctr
->info
.id7
, ps
, depth
);
6534 if (UNMARSHALLING(ps
))
6535 ctr
->info
.id9
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_9
,1);
6536 if (ctr
->info
.id9
== NULL
) {
6537 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6540 ret
= sam_io_user_info9("", ctr
->info
.id9
, ps
, depth
);
6543 if (UNMARSHALLING(ps
))
6544 ctr
->info
.id16
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_16
,1);
6545 if (ctr
->info
.id16
== NULL
) {
6546 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6549 ret
= sam_io_user_info16("", ctr
->info
.id16
, ps
, depth
);
6552 if (UNMARSHALLING(ps
))
6553 ctr
->info
.id17
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_17
,1);
6555 if (ctr
->info
.id17
== NULL
) {
6556 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6559 ret
= sam_io_user_info17("", ctr
->info
.id17
, ps
, depth
);
6562 if (UNMARSHALLING(ps
))
6563 ctr
->info
.id18
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_18
,1);
6565 if (ctr
->info
.id18
== NULL
) {
6566 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6569 ret
= sam_io_user_info18("", ctr
->info
.id18
, ps
, depth
);
6572 if (UNMARSHALLING(ps
))
6573 ctr
->info
.id20
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_20
,1);
6575 if (ctr
->info
.id20
== NULL
) {
6576 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6579 ret
= sam_io_user_info20("", ctr
->info
.id20
, ps
, depth
);
6582 if (UNMARSHALLING(ps
))
6583 ctr
->info
.id21
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_21
,1);
6585 if (ctr
->info
.id21
== NULL
) {
6586 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6589 ret
= sam_io_user_info21("", ctr
->info
.id21
, ps
, depth
);
6592 if (UNMARSHALLING(ps
))
6593 ctr
->info
.id23
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_23
,1);
6595 if (ctr
->info
.id23
== NULL
) {
6596 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6599 ret
= sam_io_user_info23("", ctr
->info
.id23
, ps
, depth
);
6602 if (UNMARSHALLING(ps
))
6603 ctr
->info
.id24
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_24
,1);
6605 if (ctr
->info
.id24
== NULL
) {
6606 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6609 ret
= sam_io_user_info24("", ctr
->info
.id24
, ps
, depth
);
6612 if (UNMARSHALLING(ps
))
6613 ctr
->info
.id25
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_25
,1);
6615 if (ctr
->info
.id25
== NULL
) {
6616 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6619 ret
= sam_io_user_info25("", ctr
->info
.id25
, ps
, depth
);
6622 if (UNMARSHALLING(ps
))
6623 ctr
->info
.id26
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_26
,1);
6625 if (ctr
->info
.id26
== NULL
) {
6626 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6629 ret
= sam_io_user_info26("", ctr
->info
.id26
, ps
, depth
);
6632 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr
->switch_value
));
6640 /*******************************************************************
6641 inits a SAMR_R_QUERY_USERINFO structure.
6642 ********************************************************************/
6644 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO
* r_u
,
6645 SAM_USERINFO_CTR
* ctr
, NTSTATUS status
)
6647 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6652 if (NT_STATUS_IS_OK(status
)) {
6657 r_u
->status
= status
; /* return status */
6660 /*******************************************************************
6661 reads or writes a structure.
6662 ********************************************************************/
6664 BOOL
samr_io_r_query_userinfo(const char *desc
, SAMR_R_QUERY_USERINFO
* r_u
,
6665 prs_struct
*ps
, int depth
)
6670 prs_debug(ps
, depth
, desc
, "samr_io_r_query_userinfo");
6676 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
6679 if (r_u
->ptr
!= 0) {
6680 if(!samr_io_userinfo_ctr("ctr", &r_u
->ctr
, ps
, depth
))
6686 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6692 /*******************************************************************
6693 inits a SAMR_Q_SET_USERINFO structure.
6694 ********************************************************************/
6696 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO
* q_u
,
6697 const POLICY_HND
*hnd
, DATA_BLOB
*sess_key
,
6698 uint16 switch_value
, void *info
)
6700 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6703 q_u
->switch_value
= switch_value
;
6704 init_samr_userinfo_ctr(q_u
->ctr
, sess_key
, switch_value
, info
);
6707 /*******************************************************************
6708 reads or writes a structure.
6709 ********************************************************************/
6711 BOOL
samr_io_q_set_userinfo(const char *desc
, SAMR_Q_SET_USERINFO
* q_u
,
6712 prs_struct
*ps
, int depth
)
6717 prs_debug(ps
, depth
, desc
, "samr_io_q_set_userinfo");
6723 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
6725 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
6727 if(!samr_io_userinfo_ctr("ctr", &q_u
->ctr
, ps
, depth
))
6733 /*******************************************************************
6734 inits a SAMR_R_SET_USERINFO structure.
6735 ********************************************************************/
6737 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO
* r_u
, NTSTATUS status
)
6739 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6741 r_u
->status
= status
; /* return status */
6744 /*******************************************************************
6745 reads or writes a structure.
6746 ********************************************************************/
6748 BOOL
samr_io_r_set_userinfo(const char *desc
, SAMR_R_SET_USERINFO
* r_u
,
6749 prs_struct
*ps
, int depth
)
6754 prs_debug(ps
, depth
, desc
, "samr_io_r_set_userinfo");
6760 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6766 /*******************************************************************
6767 inits a SAMR_Q_SET_USERINFO2 structure.
6768 ********************************************************************/
6770 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2
* q_u
,
6771 const POLICY_HND
*hnd
, DATA_BLOB
*sess_key
,
6772 uint16 switch_value
, SAM_USERINFO_CTR
* ctr
)
6774 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6777 q_u
->switch_value
= switch_value
;
6780 if (q_u
->ctr
!= NULL
)
6781 q_u
->ctr
->switch_value
= switch_value
;
6783 switch (switch_value
) {
6785 SamOEMhashBlob(ctr
->info
.id18
->lm_pwd
, 16, sess_key
);
6786 SamOEMhashBlob(ctr
->info
.id18
->nt_pwd
, 16, sess_key
);
6787 dump_data(100, (char *)sess_key
->data
, sess_key
->length
);
6788 dump_data(100, (char *)ctr
->info
.id18
->lm_pwd
, 16);
6789 dump_data(100, (char *)ctr
->info
.id18
->nt_pwd
, 16);
6794 /*******************************************************************
6795 reads or writes a structure.
6796 ********************************************************************/
6798 BOOL
samr_io_q_set_userinfo2(const char *desc
, SAMR_Q_SET_USERINFO2
* q_u
,
6799 prs_struct
*ps
, int depth
)
6804 prs_debug(ps
, depth
, desc
, "samr_io_q_set_userinfo2");
6810 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
6813 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
6815 if(!samr_io_userinfo_ctr("ctr", &q_u
->ctr
, ps
, depth
))
6821 /*******************************************************************
6822 inits a SAMR_R_SET_USERINFO2 structure.
6823 ********************************************************************/
6825 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2
* r_u
, NTSTATUS status
)
6827 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6829 r_u
->status
= status
; /* return status */
6832 /*******************************************************************
6833 reads or writes a structure.
6834 ********************************************************************/
6836 BOOL
samr_io_r_set_userinfo2(const char *desc
, SAMR_R_SET_USERINFO2
* r_u
,
6837 prs_struct
*ps
, int depth
)
6842 prs_debug(ps
, depth
, desc
, "samr_io_r_set_userinfo2");
6848 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6854 /*******************************************************************
6855 inits a SAMR_Q_CONNECT structure.
6856 ********************************************************************/
6858 void init_samr_q_connect(SAMR_Q_CONNECT
* q_u
,
6859 char *srv_name
, uint32 access_mask
)
6861 DEBUG(5, ("init_samr_q_connect\n"));
6863 /* make PDC server name \\server */
6864 q_u
->ptr_srv_name
= (srv_name
!= NULL
&& *srv_name
) ? 1 : 0;
6865 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
6867 /* example values: 0x0000 0002 */
6868 q_u
->access_mask
= access_mask
;
6871 /*******************************************************************
6872 reads or writes a structure.
6873 ********************************************************************/
6875 BOOL
samr_io_q_connect(const char *desc
, SAMR_Q_CONNECT
* q_u
,
6876 prs_struct
*ps
, int depth
)
6881 prs_debug(ps
, depth
, desc
, "samr_io_q_connect");
6887 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
6889 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
6894 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6900 /*******************************************************************
6901 reads or writes a structure.
6902 ********************************************************************/
6904 BOOL
samr_io_r_connect(const char *desc
, SAMR_R_CONNECT
* r_u
,
6905 prs_struct
*ps
, int depth
)
6910 prs_debug(ps
, depth
, desc
, "samr_io_r_connect");
6916 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6919 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6925 /*******************************************************************
6926 inits a SAMR_Q_CONNECT4 structure.
6927 ********************************************************************/
6929 void init_samr_q_connect4(SAMR_Q_CONNECT4
* q_u
,
6930 char *srv_name
, uint32 access_mask
)
6932 DEBUG(5, ("init_samr_q_connect4\n"));
6934 /* make PDC server name \\server */
6935 q_u
->ptr_srv_name
= (srv_name
!= NULL
&& *srv_name
) ? 1 : 0;
6936 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
6938 /* Only value we've seen, possibly an address type ? */
6941 /* example values: 0x0000 0002 */
6942 q_u
->access_mask
= access_mask
;
6945 /*******************************************************************
6946 reads or writes a structure.
6947 ********************************************************************/
6949 BOOL
samr_io_q_connect4(const char *desc
, SAMR_Q_CONNECT4
* q_u
,
6950 prs_struct
*ps
, int depth
)
6955 prs_debug(ps
, depth
, desc
, "samr_io_q_connect4");
6961 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
6963 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
6968 if(!prs_uint32("unk_0", ps
, depth
, &q_u
->unk_0
))
6970 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6976 /*******************************************************************
6977 reads or writes a structure.
6978 ********************************************************************/
6980 BOOL
samr_io_r_connect4(const char *desc
, SAMR_R_CONNECT4
* r_u
,
6981 prs_struct
*ps
, int depth
)
6986 prs_debug(ps
, depth
, desc
, "samr_io_r_connect4");
6992 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6995 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7001 /*******************************************************************
7002 inits a SAMR_Q_CONNECT5 structure.
7003 ********************************************************************/
7005 void init_samr_q_connect5(SAMR_Q_CONNECT5
* q_u
,
7006 char *srv_name
, uint32 access_mask
)
7008 DEBUG(5, ("init_samr_q_connect5\n"));
7010 /* make PDC server name \\server */
7011 q_u
->ptr_srv_name
= (srv_name
!= NULL
&& *srv_name
) ? 1 : 0;
7012 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
7014 /* example values: 0x0000 0002 */
7015 q_u
->access_mask
= access_mask
;
7018 q_u
->info1_unk1
= 3;
7019 q_u
->info1_unk2
= 0;
7022 /*******************************************************************
7023 inits a SAMR_R_CONNECT5 structure.
7024 ********************************************************************/
7026 void init_samr_r_connect5(SAMR_R_CONNECT5
* r_u
, POLICY_HND
*pol
, NTSTATUS status
)
7028 DEBUG(5, ("init_samr_q_connect5\n"));
7031 r_u
->info1_unk1
= 3;
7032 r_u
->info1_unk2
= 0;
7034 r_u
->connect_pol
= *pol
;
7035 r_u
->status
= status
;
7038 /*******************************************************************
7039 reads or writes a structure.
7040 ********************************************************************/
7042 BOOL
samr_io_q_connect5(const char *desc
, SAMR_Q_CONNECT5
* q_u
,
7043 prs_struct
*ps
, int depth
)
7048 prs_debug(ps
, depth
, desc
, "samr_io_q_connect5");
7054 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
7056 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
7061 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
7064 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
7066 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
7069 if(!prs_uint32("info1_unk1", ps
, depth
, &q_u
->info1_unk1
))
7071 if(!prs_uint32("info1_unk2", ps
, depth
, &q_u
->info1_unk2
))
7077 /*******************************************************************
7078 reads or writes a structure.
7079 ********************************************************************/
7081 BOOL
samr_io_r_connect5(const char *desc
, SAMR_R_CONNECT5
* r_u
,
7082 prs_struct
*ps
, int depth
)
7087 prs_debug(ps
, depth
, desc
, "samr_io_r_connect5");
7093 if(!prs_uint32("level", ps
, depth
, &r_u
->level
))
7095 if(!prs_uint32("level", ps
, depth
, &r_u
->level
))
7097 if(!prs_uint32("info1_unk1", ps
, depth
, &r_u
->info1_unk1
))
7099 if(!prs_uint32("info1_unk2", ps
, depth
, &r_u
->info1_unk2
))
7102 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
7105 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7111 /*******************************************************************
7112 inits a SAMR_Q_CONNECT_ANON structure.
7113 ********************************************************************/
7115 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON
* q_u
)
7117 DEBUG(5, ("init_samr_q_connect_anon\n"));
7120 q_u
->unknown_0
= 0x5c; /* server name (?!!) */
7121 q_u
->access_mask
= MAXIMUM_ALLOWED_ACCESS
;
7124 /*******************************************************************
7125 reads or writes a structure.
7126 ********************************************************************/
7128 BOOL
samr_io_q_connect_anon(const char *desc
, SAMR_Q_CONNECT_ANON
* q_u
,
7129 prs_struct
*ps
, int depth
)
7134 prs_debug(ps
, depth
, desc
, "samr_io_q_connect_anon");
7140 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
7143 if(!prs_uint16("unknown_0", ps
, depth
, &q_u
->unknown_0
))
7148 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
7154 /*******************************************************************
7155 reads or writes a structure.
7156 ********************************************************************/
7158 BOOL
samr_io_r_connect_anon(const char *desc
, SAMR_R_CONNECT_ANON
* r_u
,
7159 prs_struct
*ps
, int depth
)
7164 prs_debug(ps
, depth
, desc
, "samr_io_r_connect_anon");
7170 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
7173 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7179 /*******************************************************************
7180 inits a SAMR_Q_GET_DOM_PWINFO structure.
7181 ********************************************************************/
7183 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO
* q_u
,
7186 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7189 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_FLAGS_NONE
);
7190 init_uni_hdr(&q_u
->hdr_srv_name
, &q_u
->uni_srv_name
);
7193 /*******************************************************************
7194 reads or writes a structure.
7195 ********************************************************************/
7197 BOOL
samr_io_q_get_dom_pwinfo(const char *desc
, SAMR_Q_GET_DOM_PWINFO
* q_u
,
7198 prs_struct
*ps
, int depth
)
7203 prs_debug(ps
, depth
, desc
, "samr_io_q_get_dom_pwinfo");
7209 if(!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
7211 if (q_u
->ptr
!= 0) {
7212 if(!smb_io_unihdr("", &q_u
->hdr_srv_name
, ps
, depth
))
7214 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->hdr_srv_name
.buffer
, ps
, depth
))
7221 /*******************************************************************
7222 reads or writes a structure.
7223 ********************************************************************/
7225 BOOL
samr_io_r_get_dom_pwinfo(const char *desc
, SAMR_R_GET_DOM_PWINFO
* r_u
,
7226 prs_struct
*ps
, int depth
)
7231 prs_debug(ps
, depth
, desc
, "samr_io_r_get_dom_pwinfo");
7237 if(!prs_uint16("min_pwd_length", ps
, depth
, &r_u
->min_pwd_length
))
7241 if(!prs_uint32("password_properties", ps
, depth
, &r_u
->password_properties
))
7244 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7250 /*******************************************************************
7251 make a SAMR_ENC_PASSWD structure.
7252 ********************************************************************/
7254 void init_enc_passwd(SAMR_ENC_PASSWD
* pwd
, const char pass
[512])
7262 memcpy(pwd
->pass
, pass
, sizeof(pwd
->pass
));
7266 /*******************************************************************
7267 reads or writes a SAMR_ENC_PASSWD structure.
7268 ********************************************************************/
7270 BOOL
samr_io_enc_passwd(const char *desc
, SAMR_ENC_PASSWD
* pwd
,
7271 prs_struct
*ps
, int depth
)
7276 prs_debug(ps
, depth
, desc
, "samr_io_enc_passwd");
7282 if(!prs_uint32("ptr", ps
, depth
, &pwd
->ptr
))
7285 if (pwd
->ptr
!= 0) {
7286 if(!prs_uint8s(False
, "pwd", ps
, depth
, pwd
->pass
, sizeof(pwd
->pass
)))
7293 /*******************************************************************
7294 inits a SAMR_ENC_HASH structure.
7295 ********************************************************************/
7297 void init_enc_hash(SAMR_ENC_HASH
* hsh
, const uchar hash
[16])
7305 memcpy(hsh
->hash
, hash
, sizeof(hsh
->hash
));
7309 /*******************************************************************
7310 reads or writes a SAMR_ENC_HASH structure.
7311 ********************************************************************/
7313 BOOL
samr_io_enc_hash(const char *desc
, SAMR_ENC_HASH
* hsh
,
7314 prs_struct
*ps
, int depth
)
7319 prs_debug(ps
, depth
, desc
, "samr_io_enc_hash");
7325 if(!prs_uint32("ptr ", ps
, depth
, &hsh
->ptr
))
7327 if (hsh
->ptr
!= 0) {
7328 if(!prs_uint8s(False
, "hash", ps
, depth
, hsh
->hash
,sizeof(hsh
->hash
)))
7335 /*******************************************************************
7336 inits a SAMR_Q_CHGPASSWD_USER structure.
7337 ********************************************************************/
7339 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER
* q_u
,
7340 const char *dest_host
, const char *user_name
,
7341 const uchar nt_newpass
[516],
7342 const uchar nt_oldhash
[16],
7343 const uchar lm_newpass
[516],
7344 const uchar lm_oldhash
[16])
7346 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7349 init_unistr2(&q_u
->uni_dest_host
, dest_host
, UNI_FLAGS_NONE
);
7350 init_uni_hdr(&q_u
->hdr_dest_host
, &q_u
->uni_dest_host
);
7352 init_unistr2(&q_u
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
7353 init_uni_hdr(&q_u
->hdr_user_name
, &q_u
->uni_user_name
);
7355 init_enc_passwd(&q_u
->nt_newpass
, (const char *)nt_newpass
);
7356 init_enc_hash(&q_u
->nt_oldhash
, nt_oldhash
);
7358 q_u
->unknown
= 0x01;
7360 init_enc_passwd(&q_u
->lm_newpass
, (const char *)lm_newpass
);
7361 init_enc_hash(&q_u
->lm_oldhash
, lm_oldhash
);
7364 /*******************************************************************
7365 reads or writes a structure.
7366 ********************************************************************/
7368 BOOL
samr_io_q_chgpasswd_user(const char *desc
, SAMR_Q_CHGPASSWD_USER
* q_u
,
7369 prs_struct
*ps
, int depth
)
7374 prs_debug(ps
, depth
, desc
, "samr_io_q_chgpasswd_user");
7380 if(!prs_uint32("ptr_0", ps
, depth
, &q_u
->ptr_0
))
7383 if(!smb_io_unihdr("", &q_u
->hdr_dest_host
, ps
, depth
))
7385 if(!smb_io_unistr2("", &q_u
->uni_dest_host
, q_u
->hdr_dest_host
.buffer
, ps
, depth
))
7390 if(!smb_io_unihdr("", &q_u
->hdr_user_name
, ps
, depth
))
7392 if(!smb_io_unistr2("", &q_u
->uni_user_name
, q_u
->hdr_user_name
.buffer
,ps
, depth
))
7395 if(!samr_io_enc_passwd("nt_newpass", &q_u
->nt_newpass
, ps
, depth
))
7397 if(!samr_io_enc_hash("nt_oldhash", &q_u
->nt_oldhash
, ps
, depth
))
7400 if(!prs_uint32("unknown", ps
, depth
, &q_u
->unknown
))
7403 if(!samr_io_enc_passwd("lm_newpass", &q_u
->lm_newpass
, ps
, depth
))
7405 if(!samr_io_enc_hash("lm_oldhash", &q_u
->lm_oldhash
, ps
, depth
))
7411 /*******************************************************************
7412 inits a SAMR_R_CHGPASSWD_USER structure.
7413 ********************************************************************/
7415 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER
* r_u
, NTSTATUS status
)
7417 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
7419 r_u
->status
= status
;
7422 /*******************************************************************
7423 reads or writes a structure.
7424 ********************************************************************/
7426 BOOL
samr_io_r_chgpasswd_user(const char *desc
, SAMR_R_CHGPASSWD_USER
* r_u
,
7427 prs_struct
*ps
, int depth
)
7432 prs_debug(ps
, depth
, desc
, "samr_io_r_chgpasswd_user");
7438 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7444 /*******************************************************************
7445 inits a SAMR_Q_CHGPASSWD3 structure.
7446 ********************************************************************/
7448 void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3
* q_u
,
7449 const char *dest_host
, const char *user_name
,
7450 const uchar nt_newpass
[516],
7451 const uchar nt_oldhash
[16],
7452 const uchar lm_newpass
[516],
7453 const uchar lm_oldhash
[16])
7455 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
7458 init_unistr2(&q_u
->uni_dest_host
, dest_host
, UNI_FLAGS_NONE
);
7459 init_uni_hdr(&q_u
->hdr_dest_host
, &q_u
->uni_dest_host
);
7461 init_unistr2(&q_u
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
7462 init_uni_hdr(&q_u
->hdr_user_name
, &q_u
->uni_user_name
);
7464 init_enc_passwd(&q_u
->nt_newpass
, (const char *)nt_newpass
);
7465 init_enc_hash(&q_u
->nt_oldhash
, nt_oldhash
);
7467 q_u
->lm_change
= 0x01;
7469 init_enc_passwd(&q_u
->lm_newpass
, (const char *)lm_newpass
);
7470 init_enc_hash(&q_u
->lm_oldhash
, lm_oldhash
);
7472 init_enc_passwd(&q_u
->password3
, NULL
);
7475 /*******************************************************************
7476 reads or writes a structure.
7477 ********************************************************************/
7479 BOOL
samr_io_q_chgpasswd_user3(const char *desc
, SAMR_Q_CHGPASSWD_USER3
* q_u
,
7480 prs_struct
*ps
, int depth
)
7485 prs_debug(ps
, depth
, desc
, "samr_io_q_chgpasswd_user3");
7491 if(!prs_uint32("ptr_0", ps
, depth
, &q_u
->ptr_0
))
7494 if(!smb_io_unihdr("", &q_u
->hdr_dest_host
, ps
, depth
))
7496 if(!smb_io_unistr2("", &q_u
->uni_dest_host
, q_u
->hdr_dest_host
.buffer
, ps
, depth
))
7501 if(!smb_io_unihdr("", &q_u
->hdr_user_name
, ps
, depth
))
7503 if(!smb_io_unistr2("", &q_u
->uni_user_name
, q_u
->hdr_user_name
.buffer
,ps
, depth
))
7506 if(!samr_io_enc_passwd("nt_newpass", &q_u
->nt_newpass
, ps
, depth
))
7508 if(!samr_io_enc_hash("nt_oldhash", &q_u
->nt_oldhash
, ps
, depth
))
7511 if(!prs_uint32("lm_change", ps
, depth
, &q_u
->lm_change
))
7514 if(!samr_io_enc_passwd("lm_newpass", &q_u
->lm_newpass
, ps
, depth
))
7516 if(!samr_io_enc_hash("lm_oldhash", &q_u
->lm_oldhash
, ps
, depth
))
7519 if(!samr_io_enc_passwd("password3", &q_u
->password3
, ps
, depth
))
7525 /*******************************************************************
7526 inits a SAMR_R_CHGPASSWD_USER3 structure.
7527 ********************************************************************/
7529 void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3
*r_u
, NTSTATUS status
,
7530 SAMR_CHANGE_REJECT
*reject
, SAM_UNK_INFO_1
*info
)
7532 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
7534 r_u
->status
= status
;
7538 r_u
->ptr_reject
= 0;
7544 if (reject
&& (reject
->reject_reason
!= Undefined
)) {
7545 r_u
->reject
= reject
;
7546 r_u
->ptr_reject
= 1;
7550 /*******************************************************************
7551 Reads or writes an SAMR_CHANGE_REJECT structure.
7552 ********************************************************************/
7554 BOOL
samr_io_change_reject(const char *desc
, SAMR_CHANGE_REJECT
*reject
, prs_struct
*ps
, int depth
)
7559 prs_debug(ps
, depth
, desc
, "samr_io_change_reject");
7565 if(UNMARSHALLING(ps
))
7566 ZERO_STRUCTP(reject
);
7568 if (!prs_uint32("reject_reason", ps
, depth
, &reject
->reject_reason
))
7571 if (!prs_uint32("unknown1", ps
, depth
, &reject
->unknown1
))
7574 if (!prs_uint32("unknown2", ps
, depth
, &reject
->unknown2
))
7580 /*******************************************************************
7581 reads or writes a structure.
7582 ********************************************************************/
7584 BOOL
samr_io_r_chgpasswd_user3(const char *desc
, SAMR_R_CHGPASSWD_USER3
*r_u
,
7585 prs_struct
*ps
, int depth
)
7590 prs_debug(ps
, depth
, desc
, "samr_io_r_chgpasswd_user3");
7596 if (!prs_uint32("ptr_info", ps
, depth
, &r_u
->ptr_info
))
7599 if (r_u
->ptr_info
&& r_u
->info
!= NULL
) {
7600 /* SAM_UNK_INFO_1 */
7601 if (!sam_io_unk_info1("info", r_u
->info
, ps
, depth
))
7605 if (!prs_uint32("ptr_reject", ps
, depth
, &r_u
->ptr_reject
))
7608 if (r_u
->ptr_reject
&& r_u
->reject
!= NULL
) {
7609 /* SAMR_CHANGE_REJECT */
7610 if (!samr_io_change_reject("reject", r_u
->reject
, ps
, depth
))
7614 if (!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7620 /*******************************************************************
7621 reads or writes a structure.
7622 ********************************************************************/
7624 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2
*q_u
,
7625 POLICY_HND
*domain_pol
, uint16 switch_value
)
7627 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7629 q_u
->domain_pol
= *domain_pol
;
7630 q_u
->switch_value
= switch_value
;
7633 /*******************************************************************
7634 reads or writes a structure.
7635 ********************************************************************/
7637 BOOL
samr_io_q_query_domain_info2(const char *desc
, SAMR_Q_QUERY_DOMAIN_INFO2
*q_u
,
7638 prs_struct
*ps
, int depth
)
7643 prs_debug(ps
, depth
, desc
, "samr_io_q_query_domain_info2");
7649 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
7652 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
7658 /*******************************************************************
7659 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7660 ********************************************************************/
7662 void init_samr_r_samr_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2
* r_u
,
7663 uint16 switch_value
, SAM_UNK_CTR
* ctr
,
7666 DEBUG(5, ("init_samr_r_samr_query_domain_info2\n"));
7669 r_u
->switch_value
= 0;
7670 r_u
->status
= status
; /* return status */
7672 if (NT_STATUS_IS_OK(status
)) {
7673 r_u
->switch_value
= switch_value
;
7679 /*******************************************************************
7680 reads or writes a structure.
7681 ********************************************************************/
7683 BOOL
samr_io_r_samr_query_domain_info2(const char *desc
, SAMR_R_QUERY_DOMAIN_INFO2
* r_u
,
7684 prs_struct
*ps
, int depth
)
7689 prs_debug(ps
, depth
, desc
, "samr_io_r_samr_query_domain_info2");
7695 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
7698 if (r_u
->ptr_0
!= 0 && r_u
->ctr
!= NULL
) {
7699 if(!prs_uint16("switch_value", ps
, depth
, &r_u
->switch_value
))
7704 switch (r_u
->switch_value
) {
7706 if(!sam_io_unk_info12("unk_inf12", &r_u
->ctr
->info
.inf12
, ps
, depth
))
7710 if(!sam_io_unk_info7("unk_inf7",&r_u
->ctr
->info
.inf7
, ps
,depth
))
7714 if(!sam_io_unk_info6("unk_inf6",&r_u
->ctr
->info
.inf6
, ps
,depth
))
7718 if(!sam_io_unk_info5("unk_inf5",&r_u
->ctr
->info
.inf5
, ps
,depth
))
7722 if(!sam_io_unk_info3("unk_inf3",&r_u
->ctr
->info
.inf3
, ps
,depth
))
7726 if(!sam_io_unk_info2("unk_inf2",&r_u
->ctr
->info
.inf2
, ps
,depth
))
7730 if(!sam_io_unk_info1("unk_inf1",&r_u
->ctr
->info
.inf1
, ps
,depth
))
7734 DEBUG(0, ("samr_io_r_samr_query_domain_info2: unknown switch level 0x%x\n",
7735 r_u
->switch_value
));
7736 r_u
->status
= NT_STATUS_INVALID_INFO_CLASS
;
7744 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7751 /*******************************************************************
7752 reads or writes a structure.
7753 ********************************************************************/
7755 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO
*q_u
,
7756 POLICY_HND
*domain_pol
, uint16 switch_value
, SAM_UNK_CTR
*ctr
)
7758 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7760 q_u
->domain_pol
= *domain_pol
;
7761 q_u
->switch_value0
= switch_value
;
7763 q_u
->switch_value
= switch_value
;
7768 /*******************************************************************
7769 reads or writes a structure.
7770 ********************************************************************/
7772 BOOL
samr_io_q_set_domain_info(const char *desc
, SAMR_Q_SET_DOMAIN_INFO
*q_u
,
7773 prs_struct
*ps
, int depth
)
7778 prs_debug(ps
, depth
, desc
, "samr_io_q_set_domain_info");
7784 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
7787 if(!prs_uint16("switch_value0", ps
, depth
, &q_u
->switch_value0
))
7790 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
7796 if (UNMARSHALLING(ps
)) {
7797 if ((q_u
->ctr
= PRS_ALLOC_MEM(ps
, SAM_UNK_CTR
, 1)) == NULL
)
7801 switch (q_u
->switch_value
) {
7804 if(!sam_io_unk_info12("unk_inf12", &q_u
->ctr
->info
.inf12
, ps
, depth
))
7808 if(!sam_io_unk_info7("unk_inf7",&q_u
->ctr
->info
.inf7
, ps
,depth
))
7812 if(!sam_io_unk_info6("unk_inf6",&q_u
->ctr
->info
.inf6
, ps
,depth
))
7816 if(!sam_io_unk_info5("unk_inf5",&q_u
->ctr
->info
.inf5
, ps
,depth
))
7820 if(!sam_io_unk_info3("unk_inf3",&q_u
->ctr
->info
.inf3
, ps
,depth
))
7824 if(!sam_io_unk_info2("unk_inf2",&q_u
->ctr
->info
.inf2
, ps
,depth
))
7828 if(!sam_io_unk_info1("unk_inf1",&q_u
->ctr
->info
.inf1
, ps
,depth
))
7832 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7833 q_u
->switch_value
));
7840 /*******************************************************************
7841 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7842 ********************************************************************/
7844 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO
* r_u
, NTSTATUS status
)
7846 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7848 r_u
->status
= status
; /* return status */
7851 /*******************************************************************
7852 reads or writes a structure.
7853 ********************************************************************/
7855 BOOL
samr_io_r_set_domain_info(const char *desc
, SAMR_R_SET_DOMAIN_INFO
* r_u
,
7856 prs_struct
*ps
, int depth
)
7861 prs_debug(ps
, depth
, desc
, "samr_io_r_samr_unknown_2e");
7867 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))