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 *server
)
667 init_unistr2(&u_5
->uni_server
, server
, UNI_FLAGS_NONE
);
668 init_uni_hdr(&u_5
->hdr_server
, &u_5
->uni_server
);
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_server", &u_5
->hdr_server
, ps
, depth
))
687 if(!smb_io_unistr2("uni_server", &u_5
->uni_server
, u_5
->hdr_server
.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 reads or writes a structure.
2311 ********************************************************************/
2313 static BOOL
samr_group_info_ctr(const char *desc
, GROUP_INFO_CTR
**ctr
,
2314 prs_struct
*ps
, int depth
)
2316 if (UNMARSHALLING(ps
))
2317 *ctr
= PRS_ALLOC_MEM(ps
,GROUP_INFO_CTR
,1);
2322 prs_debug(ps
, depth
, desc
, "samr_group_info_ctr");
2325 if(!prs_uint16("switch_value1", ps
, depth
, &(*ctr
)->switch_value1
))
2328 switch ((*ctr
)->switch_value1
) {
2330 if(!samr_io_group_info1("group_info1", &(*ctr
)->group
.info1
, ps
, depth
))
2334 if(!samr_io_group_info2("group_info2", &(*ctr
)->group
.info2
, ps
, depth
))
2338 if(!samr_io_group_info3("group_info3", &(*ctr
)->group
.info3
, ps
, depth
))
2342 if(!samr_io_group_info4("group_info4", &(*ctr
)->group
.info4
, ps
, depth
))
2346 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2353 /*******************************************************************
2354 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2355 ********************************************************************/
2357 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP
* q_e
,
2358 POLICY_HND
*pol
, const char *acct_desc
,
2361 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2365 init_unistr2(&q_e
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
2366 init_uni_hdr(&q_e
->hdr_acct_desc
, &q_e
->uni_acct_desc
);
2368 q_e
->access_mask
= access_mask
;
2371 /*******************************************************************
2372 reads or writes a structure.
2373 ********************************************************************/
2375 BOOL
samr_io_q_create_dom_group(const char *desc
, SAMR_Q_CREATE_DOM_GROUP
* q_e
,
2376 prs_struct
*ps
, int depth
)
2381 prs_debug(ps
, depth
, desc
, "samr_io_q_create_dom_group");
2387 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2390 if(!smb_io_unihdr("hdr_acct_desc", &q_e
->hdr_acct_desc
, ps
, depth
))
2392 if(!smb_io_unistr2("uni_acct_desc", &q_e
->uni_acct_desc
,
2393 q_e
->hdr_acct_desc
.buffer
, ps
, depth
))
2398 if(!prs_uint32("access", ps
, depth
, &q_e
->access_mask
))
2404 /*******************************************************************
2405 reads or writes a structure.
2406 ********************************************************************/
2408 BOOL
samr_io_r_create_dom_group(const char *desc
, SAMR_R_CREATE_DOM_GROUP
* r_u
,
2409 prs_struct
*ps
, int depth
)
2414 prs_debug(ps
, depth
, desc
, "samr_io_r_create_dom_group");
2420 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2423 if(!prs_uint32("rid ", ps
, depth
, &r_u
->rid
))
2425 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2431 /*******************************************************************
2432 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2433 ********************************************************************/
2435 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP
* q_c
,
2438 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2440 q_c
->group_pol
= *hnd
;
2443 /*******************************************************************
2444 reads or writes a structure.
2445 ********************************************************************/
2447 BOOL
samr_io_q_delete_dom_group(const char *desc
, SAMR_Q_DELETE_DOM_GROUP
* q_u
,
2448 prs_struct
*ps
, int depth
)
2453 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_group");
2459 if(!smb_io_pol_hnd("group_pol", &q_u
->group_pol
, ps
, depth
))
2465 /*******************************************************************
2466 reads or writes a structure.
2467 ********************************************************************/
2469 BOOL
samr_io_r_delete_dom_group(const char *desc
, SAMR_R_DELETE_DOM_GROUP
* r_u
,
2470 prs_struct
*ps
, int depth
)
2475 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_group");
2481 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2484 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2490 /*******************************************************************
2491 inits a SAMR_Q_DEL_GROUPMEM structure.
2492 ********************************************************************/
2494 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM
* q_e
,
2495 POLICY_HND
*pol
, uint32 rid
)
2497 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2503 /*******************************************************************
2504 reads or writes a structure.
2505 ********************************************************************/
2507 BOOL
samr_io_q_del_groupmem(const char *desc
, SAMR_Q_DEL_GROUPMEM
* q_e
,
2508 prs_struct
*ps
, int depth
)
2513 prs_debug(ps
, depth
, desc
, "samr_io_q_del_groupmem");
2519 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2522 if(!prs_uint32("rid", ps
, depth
, &q_e
->rid
))
2528 /*******************************************************************
2529 inits a SAMR_R_DEL_GROUPMEM structure.
2530 ********************************************************************/
2532 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM
* r_u
, POLICY_HND
*pol
,
2535 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2537 r_u
->status
= status
;
2540 /*******************************************************************
2541 reads or writes a structure.
2542 ********************************************************************/
2544 BOOL
samr_io_r_del_groupmem(const char *desc
, SAMR_R_DEL_GROUPMEM
* r_u
,
2545 prs_struct
*ps
, int depth
)
2550 prs_debug(ps
, depth
, desc
, "samr_io_r_del_groupmem");
2556 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2562 /*******************************************************************
2563 inits a SAMR_Q_ADD_GROUPMEM structure.
2564 ********************************************************************/
2566 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM
* q_e
,
2567 POLICY_HND
*pol
, uint32 rid
)
2569 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2573 q_e
->unknown
= 0x0005;
2576 /*******************************************************************
2577 reads or writes a structure.
2578 ********************************************************************/
2580 BOOL
samr_io_q_add_groupmem(const char *desc
, SAMR_Q_ADD_GROUPMEM
* q_e
,
2581 prs_struct
*ps
, int depth
)
2586 prs_debug(ps
, depth
, desc
, "samr_io_q_add_groupmem");
2592 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2595 if(!prs_uint32("rid ", ps
, depth
, &q_e
->rid
))
2597 if(!prs_uint32("unknown", ps
, depth
, &q_e
->unknown
))
2603 /*******************************************************************
2604 inits a SAMR_R_ADD_GROUPMEM structure.
2605 ********************************************************************/
2607 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM
* r_u
, POLICY_HND
*pol
,
2610 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2612 r_u
->status
= status
;
2615 /*******************************************************************
2616 reads or writes a structure.
2617 ********************************************************************/
2619 BOOL
samr_io_r_add_groupmem(const char *desc
, SAMR_R_ADD_GROUPMEM
* r_u
,
2620 prs_struct
*ps
, int depth
)
2625 prs_debug(ps
, depth
, desc
, "samr_io_r_add_groupmem");
2631 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2637 /*******************************************************************
2638 inits a SAMR_Q_SET_GROUPINFO structure.
2639 ********************************************************************/
2641 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO
* q_e
,
2642 POLICY_HND
*pol
, GROUP_INFO_CTR
* ctr
)
2644 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2650 /*******************************************************************
2651 reads or writes a structure.
2652 ********************************************************************/
2654 BOOL
samr_io_q_set_groupinfo(const char *desc
, SAMR_Q_SET_GROUPINFO
* q_e
,
2655 prs_struct
*ps
, int depth
)
2660 prs_debug(ps
, depth
, desc
, "samr_io_q_set_groupinfo");
2666 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2669 if(!samr_group_info_ctr("ctr", &q_e
->ctr
, ps
, depth
))
2675 /*******************************************************************
2676 inits a SAMR_R_SET_GROUPINFO structure.
2677 ********************************************************************/
2679 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO
* r_u
, NTSTATUS status
)
2681 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2683 r_u
->status
= status
;
2686 /*******************************************************************
2687 reads or writes a structure.
2688 ********************************************************************/
2690 BOOL
samr_io_r_set_groupinfo(const char *desc
, SAMR_R_SET_GROUPINFO
* r_u
,
2691 prs_struct
*ps
, int depth
)
2696 prs_debug(ps
, depth
, desc
, "samr_io_r_set_groupinfo");
2702 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2708 /*******************************************************************
2709 inits a SAMR_Q_QUERY_GROUPINFO structure.
2710 ********************************************************************/
2712 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO
* q_e
,
2713 POLICY_HND
*pol
, uint16 switch_level
)
2715 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2719 q_e
->switch_level
= switch_level
;
2722 /*******************************************************************
2723 reads or writes a structure.
2724 ********************************************************************/
2726 BOOL
samr_io_q_query_groupinfo(const char *desc
, SAMR_Q_QUERY_GROUPINFO
* q_e
,
2727 prs_struct
*ps
, int depth
)
2732 prs_debug(ps
, depth
, desc
, "samr_io_q_query_groupinfo");
2738 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2741 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
2747 /*******************************************************************
2748 inits a SAMR_R_QUERY_GROUPINFO structure.
2749 ********************************************************************/
2751 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO
* r_u
,
2752 GROUP_INFO_CTR
* ctr
, NTSTATUS status
)
2754 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2756 r_u
->ptr
= (NT_STATUS_IS_OK(status
) && ctr
!= NULL
) ? 1 : 0;
2758 r_u
->status
= status
;
2761 /*******************************************************************
2762 reads or writes a structure.
2763 ********************************************************************/
2765 BOOL
samr_io_r_query_groupinfo(const char *desc
, SAMR_R_QUERY_GROUPINFO
* r_u
,
2766 prs_struct
*ps
, int depth
)
2771 prs_debug(ps
, depth
, desc
, "samr_io_r_query_groupinfo");
2777 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
2780 if (r_u
->ptr
!= 0) {
2781 if(!samr_group_info_ctr("ctr", &r_u
->ctr
, ps
, depth
))
2787 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2793 /*******************************************************************
2794 inits a SAMR_Q_QUERY_GROUPMEM structure.
2795 ********************************************************************/
2797 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM
* q_c
, POLICY_HND
*hnd
)
2799 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2801 q_c
->group_pol
= *hnd
;
2804 /*******************************************************************
2805 reads or writes a structure.
2806 ********************************************************************/
2808 BOOL
samr_io_q_query_groupmem(const char *desc
, SAMR_Q_QUERY_GROUPMEM
* q_u
,
2809 prs_struct
*ps
, int depth
)
2814 prs_debug(ps
, depth
, desc
, "samr_io_q_query_groupmem");
2820 if(!smb_io_pol_hnd("group_pol", &q_u
->group_pol
, ps
, depth
))
2826 /*******************************************************************
2827 inits a SAMR_R_QUERY_GROUPMEM structure.
2828 ********************************************************************/
2830 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM
* r_u
,
2831 uint32 num_entries
, uint32
*rid
,
2832 uint32
*attr
, NTSTATUS status
)
2834 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2836 if (NT_STATUS_IS_OK(status
)) {
2838 r_u
->num_entries
= num_entries
;
2840 r_u
->ptr_attrs
= attr
!= NULL
? 1 : 0;
2841 r_u
->ptr_rids
= rid
!= NULL
? 1 : 0;
2843 r_u
->num_rids
= num_entries
;
2846 r_u
->num_attrs
= num_entries
;
2850 r_u
->num_entries
= 0;
2853 r_u
->status
= status
;
2856 /*******************************************************************
2857 reads or writes a structure.
2858 ********************************************************************/
2860 BOOL
samr_io_r_query_groupmem(const char *desc
, SAMR_R_QUERY_GROUPMEM
* r_u
,
2861 prs_struct
*ps
, int depth
)
2868 if (UNMARSHALLING(ps
))
2871 prs_debug(ps
, depth
, desc
, "samr_io_r_query_groupmem");
2877 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
2879 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
2882 if (r_u
->ptr
!= 0) {
2883 if(!prs_uint32("ptr_rids ", ps
, depth
, &r_u
->ptr_rids
))
2885 if(!prs_uint32("ptr_attrs", ps
, depth
, &r_u
->ptr_attrs
))
2888 if (r_u
->ptr_rids
!= 0) {
2889 if(!prs_uint32("num_rids", ps
, depth
, &r_u
->num_rids
))
2891 if (UNMARSHALLING(ps
) && r_u
->num_rids
!= 0) {
2892 r_u
->rid
= PRS_ALLOC_MEM(ps
,uint32
,r_u
->num_rids
);
2893 if (r_u
->rid
== NULL
)
2897 for (i
= 0; i
< r_u
->num_rids
; i
++) {
2898 if(!prs_uint32("", ps
, depth
, &r_u
->rid
[i
]))
2903 if (r_u
->ptr_attrs
!= 0) {
2904 if(!prs_uint32("num_attrs", ps
, depth
, &r_u
->num_attrs
))
2907 if (UNMARSHALLING(ps
) && r_u
->num_attrs
!= 0) {
2908 r_u
->attr
= PRS_ALLOC_MEM(ps
,uint32
,r_u
->num_attrs
);
2909 if (r_u
->attr
== NULL
)
2913 for (i
= 0; i
< r_u
->num_attrs
; i
++) {
2914 if(!prs_uint32("", ps
, depth
, &r_u
->attr
[i
]))
2920 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2926 /*******************************************************************
2927 inits a SAMR_Q_QUERY_USERGROUPS structure.
2928 ********************************************************************/
2930 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS
* q_u
,
2933 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2938 /*******************************************************************
2939 reads or writes a structure.
2940 ********************************************************************/
2942 BOOL
samr_io_q_query_usergroups(const char *desc
, SAMR_Q_QUERY_USERGROUPS
* q_u
,
2943 prs_struct
*ps
, int depth
)
2948 prs_debug(ps
, depth
, desc
, "samr_io_q_query_usergroups");
2954 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
2960 /*******************************************************************
2961 inits a SAMR_R_QUERY_USERGROUPS structure.
2962 ********************************************************************/
2964 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS
* r_u
,
2965 uint32 num_gids
, DOM_GID
* gid
,
2968 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2970 if (NT_STATUS_IS_OK(status
)) {
2972 r_u
->num_entries
= num_gids
;
2973 r_u
->ptr_1
= (num_gids
!= 0) ? 1 : 0;
2974 r_u
->num_entries2
= num_gids
;
2979 r_u
->num_entries
= 0;
2984 r_u
->status
= status
;
2987 /*******************************************************************
2988 reads or writes a structure.
2989 ********************************************************************/
2991 BOOL
samr_io_gids(const char *desc
, uint32
*num_gids
, DOM_GID
** gid
,
2992 prs_struct
*ps
, int depth
)
2998 prs_debug(ps
, depth
, desc
, "samr_io_gids");
3004 if(!prs_uint32("num_gids", ps
, depth
, num_gids
))
3007 if ((*num_gids
) != 0) {
3008 if (UNMARSHALLING(ps
)) {
3009 (*gid
) = PRS_ALLOC_MEM(ps
,DOM_GID
,*num_gids
);
3012 if ((*gid
) == NULL
) {
3016 for (i
= 0; i
< (*num_gids
); i
++) {
3017 if(!smb_io_gid("gids", &(*gid
)[i
], ps
, depth
))
3025 /*******************************************************************
3026 reads or writes a structure.
3027 ********************************************************************/
3029 BOOL
samr_io_r_query_usergroups(const char *desc
, SAMR_R_QUERY_USERGROUPS
* r_u
,
3030 prs_struct
*ps
, int depth
)
3035 prs_debug(ps
, depth
, desc
, "samr_io_r_query_usergroups");
3041 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
3044 if (r_u
->ptr_0
!= 0) {
3045 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
3047 if(!prs_uint32("ptr_1 ", ps
, depth
, &r_u
->ptr_1
))
3050 if (r_u
->num_entries
!= 0 && r_u
->ptr_1
!= 0) {
3051 if(!samr_io_gids("gids", &r_u
->num_entries2
, &r_u
->gid
, ps
, depth
))
3058 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3064 /*******************************************************************
3065 inits a SAMR_Q_ENUM_DOMAINS structure.
3066 ********************************************************************/
3068 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS
* q_e
,
3070 uint32 start_idx
, uint32 size
)
3072 DEBUG(5, ("init_samr_q_enum_domains\n"));
3076 q_e
->start_idx
= start_idx
;
3077 q_e
->max_size
= size
;
3080 /*******************************************************************
3081 reads or writes a structure.
3082 ********************************************************************/
3084 BOOL
samr_io_q_enum_domains(const char *desc
, SAMR_Q_ENUM_DOMAINS
* q_e
,
3085 prs_struct
*ps
, int depth
)
3090 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_domains");
3096 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
3099 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3101 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3107 /*******************************************************************
3108 inits a SAMR_R_ENUM_DOMAINS structure.
3109 ********************************************************************/
3111 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS
* r_u
,
3112 uint32 next_idx
, uint32 num_sam_entries
)
3114 DEBUG(5, ("init_samr_r_enum_domains\n"));
3116 r_u
->next_idx
= next_idx
;
3118 if (num_sam_entries
!= 0) {
3119 r_u
->ptr_entries1
= 1;
3120 r_u
->ptr_entries2
= 1;
3121 r_u
->num_entries2
= num_sam_entries
;
3122 r_u
->num_entries3
= num_sam_entries
;
3124 r_u
->num_entries4
= num_sam_entries
;
3126 r_u
->ptr_entries1
= 0;
3127 r_u
->num_entries2
= num_sam_entries
;
3128 r_u
->ptr_entries2
= 1;
3132 /*******************************************************************
3133 reads or writes a structure.
3134 ********************************************************************/
3136 BOOL
samr_io_r_enum_domains(const char *desc
, SAMR_R_ENUM_DOMAINS
* r_u
,
3137 prs_struct
*ps
, int depth
)
3144 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_domains");
3150 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3152 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3155 if (r_u
->ptr_entries1
!= 0) {
3156 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3158 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3160 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3163 if (UNMARSHALLING(ps
)) {
3164 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
,r_u
->num_entries2
);
3165 r_u
->uni_dom_name
= PRS_ALLOC_MEM(ps
,UNISTR2
,r_u
->num_entries2
);
3168 if ((r_u
->sam
== NULL
|| r_u
->uni_dom_name
== NULL
) && r_u
->num_entries2
!= 0) {
3169 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3170 r_u
->num_entries4
= 0;
3171 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3175 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3177 slprintf(tmp
, sizeof(tmp
) - 1, "dom[%d]", i
);
3178 if(!sam_io_sam_entry(tmp
, &r_u
->sam
[i
], ps
, depth
))
3182 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3184 slprintf(tmp
, sizeof(tmp
) - 1, "dom[%d]", i
);
3185 if(!smb_io_unistr2(tmp
, &r_u
->uni_dom_name
[i
],
3186 r_u
->sam
[i
].hdr_name
.buffer
, ps
,
3195 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3197 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3203 /*******************************************************************
3204 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3205 ********************************************************************/
3207 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS
* q_e
,
3209 uint32 start_idx
, uint32 size
)
3211 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3215 q_e
->start_idx
= start_idx
;
3216 q_e
->max_size
= size
;
3219 /*******************************************************************
3220 reads or writes a structure.
3221 ********************************************************************/
3223 BOOL
samr_io_q_enum_dom_groups(const char *desc
, SAMR_Q_ENUM_DOM_GROUPS
* q_e
,
3224 prs_struct
*ps
, int depth
)
3229 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_groups");
3235 if(!smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
))
3238 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3240 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3246 /*******************************************************************
3247 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3248 ********************************************************************/
3250 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS
* r_u
,
3251 uint32 next_idx
, uint32 num_sam_entries
)
3253 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3255 r_u
->next_idx
= next_idx
;
3257 if (num_sam_entries
!= 0) {
3258 r_u
->ptr_entries1
= 1;
3259 r_u
->ptr_entries2
= 1;
3260 r_u
->num_entries2
= num_sam_entries
;
3261 r_u
->num_entries3
= num_sam_entries
;
3263 r_u
->num_entries4
= num_sam_entries
;
3265 r_u
->ptr_entries1
= 0;
3266 r_u
->num_entries2
= num_sam_entries
;
3267 r_u
->ptr_entries2
= 1;
3271 /*******************************************************************
3272 reads or writes a structure.
3273 ********************************************************************/
3275 BOOL
samr_io_r_enum_dom_groups(const char *desc
, SAMR_R_ENUM_DOM_GROUPS
* r_u
,
3276 prs_struct
*ps
, int depth
)
3283 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_groups");
3289 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3291 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3294 if (r_u
->ptr_entries1
!= 0) {
3295 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3297 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3299 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3302 if (UNMARSHALLING(ps
)) {
3303 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
,r_u
->num_entries2
);
3304 r_u
->uni_grp_name
= PRS_ALLOC_MEM(ps
,UNISTR2
,r_u
->num_entries2
);
3307 if ((r_u
->sam
== NULL
|| r_u
->uni_grp_name
== NULL
) && r_u
->num_entries2
!= 0) {
3309 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3310 r_u
->num_entries4
= 0;
3311 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3315 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3316 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
3320 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3321 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
],
3322 r_u
->sam
[i
].hdr_name
.buffer
, ps
, depth
))
3329 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3331 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3337 /*******************************************************************
3338 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3339 ********************************************************************/
3341 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES
* q_e
,
3342 POLICY_HND
*pol
, uint32 start_idx
,
3345 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3349 q_e
->start_idx
= start_idx
;
3350 q_e
->max_size
= size
;
3354 /*******************************************************************
3355 reads or writes a structure.
3356 ********************************************************************/
3358 BOOL
samr_io_q_enum_dom_aliases(const char *desc
, SAMR_Q_ENUM_DOM_ALIASES
* q_e
,
3359 prs_struct
*ps
, int depth
)
3364 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_aliases");
3370 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
3373 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3375 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3381 /*******************************************************************
3382 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3383 ********************************************************************/
3385 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES
*r_u
, uint32 next_idx
, uint32 num_sam_entries
)
3387 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3389 r_u
->next_idx
= next_idx
;
3391 if (num_sam_entries
!= 0) {
3392 r_u
->ptr_entries1
= 1;
3393 r_u
->ptr_entries2
= 1;
3394 r_u
->num_entries2
= num_sam_entries
;
3395 r_u
->num_entries3
= num_sam_entries
;
3397 r_u
->num_entries4
= num_sam_entries
;
3399 r_u
->ptr_entries1
= 0;
3400 r_u
->num_entries2
= num_sam_entries
;
3401 r_u
->ptr_entries2
= 1;
3405 /*******************************************************************
3406 reads or writes a structure.
3407 ********************************************************************/
3409 BOOL
samr_io_r_enum_dom_aliases(const char *desc
, SAMR_R_ENUM_DOM_ALIASES
* r_u
,
3410 prs_struct
*ps
, int depth
)
3417 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_aliases");
3423 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3425 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3428 if (r_u
->ptr_entries1
!= 0) {
3429 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3431 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3433 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3436 if (UNMARSHALLING(ps
) && (r_u
->num_entries2
> 0)) {
3437 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
,r_u
->num_entries2
);
3438 r_u
->uni_grp_name
= PRS_ALLOC_MEM(ps
,UNISTR2
,r_u
->num_entries2
);
3441 if (r_u
->num_entries2
!= 0 &&
3442 (r_u
->sam
== NULL
|| r_u
->uni_grp_name
== NULL
)) {
3443 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3444 r_u
->num_entries4
= 0;
3445 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3449 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3450 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
3454 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3455 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
],
3456 r_u
->sam
[i
].hdr_name
.buffer
, ps
,
3464 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3466 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3472 /*******************************************************************
3473 inits a ALIAS_INFO1 structure.
3474 ********************************************************************/
3476 void init_samr_alias_info1(ALIAS_INFO1
* al1
, char *acct_name
, uint32 num_member
, char *acct_desc
)
3478 DEBUG(5, ("init_samr_alias_info1\n"));
3480 init_unistr4(&al1
->name
, acct_name
, UNI_FLAGS_NONE
);
3481 al1
->num_member
= num_member
;
3482 init_unistr4(&al1
->description
, acct_desc
, UNI_FLAGS_NONE
);
3485 /*******************************************************************
3486 reads or writes a structure.
3487 ********************************************************************/
3489 BOOL
samr_io_alias_info1(const char *desc
, ALIAS_INFO1
* al1
,
3490 prs_struct
*ps
, int depth
)
3495 prs_debug(ps
, depth
, desc
, "samr_io_alias_info1");
3501 if ( !prs_unistr4_hdr("name", ps
, depth
, &al1
->name
) )
3503 if ( !prs_uint32("num_member", ps
, depth
, &al1
->num_member
) )
3505 if ( !prs_unistr4_hdr("description", ps
, depth
, &al1
->description
) )
3508 if ( !prs_unistr4_str("name", ps
, depth
, &al1
->name
) )
3510 if ( !prs_align(ps
) )
3512 if ( !prs_unistr4_str("description", ps
, depth
, &al1
->description
) )
3514 if ( !prs_align(ps
) )
3520 /*******************************************************************
3521 inits a ALIAS_INFO3 structure.
3522 ********************************************************************/
3524 void init_samr_alias_info3(ALIAS_INFO3
* al3
, const char *acct_desc
)
3526 DEBUG(5, ("init_samr_alias_info3\n"));
3528 init_unistr4(&al3
->description
, acct_desc
, UNI_FLAGS_NONE
);
3531 /*******************************************************************
3532 reads or writes a structure.
3533 ********************************************************************/
3535 BOOL
samr_io_alias_info3(const char *desc
, ALIAS_INFO3
*al3
,
3536 prs_struct
*ps
, int depth
)
3541 prs_debug(ps
, depth
, desc
, "samr_io_alias_info3");
3547 if (!prs_unistr4("description", ps
, depth
, &al3
->description
))
3553 /*******************************************************************
3554 reads or writes a structure.
3555 ********************************************************************/
3557 BOOL
samr_alias_info_ctr(const char *desc
, prs_struct
*ps
, int depth
, ALIAS_INFO_CTR
* ctr
)
3562 prs_debug(ps
, depth
, desc
, "samr_alias_info_ctr");
3565 if ( !prs_uint16("level", ps
, depth
, &ctr
->level
) )
3570 switch (ctr
->level
) {
3572 if(!samr_io_alias_info1("alias_info1", &ctr
->alias
.info1
, ps
, depth
))
3576 if(!samr_io_alias_info3("alias_info3", &ctr
->alias
.info3
, ps
, depth
))
3580 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3587 /*******************************************************************
3588 inits a SAMR_Q_QUERY_ALIASINFO structure.
3589 ********************************************************************/
3591 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO
* q_e
,
3592 POLICY_HND
*pol
, uint32 switch_level
)
3594 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3597 q_e
->level
= switch_level
;
3600 /*******************************************************************
3601 reads or writes a structure.
3602 ********************************************************************/
3604 BOOL
samr_io_q_query_aliasinfo(const char *desc
, SAMR_Q_QUERY_ALIASINFO
*in
,
3605 prs_struct
*ps
, int depth
)
3610 prs_debug(ps
, depth
, desc
, "samr_io_q_query_aliasinfo");
3616 if ( !smb_io_pol_hnd("pol", &(in
->pol
), ps
, depth
) )
3619 if ( !prs_uint16("level", ps
, depth
, &in
->level
) )
3625 /*******************************************************************
3626 inits a SAMR_R_QUERY_ALIASINFO structure.
3627 ********************************************************************/
3629 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO
*out
,
3630 ALIAS_INFO_CTR
* ctr
, NTSTATUS status
)
3632 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3635 out
->status
= status
;
3638 /*******************************************************************
3639 reads or writes a structure.
3640 ********************************************************************/
3642 BOOL
samr_io_r_query_aliasinfo(const char *desc
, SAMR_R_QUERY_ALIASINFO
*out
,
3643 prs_struct
*ps
, int depth
)
3648 prs_debug(ps
, depth
, desc
, "samr_io_r_query_aliasinfo");
3654 if ( !prs_pointer("alias", ps
, depth
, (void**)&out
->ctr
, sizeof(ALIAS_INFO_CTR
), (PRS_POINTER_CAST
)samr_alias_info_ctr
))
3659 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
3665 /*******************************************************************
3666 inits a SAMR_Q_SET_ALIASINFO structure.
3667 ********************************************************************/
3669 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO
* q_u
,
3670 POLICY_HND
*hnd
, ALIAS_INFO_CTR
* ctr
)
3672 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3674 q_u
->alias_pol
= *hnd
;
3678 /*******************************************************************
3679 reads or writes a structure.
3680 ********************************************************************/
3682 BOOL
samr_io_q_set_aliasinfo(const char *desc
, SAMR_Q_SET_ALIASINFO
* q_u
,
3683 prs_struct
*ps
, int depth
)
3688 prs_debug(ps
, depth
, desc
, "samr_io_q_set_aliasinfo");
3694 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
3696 if(!samr_alias_info_ctr("ctr", ps
, depth
, &q_u
->ctr
))
3702 /*******************************************************************
3703 reads or writes a structure.
3704 ********************************************************************/
3706 BOOL
samr_io_r_set_aliasinfo(const char *desc
, SAMR_R_SET_ALIASINFO
* r_u
,
3707 prs_struct
*ps
, int depth
)
3712 prs_debug(ps
, depth
, desc
, "samr_io_r_set_aliasinfo");
3717 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3723 /*******************************************************************
3724 inits a SAMR_Q_QUERY_USERALIASES structure.
3725 ********************************************************************/
3727 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES
* q_u
,
3730 uint32
*ptr_sid
, DOM_SID2
* sid
)
3732 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3736 q_u
->num_sids1
= num_sids
;
3738 q_u
->num_sids2
= num_sids
;
3740 q_u
->ptr_sid
= ptr_sid
;
3744 /*******************************************************************
3745 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3746 ********************************************************************/
3748 BOOL
samr_io_q_query_useraliases(const char *desc
, SAMR_Q_QUERY_USERALIASES
* q_u
,
3749 prs_struct
*ps
, int depth
)
3757 prs_debug(ps
, depth
, desc
, "samr_io_q_query_useraliases");
3763 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
3766 if(!prs_uint32("num_sids1", ps
, depth
, &q_u
->num_sids1
))
3768 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
3774 if(!prs_uint32("num_sids2", ps
, depth
, &q_u
->num_sids2
))
3777 if (UNMARSHALLING(ps
) && (q_u
->num_sids2
!= 0)) {
3778 q_u
->ptr_sid
= PRS_ALLOC_MEM(ps
,uint32
,q_u
->num_sids2
);
3779 if (q_u
->ptr_sid
== NULL
)
3782 q_u
->sid
= PRS_ALLOC_MEM(ps
, DOM_SID2
, q_u
->num_sids2
);
3783 if (q_u
->sid
== NULL
)
3787 for (i
= 0; i
< q_u
->num_sids2
; i
++) {
3788 slprintf(tmp
, sizeof(tmp
) - 1, "ptr[%02d]", i
);
3789 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->ptr_sid
[i
]))
3793 for (i
= 0; i
< q_u
->num_sids2
; i
++) {
3794 if (q_u
->ptr_sid
[i
] != 0) {
3795 slprintf(tmp
, sizeof(tmp
) - 1, "sid[%02d]", i
);
3796 if(!smb_io_dom_sid2(tmp
, &q_u
->sid
[i
], ps
, depth
))
3804 /*******************************************************************
3805 inits a SAMR_R_QUERY_USERALIASES structure.
3806 ********************************************************************/
3808 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES
* r_u
,
3809 uint32 num_rids
, uint32
*rid
,
3812 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3814 if (NT_STATUS_IS_OK(status
)) {
3815 r_u
->num_entries
= num_rids
;
3817 r_u
->num_entries2
= num_rids
;
3821 r_u
->num_entries
= 0;
3823 r_u
->num_entries2
= 0;
3826 r_u
->status
= status
;
3829 /*******************************************************************
3830 reads or writes a structure.
3831 ********************************************************************/
3833 BOOL
samr_io_rids(const char *desc
, uint32
*num_rids
, uint32
**rid
,
3834 prs_struct
*ps
, int depth
)
3841 prs_debug(ps
, depth
, desc
, "samr_io_rids");
3847 if(!prs_uint32("num_rids", ps
, depth
, num_rids
))
3850 if ((*num_rids
) != 0) {
3851 if (UNMARSHALLING(ps
)) {
3853 (*rid
) = PRS_ALLOC_MEM(ps
,uint32
, *num_rids
);
3858 for (i
= 0; i
< (*num_rids
); i
++) {
3859 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d]", i
);
3860 if(!prs_uint32(tmp
, ps
, depth
, &((*rid
)[i
])))
3868 /*******************************************************************
3869 reads or writes a structure.
3870 ********************************************************************/
3872 BOOL
samr_io_r_query_useraliases(const char *desc
, SAMR_R_QUERY_USERALIASES
* r_u
,
3873 prs_struct
*ps
, int depth
)
3878 prs_debug(ps
, depth
, desc
, "samr_io_r_query_useraliases");
3884 if(!prs_uint32("num_entries", ps
, depth
, &r_u
->num_entries
))
3886 if(!prs_uint32("ptr ", ps
, depth
, &r_u
->ptr
))
3889 if (r_u
->ptr
!= 0) {
3890 if(!samr_io_rids("rids", &r_u
->num_entries2
, &r_u
->rid
, ps
, depth
))
3896 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3902 /*******************************************************************
3903 inits a SAMR_Q_OPEN_ALIAS structure.
3904 ********************************************************************/
3906 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS
* q_u
, POLICY_HND
*pol
,
3907 uint32 access_mask
, uint32 rid
)
3909 DEBUG(5, ("init_samr_q_open_alias\n"));
3911 q_u
->dom_pol
= *pol
;
3912 q_u
->access_mask
= access_mask
;
3913 q_u
->rid_alias
= rid
;
3916 /*******************************************************************
3917 reads or writes a structure.
3918 ********************************************************************/
3920 BOOL
samr_io_q_open_alias(const char *desc
, SAMR_Q_OPEN_ALIAS
* q_u
,
3921 prs_struct
*ps
, int depth
)
3926 prs_debug(ps
, depth
, desc
, "samr_io_q_open_alias");
3932 if(!smb_io_pol_hnd("domain_pol", &q_u
->dom_pol
, ps
, depth
))
3935 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
3937 if(!prs_uint32("rid_alias", ps
, depth
, &q_u
->rid_alias
))
3943 /*******************************************************************
3944 reads or writes a structure.
3945 ********************************************************************/
3947 BOOL
samr_io_r_open_alias(const char *desc
, SAMR_R_OPEN_ALIAS
* r_u
,
3948 prs_struct
*ps
, int depth
)
3953 prs_debug(ps
, depth
, desc
, "samr_io_r_open_alias");
3959 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
3962 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3968 /*******************************************************************
3969 inits a SAMR_Q_LOOKUP_RIDS structure.
3970 ********************************************************************/
3972 void init_samr_q_lookup_rids(TALLOC_CTX
*ctx
, SAMR_Q_LOOKUP_RIDS
* q_u
,
3973 POLICY_HND
*pol
, uint32 flags
,
3974 uint32 num_rids
, uint32
*rid
)
3976 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3980 q_u
->num_rids1
= num_rids
;
3983 q_u
->num_rids2
= num_rids
;
3984 q_u
->rid
= TALLOC_ZERO_ARRAY(ctx
, uint32
, num_rids
);
3985 if (q_u
->rid
== NULL
) {
3989 memcpy(q_u
->rid
, rid
, num_rids
* sizeof(q_u
->rid
[0]));
3993 /*******************************************************************
3994 reads or writes a structure.
3995 ********************************************************************/
3997 BOOL
samr_io_q_lookup_rids(const char *desc
, SAMR_Q_LOOKUP_RIDS
* q_u
,
3998 prs_struct
*ps
, int depth
)
4006 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_rids");
4009 if (UNMARSHALLING(ps
))
4015 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
4018 if(!prs_uint32("num_rids1", ps
, depth
, &q_u
->num_rids1
))
4020 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
4022 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
4024 if(!prs_uint32("num_rids2", ps
, depth
, &q_u
->num_rids2
))
4027 if (UNMARSHALLING(ps
) && (q_u
->num_rids2
!= 0)) {
4028 q_u
->rid
= PRS_ALLOC_MEM(ps
, uint32
, q_u
->num_rids2
);
4029 if (q_u
->rid
== NULL
)
4033 for (i
= 0; i
< q_u
->num_rids2
; i
++) {
4034 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
4035 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->rid
[i
]))
4042 /*******************************************************************
4043 inits a SAMR_R_LOOKUP_RIDS structure.
4044 ********************************************************************/
4046 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS
* r_u
,
4047 uint32 num_names
, UNIHDR
* hdr_name
,
4048 UNISTR2
*uni_name
, uint32
*type
)
4050 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4052 r_u
->hdr_name
= NULL
;
4053 r_u
->uni_name
= NULL
;
4056 if (num_names
!= 0) {
4057 r_u
->num_names1
= num_names
;
4059 r_u
->num_names2
= num_names
;
4061 r_u
->num_types1
= num_names
;
4063 r_u
->num_types2
= num_names
;
4065 r_u
->hdr_name
= hdr_name
;
4066 r_u
->uni_name
= uni_name
;
4069 r_u
->num_names1
= num_names
;
4071 r_u
->num_names2
= num_names
;
4073 r_u
->num_types1
= num_names
;
4075 r_u
->num_types2
= num_names
;
4079 /*******************************************************************
4080 reads or writes a structure.
4081 ********************************************************************/
4083 BOOL
samr_io_r_lookup_rids(const char *desc
, SAMR_R_LOOKUP_RIDS
* r_u
,
4084 prs_struct
*ps
, int depth
)
4091 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_rids");
4097 if(!prs_uint32("num_names1", ps
, depth
, &r_u
->num_names1
))
4099 if(!prs_uint32("ptr_names ", ps
, depth
, &r_u
->ptr_names
))
4102 if (r_u
->ptr_names
!= 0) {
4104 if(!prs_uint32("num_names2", ps
, depth
, &r_u
->num_names2
))
4108 if (UNMARSHALLING(ps
) && (r_u
->num_names2
!= 0)) {
4109 r_u
->hdr_name
= PRS_ALLOC_MEM(ps
, UNIHDR
, r_u
->num_names2
);
4110 if (r_u
->hdr_name
== NULL
)
4113 r_u
->uni_name
= PRS_ALLOC_MEM(ps
, UNISTR2
, r_u
->num_names2
);
4114 if (r_u
->uni_name
== NULL
)
4118 for (i
= 0; i
< r_u
->num_names2
; i
++) {
4119 slprintf(tmp
, sizeof(tmp
) - 1, "hdr[%02d] ", i
);
4120 if(!smb_io_unihdr("", &r_u
->hdr_name
[i
], ps
, depth
))
4123 for (i
= 0; i
< r_u
->num_names2
; i
++) {
4124 slprintf(tmp
, sizeof(tmp
) - 1, "str[%02d] ", i
);
4125 if(!smb_io_unistr2("", &r_u
->uni_name
[i
], r_u
->hdr_name
[i
].buffer
, ps
, depth
))
4133 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
4135 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
4138 if (r_u
->ptr_types
!= 0) {
4140 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
4143 if (UNMARSHALLING(ps
) && (r_u
->num_types2
!= 0)) {
4144 r_u
->type
= PRS_ALLOC_MEM(ps
, uint32
, r_u
->num_types2
);
4145 if (r_u
->type
== NULL
)
4149 for (i
= 0; i
< r_u
->num_types2
; i
++) {
4150 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
4151 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->type
[i
]))
4156 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4162 /*******************************************************************
4163 inits a SAMR_Q_OPEN_ALIAS structure.
4164 ********************************************************************/
4166 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS
* q_u
, POLICY_HND
*hnd
)
4168 DEBUG(5, ("init_samr_q_delete_alias\n"));
4170 q_u
->alias_pol
= *hnd
;
4173 /*******************************************************************
4174 reads or writes a structure.
4175 ********************************************************************/
4177 BOOL
samr_io_q_delete_alias(const char *desc
, SAMR_Q_DELETE_DOM_ALIAS
* q_u
,
4178 prs_struct
*ps
, int depth
)
4183 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_alias");
4189 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4195 /*******************************************************************
4196 reads or writes a structure.
4197 ********************************************************************/
4199 BOOL
samr_io_r_delete_alias(const char *desc
, SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4200 prs_struct
*ps
, int depth
)
4205 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_alias");
4211 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4213 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4219 /*******************************************************************
4220 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4221 ********************************************************************/
4223 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS
* q_u
,
4224 POLICY_HND
*hnd
, const char *acct_desc
)
4226 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4228 q_u
->dom_pol
= *hnd
;
4230 init_unistr2(&q_u
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
4231 init_uni_hdr(&q_u
->hdr_acct_desc
, &q_u
->uni_acct_desc
);
4233 q_u
->access_mask
= MAXIMUM_ALLOWED_ACCESS
;
4236 /*******************************************************************
4237 reads or writes a structure.
4238 ********************************************************************/
4240 BOOL
samr_io_q_create_dom_alias(const char *desc
, SAMR_Q_CREATE_DOM_ALIAS
* q_u
,
4241 prs_struct
*ps
, int depth
)
4246 prs_debug(ps
, depth
, desc
, "samr_io_q_create_dom_alias");
4252 if(!smb_io_pol_hnd("dom_pol", &q_u
->dom_pol
, ps
, depth
))
4255 if(!smb_io_unihdr("hdr_acct_desc", &q_u
->hdr_acct_desc
, ps
, depth
))
4257 if(!smb_io_unistr2("uni_acct_desc", &q_u
->uni_acct_desc
,
4258 q_u
->hdr_acct_desc
.buffer
, ps
, depth
))
4263 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
4269 /*******************************************************************
4270 reads or writes a structure.
4271 ********************************************************************/
4273 BOOL
samr_io_r_create_dom_alias(const char *desc
, SAMR_R_CREATE_DOM_ALIAS
* r_u
,
4274 prs_struct
*ps
, int depth
)
4279 prs_debug(ps
, depth
, desc
, "samr_io_r_create_dom_alias");
4285 if(!smb_io_pol_hnd("alias_pol", &r_u
->alias_pol
, ps
, depth
))
4288 if(!prs_uint32("rid", ps
, depth
, &r_u
->rid
))
4291 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4297 /*******************************************************************
4298 inits a SAMR_Q_ADD_ALIASMEM structure.
4299 ********************************************************************/
4301 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM
* q_u
, POLICY_HND
*hnd
,
4304 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4306 q_u
->alias_pol
= *hnd
;
4307 init_dom_sid2(&q_u
->sid
, sid
);
4310 /*******************************************************************
4311 reads or writes a structure.
4312 ********************************************************************/
4314 BOOL
samr_io_q_add_aliasmem(const char *desc
, SAMR_Q_ADD_ALIASMEM
* q_u
,
4315 prs_struct
*ps
, int depth
)
4320 prs_debug(ps
, depth
, desc
, "samr_io_q_add_aliasmem");
4326 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4328 if(!smb_io_dom_sid2("sid ", &q_u
->sid
, ps
, depth
))
4334 /*******************************************************************
4335 reads or writes a structure.
4336 ********************************************************************/
4338 BOOL
samr_io_r_add_aliasmem(const char *desc
, SAMR_R_ADD_ALIASMEM
* r_u
,
4339 prs_struct
*ps
, int depth
)
4344 prs_debug(ps
, depth
, desc
, "samr_io_r_add_aliasmem");
4350 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4356 /*******************************************************************
4357 inits a SAMR_Q_DEL_ALIASMEM structure.
4358 ********************************************************************/
4360 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM
* q_u
, POLICY_HND
*hnd
,
4363 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4365 q_u
->alias_pol
= *hnd
;
4366 init_dom_sid2(&q_u
->sid
, sid
);
4369 /*******************************************************************
4370 reads or writes a structure.
4371 ********************************************************************/
4373 BOOL
samr_io_q_del_aliasmem(const char *desc
, SAMR_Q_DEL_ALIASMEM
* q_u
,
4374 prs_struct
*ps
, int depth
)
4379 prs_debug(ps
, depth
, desc
, "samr_io_q_del_aliasmem");
4385 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4387 if(!smb_io_dom_sid2("sid ", &q_u
->sid
, ps
, depth
))
4393 /*******************************************************************
4394 reads or writes a structure.
4395 ********************************************************************/
4397 BOOL
samr_io_r_del_aliasmem(const char *desc
, SAMR_R_DEL_ALIASMEM
* r_u
,
4398 prs_struct
*ps
, int depth
)
4403 prs_debug(ps
, depth
, desc
, "samr_io_r_del_aliasmem");
4409 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4415 /*******************************************************************
4416 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4417 ********************************************************************/
4419 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS
* q_c
,
4422 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4424 q_c
->alias_pol
= *hnd
;
4427 /*******************************************************************
4428 reads or writes a structure.
4429 ********************************************************************/
4431 BOOL
samr_io_q_delete_dom_alias(const char *desc
, SAMR_Q_DELETE_DOM_ALIAS
* q_u
,
4432 prs_struct
*ps
, int depth
)
4437 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_alias");
4443 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4449 /*******************************************************************
4450 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4451 ********************************************************************/
4453 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4456 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4458 r_u
->status
= status
;
4461 /*******************************************************************
4462 reads or writes a structure.
4463 ********************************************************************/
4465 BOOL
samr_io_r_delete_dom_alias(const char *desc
, SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4466 prs_struct
*ps
, int depth
)
4471 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_alias");
4477 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4483 /*******************************************************************
4484 inits a SAMR_Q_QUERY_ALIASMEM structure.
4485 ********************************************************************/
4487 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM
* q_c
,
4490 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4492 q_c
->alias_pol
= *hnd
;
4495 /*******************************************************************
4496 reads or writes a structure.
4497 ********************************************************************/
4499 BOOL
samr_io_q_query_aliasmem(const char *desc
, SAMR_Q_QUERY_ALIASMEM
* q_u
,
4500 prs_struct
*ps
, int depth
)
4505 prs_debug(ps
, depth
, desc
, "samr_io_q_query_aliasmem");
4511 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4517 /*******************************************************************
4518 inits a SAMR_R_QUERY_ALIASMEM structure.
4519 ********************************************************************/
4521 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM
* r_u
,
4522 uint32 num_sids
, DOM_SID2
* sid
,
4525 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4527 if (NT_STATUS_IS_OK(status
)) {
4528 r_u
->num_sids
= num_sids
;
4529 r_u
->ptr
= (num_sids
!= 0) ? 1 : 0;
4530 r_u
->num_sids1
= num_sids
;
4538 r_u
->status
= status
;
4541 /*******************************************************************
4542 reads or writes a structure.
4543 ********************************************************************/
4545 BOOL
samr_io_r_query_aliasmem(const char *desc
, SAMR_R_QUERY_ALIASMEM
* r_u
,
4546 prs_struct
*ps
, int depth
)
4553 prs_debug(ps
, depth
, desc
, "samr_io_r_query_aliasmem");
4559 if(!prs_uint32("num_sids ", ps
, depth
, &r_u
->num_sids
))
4561 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
4564 if (r_u
->ptr
!= 0 && r_u
->num_sids
!= 0) {
4565 uint32
*ptr_sid
= NULL
;
4567 if(!prs_uint32("num_sids1", ps
, depth
, &r_u
->num_sids1
))
4570 ptr_sid
= TALLOC_ARRAY(ps
->mem_ctx
, uint32
, r_u
->num_sids1
);
4575 for (i
= 0; i
< r_u
->num_sids1
; i
++) {
4577 if(!prs_uint32("ptr_sid", ps
, depth
, &ptr_sid
[i
]))
4581 if (UNMARSHALLING(ps
)) {
4582 r_u
->sid
= TALLOC_ARRAY(ps
->mem_ctx
, DOM_SID2
, r_u
->num_sids1
);
4585 for (i
= 0; i
< r_u
->num_sids1
; i
++) {
4586 if (ptr_sid
[i
] != 0) {
4587 if(!smb_io_dom_sid2("sid", &r_u
->sid
[i
], ps
, depth
))
4595 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4601 /*******************************************************************
4602 inits a SAMR_Q_LOOKUP_NAMES structure.
4603 ********************************************************************/
4605 NTSTATUS
init_samr_q_lookup_names(TALLOC_CTX
*ctx
, SAMR_Q_LOOKUP_NAMES
* q_u
,
4606 POLICY_HND
*pol
, uint32 flags
,
4607 uint32 num_names
, const char **name
)
4611 DEBUG(5, ("init_samr_q_lookup_names\n"));
4615 q_u
->num_names1
= num_names
;
4618 q_u
->num_names2
= num_names
;
4620 if (!(q_u
->hdr_name
= TALLOC_ZERO_ARRAY(ctx
, UNIHDR
, num_names
)))
4621 return NT_STATUS_NO_MEMORY
;
4623 if (!(q_u
->uni_name
= TALLOC_ZERO_ARRAY(ctx
, UNISTR2
, num_names
)))
4624 return NT_STATUS_NO_MEMORY
;
4626 for (i
= 0; i
< num_names
; i
++) {
4627 init_unistr2(&q_u
->uni_name
[i
], name
[i
], UNI_FLAGS_NONE
); /* unicode string for machine account */
4628 init_uni_hdr(&q_u
->hdr_name
[i
], &q_u
->uni_name
[i
]); /* unicode header for user_name */
4631 return NT_STATUS_OK
;
4634 /*******************************************************************
4635 reads or writes a structure.
4636 ********************************************************************/
4638 BOOL
samr_io_q_lookup_names(const char *desc
, SAMR_Q_LOOKUP_NAMES
* q_u
,
4639 prs_struct
*ps
, int depth
)
4646 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_names");
4649 if (UNMARSHALLING(ps
))
4655 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
4658 if(!prs_uint32("num_names1", ps
, depth
, &q_u
->num_names1
))
4660 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
4662 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
4664 if(!prs_uint32("num_names2", ps
, depth
, &q_u
->num_names2
))
4667 if (UNMARSHALLING(ps
) && (q_u
->num_names2
!= 0)) {
4668 q_u
->hdr_name
= PRS_ALLOC_MEM(ps
, UNIHDR
, q_u
->num_names2
);
4669 q_u
->uni_name
= PRS_ALLOC_MEM(ps
, UNISTR2
, q_u
->num_names2
);
4670 if (!q_u
->hdr_name
|| !q_u
->uni_name
)
4674 for (i
= 0; i
< q_u
->num_names2
; i
++) {
4675 if(!smb_io_unihdr("", &q_u
->hdr_name
[i
], ps
, depth
))
4679 for (i
= 0; i
< q_u
->num_names2
; i
++) {
4680 if(!smb_io_unistr2("", &q_u
->uni_name
[i
], q_u
->hdr_name
[i
].buffer
, ps
, depth
))
4687 /*******************************************************************
4688 inits a SAMR_R_LOOKUP_NAMES structure.
4689 ********************************************************************/
4691 NTSTATUS
init_samr_r_lookup_names(TALLOC_CTX
*ctx
, SAMR_R_LOOKUP_NAMES
* r_u
,
4693 uint32
*rid
, uint32
*type
,
4696 DEBUG(5, ("init_samr_r_lookup_names\n"));
4698 if (NT_STATUS_IS_OK(status
) && (num_rids
!= 0)) {
4701 r_u
->num_types1
= num_rids
;
4703 r_u
->num_types2
= num_rids
;
4705 r_u
->num_rids1
= num_rids
;
4707 r_u
->num_rids2
= num_rids
;
4709 if (!(r_u
->rids
= TALLOC_ZERO_ARRAY(ctx
, uint32
, num_rids
)))
4710 return NT_STATUS_NO_MEMORY
;
4711 if (!(r_u
->types
= TALLOC_ZERO_ARRAY(ctx
, uint32
, num_rids
)))
4712 return NT_STATUS_NO_MEMORY
;
4714 if (!r_u
->rids
|| !r_u
->types
)
4717 for (i
= 0; i
< num_rids
; i
++) {
4718 r_u
->rids
[i
] = rid
[i
];
4719 r_u
->types
[i
] = type
[i
];
4724 r_u
->num_types1
= 0;
4726 r_u
->num_types2
= 0;
4736 r_u
->status
= status
;
4738 return NT_STATUS_OK
;
4741 /*******************************************************************
4742 reads or writes a structure.
4743 ********************************************************************/
4745 BOOL
samr_io_r_lookup_names(const char *desc
, SAMR_R_LOOKUP_NAMES
* r_u
,
4746 prs_struct
*ps
, int depth
)
4754 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_names");
4757 if (UNMARSHALLING(ps
))
4763 if(!prs_uint32("num_rids1", ps
, depth
, &r_u
->num_rids1
))
4765 if(!prs_uint32("ptr_rids ", ps
, depth
, &r_u
->ptr_rids
))
4768 if (r_u
->ptr_rids
!= 0) {
4769 if(!prs_uint32("num_rids2", ps
, depth
, &r_u
->num_rids2
))
4772 if (r_u
->num_rids2
!= r_u
->num_rids1
) {
4777 if (UNMARSHALLING(ps
))
4778 r_u
->rids
= PRS_ALLOC_MEM(ps
, uint32
, r_u
->num_rids2
);
4781 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4785 for (i
= 0; i
< r_u
->num_rids2
; i
++) {
4786 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
4787 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->rids
[i
]))
4792 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
4794 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
4797 if (r_u
->ptr_types
!= 0) {
4798 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
4801 if (r_u
->num_types2
!= r_u
->num_types1
) {
4806 if (UNMARSHALLING(ps
))
4807 r_u
->types
= PRS_ALLOC_MEM(ps
, uint32
, r_u
->num_types2
);
4810 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4814 for (i
= 0; i
< r_u
->num_types2
; i
++) {
4815 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
4816 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->types
[i
]))
4821 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4827 /*******************************************************************
4828 inits a SAMR_Q_DELETE_DOM_USER structure.
4829 ********************************************************************/
4831 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER
* q_c
,
4834 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4836 q_c
->user_pol
= *hnd
;
4839 /*******************************************************************
4840 reads or writes a structure.
4841 ********************************************************************/
4843 BOOL
samr_io_q_delete_dom_user(const char *desc
, SAMR_Q_DELETE_DOM_USER
* q_u
,
4844 prs_struct
*ps
, int depth
)
4849 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_user");
4855 if(!smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
))
4861 /*******************************************************************
4862 reads or writes a structure.
4863 ********************************************************************/
4865 BOOL
samr_io_r_delete_dom_user(const char *desc
, SAMR_R_DELETE_DOM_USER
* r_u
,
4866 prs_struct
*ps
, int depth
)
4871 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_user");
4877 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4879 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4885 /*******************************************************************
4886 reads or writes a structure.
4887 ********************************************************************/
4889 void init_samr_q_open_user(SAMR_Q_OPEN_USER
* q_u
,
4891 uint32 access_mask
, uint32 rid
)
4893 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4895 q_u
->domain_pol
= *pol
;
4896 q_u
->access_mask
= access_mask
;
4897 q_u
->user_rid
= rid
;
4900 /*******************************************************************
4901 reads or writes a structure.
4902 ********************************************************************/
4904 BOOL
samr_io_q_open_user(const char *desc
, SAMR_Q_OPEN_USER
* q_u
,
4905 prs_struct
*ps
, int depth
)
4910 prs_debug(ps
, depth
, desc
, "samr_io_q_open_user");
4916 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
4919 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
4921 if(!prs_uint32("user_rid ", ps
, depth
, &q_u
->user_rid
))
4927 /*******************************************************************
4928 reads or writes a structure.
4929 ********************************************************************/
4931 BOOL
samr_io_r_open_user(const char *desc
, SAMR_R_OPEN_USER
* r_u
,
4932 prs_struct
*ps
, int depth
)
4937 prs_debug(ps
, depth
, desc
, "samr_io_r_open_user");
4943 if(!smb_io_pol_hnd("user_pol", &r_u
->user_pol
, ps
, depth
))
4946 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4953 /*******************************************************************
4954 reads or writes a structure.
4955 ********************************************************************/
4957 void init_samr_q_create_user(SAMR_Q_CREATE_USER
* q_u
,
4960 uint32 acb_info
, uint32 access_mask
)
4962 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4964 q_u
->domain_pol
= *pol
;
4966 init_unistr2(&q_u
->uni_name
, name
, UNI_FLAGS_NONE
);
4967 init_uni_hdr(&q_u
->hdr_name
, &q_u
->uni_name
);
4969 q_u
->acb_info
= acb_info
;
4970 q_u
->access_mask
= access_mask
;
4973 /*******************************************************************
4974 reads or writes a structure.
4975 ********************************************************************/
4977 BOOL
samr_io_q_create_user(const char *desc
, SAMR_Q_CREATE_USER
* q_u
,
4978 prs_struct
*ps
, int depth
)
4983 prs_debug(ps
, depth
, desc
, "samr_io_q_create_user");
4989 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
4992 if(!smb_io_unihdr("hdr_name", &q_u
->hdr_name
, ps
, depth
))
4994 if(!smb_io_unistr2("uni_name", &q_u
->uni_name
, q_u
->hdr_name
.buffer
, ps
, depth
))
4999 if(!prs_uint32("acb_info ", ps
, depth
, &q_u
->acb_info
))
5001 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
5007 /*******************************************************************
5008 reads or writes a structure.
5009 ********************************************************************/
5011 BOOL
samr_io_r_create_user(const char *desc
, SAMR_R_CREATE_USER
* r_u
,
5012 prs_struct
*ps
, int depth
)
5017 prs_debug(ps
, depth
, desc
, "samr_io_r_create_user");
5023 if(!smb_io_pol_hnd("user_pol", &r_u
->user_pol
, ps
, depth
))
5026 if(!prs_uint32("access_granted", ps
, depth
, &r_u
->access_granted
))
5028 if(!prs_uint32("user_rid ", ps
, depth
, &r_u
->user_rid
))
5030 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
5036 /*******************************************************************
5037 inits a SAMR_Q_QUERY_USERINFO structure.
5038 ********************************************************************/
5040 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO
* q_u
,
5041 const POLICY_HND
*hnd
, uint16 switch_value
)
5043 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5046 q_u
->switch_value
= switch_value
;
5049 /*******************************************************************
5050 reads or writes a structure.
5051 ********************************************************************/
5053 BOOL
samr_io_q_query_userinfo(const char *desc
, SAMR_Q_QUERY_USERINFO
* q_u
,
5054 prs_struct
*ps
, int depth
)
5059 prs_debug(ps
, depth
, desc
, "samr_io_q_query_userinfo");
5065 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
5068 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
)) /* 0x0015 or 0x0011 */
5074 /*******************************************************************
5075 reads or writes a LOGON_HRS structure.
5076 ********************************************************************/
5078 static BOOL
sam_io_logon_hrs(const char *desc
, LOGON_HRS
* hrs
,
5079 prs_struct
*ps
, int depth
)
5084 prs_debug(ps
, depth
, desc
, "sam_io_logon_hrs");
5090 if(!prs_uint32("maxlen", ps
, depth
, &hrs
->max_len
))
5093 if(!prs_uint32("offset", ps
, depth
, &hrs
->offset
))
5096 if(!prs_uint32("len ", ps
, depth
, &hrs
->len
))
5099 if (hrs
->len
> sizeof(hrs
->hours
)) {
5100 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs
->len
));
5101 hrs
->len
= sizeof(hrs
->hours
);
5104 if(!prs_uint8s(False
, "hours", ps
, depth
, hrs
->hours
, hrs
->len
))
5110 /*******************************************************************
5111 inits a SAM_USER_INFO_18 structure.
5112 ********************************************************************/
5114 void init_sam_user_info18(SAM_USER_INFO_18
* usr
,
5115 const uint8 lm_pwd
[16], const uint8 nt_pwd
[16])
5117 DEBUG(5, ("init_sam_user_info18\n"));
5119 usr
->lm_pwd_active
=
5120 memcpy(usr
->lm_pwd
, lm_pwd
, sizeof(usr
->lm_pwd
)) ? 1 : 0;
5121 usr
->nt_pwd_active
=
5122 memcpy(usr
->nt_pwd
, nt_pwd
, sizeof(usr
->nt_pwd
)) ? 1 : 0;
5125 /*******************************************************************
5126 reads or writes a structure.
5127 ********************************************************************/
5129 static BOOL
sam_io_user_info18(const char *desc
, SAM_USER_INFO_18
* u
,
5130 prs_struct
*ps
, int depth
)
5135 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info18");
5141 if(!prs_uint8s(False
, "lm_pwd", ps
, depth
, u
->lm_pwd
, sizeof(u
->lm_pwd
)))
5143 if(!prs_uint8s(False
, "nt_pwd", ps
, depth
, u
->nt_pwd
, sizeof(u
->nt_pwd
)))
5146 if(!prs_uint8("lm_pwd_active", ps
, depth
, &u
->lm_pwd_active
))
5148 if(!prs_uint8("nt_pwd_active", ps
, depth
, &u
->nt_pwd_active
))
5154 /*******************************************************************
5155 inits a SAM_USER_INFO_7 structure.
5156 ********************************************************************/
5158 void init_sam_user_info7(SAM_USER_INFO_7
* usr
, const char *name
)
5160 DEBUG(5, ("init_sam_user_info7\n"));
5162 init_unistr2(&usr
->uni_name
, name
, UNI_FLAGS_NONE
); /* unicode string for name */
5163 init_uni_hdr(&usr
->hdr_name
, &usr
->uni_name
); /* unicode header for name */
5167 /*******************************************************************
5168 reads or writes a structure.
5169 ********************************************************************/
5171 static BOOL
sam_io_user_info7(const char *desc
, SAM_USER_INFO_7
* usr
,
5172 prs_struct
*ps
, int depth
)
5177 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info7");
5183 if(!smb_io_unihdr("unihdr", &usr
->hdr_name
, ps
, depth
))
5186 if(!smb_io_unistr2("unistr2", &usr
->uni_name
, True
, ps
, depth
))
5192 /*******************************************************************
5193 inits a SAM_USER_INFO_9 structure.
5194 ********************************************************************/
5196 void init_sam_user_info9(SAM_USER_INFO_9
* usr
, uint32 rid_group
)
5198 DEBUG(5, ("init_sam_user_info9\n"));
5200 usr
->rid_group
= rid_group
;
5203 /*******************************************************************
5204 reads or writes a structure.
5205 ********************************************************************/
5207 static BOOL
sam_io_user_info9(const char *desc
, SAM_USER_INFO_9
* usr
,
5208 prs_struct
*ps
, int depth
)
5213 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info9");
5219 if(!prs_uint32("rid_group", ps
, depth
, &usr
->rid_group
))
5225 /*******************************************************************
5226 inits a SAM_USER_INFO_16 structure.
5227 ********************************************************************/
5229 void init_sam_user_info16(SAM_USER_INFO_16
* usr
, uint32 acb_info
)
5231 DEBUG(5, ("init_sam_user_info16\n"));
5233 usr
->acb_info
= acb_info
;
5236 /*******************************************************************
5237 reads or writes a structure.
5238 ********************************************************************/
5240 static BOOL
sam_io_user_info16(const char *desc
, SAM_USER_INFO_16
* usr
,
5241 prs_struct
*ps
, int depth
)
5246 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info16");
5252 if(!prs_uint32("acb_info", ps
, depth
, &usr
->acb_info
))
5258 /*******************************************************************
5259 inits a SAM_USER_INFO_17 structure.
5260 ********************************************************************/
5262 void init_sam_user_info17(SAM_USER_INFO_17
* usr
,
5265 uint32 rid_user
, uint32 rid_group
, uint16 acct_ctrl
)
5267 DEBUG(5, ("init_sam_user_info17\n"));
5269 memcpy(&usr
->expiry
, expiry
, sizeof(usr
->expiry
)); /* expiry time or something? */
5270 ZERO_STRUCT(usr
->padding_1
); /* 0 - padding 24 bytes */
5272 usr
->padding_2
= 0; /* 0 - padding 4 bytes */
5274 usr
->ptr_1
= 1; /* pointer */
5275 ZERO_STRUCT(usr
->padding_3
); /* 0 - padding 32 bytes */
5276 usr
->padding_4
= 0; /* 0 - padding 4 bytes */
5278 usr
->ptr_2
= 1; /* pointer */
5279 usr
->padding_5
= 0; /* 0 - padding 4 bytes */
5281 usr
->ptr_3
= 1; /* pointer */
5282 ZERO_STRUCT(usr
->padding_6
); /* 0 - padding 32 bytes */
5284 usr
->rid_user
= rid_user
;
5285 usr
->rid_group
= rid_group
;
5287 usr
->acct_ctrl
= acct_ctrl
;
5288 usr
->unknown_3
= 0x0000;
5290 usr
->unknown_4
= 0x003f; /* 0x003f - 16 bit unknown */
5291 usr
->unknown_5
= 0x003c; /* 0x003c - 16 bit unknown */
5293 ZERO_STRUCT(usr
->padding_7
); /* 0 - padding 16 bytes */
5294 usr
->padding_8
= 0; /* 0 - padding 4 bytes */
5296 init_unistr2(&usr
->uni_mach_acct
, mach_acct
, UNI_FLAGS_NONE
); /* unicode string for machine account */
5297 init_uni_hdr(&usr
->hdr_mach_acct
, &usr
->uni_mach_acct
); /* unicode header for machine account */
5300 /*******************************************************************
5301 reads or writes a structure.
5302 ********************************************************************/
5304 static BOOL
sam_io_user_info17(const char *desc
, SAM_USER_INFO_17
* usr
,
5305 prs_struct
*ps
, int depth
)
5310 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_17");
5316 if(!prs_uint8s(False
, "padding_0", ps
, depth
, usr
->padding_0
, sizeof(usr
->padding_0
)))
5319 if(!smb_io_time("time", &usr
->expiry
, ps
, depth
))
5322 if(!prs_uint8s(False
, "padding_1", ps
, depth
, usr
->padding_1
, sizeof(usr
->padding_1
)))
5325 if(!smb_io_unihdr("unihdr", &usr
->hdr_mach_acct
, ps
, depth
))
5328 if(!prs_uint32("padding_2", ps
, depth
, &usr
->padding_2
))
5331 if(!prs_uint32("ptr_1 ", ps
, depth
, &usr
->ptr_1
))
5333 if(!prs_uint8s(False
, "padding_3", ps
, depth
, usr
->padding_3
, sizeof(usr
->padding_3
)))
5336 if(!prs_uint32("padding_4", ps
, depth
, &usr
->padding_4
))
5339 if(!prs_uint32("ptr_2 ", ps
, depth
, &usr
->ptr_2
))
5341 if(!prs_uint32("padding_5", ps
, depth
, &usr
->padding_5
))
5344 if(!prs_uint32("ptr_3 ", ps
, depth
, &usr
->ptr_3
))
5346 if(!prs_uint8s(False
, "padding_6", ps
, depth
, usr
->padding_6
,sizeof(usr
->padding_6
)))
5349 if(!prs_uint32("rid_user ", ps
, depth
, &usr
->rid_user
))
5351 if(!prs_uint32("rid_group", ps
, depth
, &usr
->rid_group
))
5353 if(!prs_uint16("acct_ctrl", ps
, depth
, &usr
->acct_ctrl
))
5355 if(!prs_uint16("unknown_3", ps
, depth
, &usr
->unknown_3
))
5357 if(!prs_uint16("unknown_4", ps
, depth
, &usr
->unknown_4
))
5359 if(!prs_uint16("unknown_5", ps
, depth
, &usr
->unknown_5
))
5362 if(!prs_uint8s(False
, "padding_7", ps
, depth
, usr
->padding_7
, sizeof(usr
->padding_7
)))
5365 if(!prs_uint32("padding_8", ps
, depth
, &(usr
->padding_8
)))
5368 if(!smb_io_unistr2("unistr2", &usr
->uni_mach_acct
, True
, ps
, depth
))
5374 if(!prs_uint8s(False
, "padding_9", ps
, depth
, usr
->padding_9
, sizeof(usr
->padding_9
)))
5380 /*************************************************************************
5382 *************************************************************************/
5384 void init_sam_user_info24(SAM_USER_INFO_24
* usr
, char newpass
[516], uint16 pw_len
)
5386 DEBUG(10, ("init_sam_user_info24:\n"));
5387 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5388 usr
->pw_len
= pw_len
;
5391 /*******************************************************************
5392 reads or writes a structure.
5393 ********************************************************************/
5395 static BOOL
sam_io_user_info24(const char *desc
, SAM_USER_INFO_24
* usr
,
5396 prs_struct
*ps
, int depth
)
5401 prs_debug(ps
, depth
, desc
, "sam_io_user_info24");
5407 if(!prs_uint8s(False
, "password", ps
, depth
, usr
->pass
,
5411 if (MARSHALLING(ps
) && (usr
->pw_len
!= 0)) {
5412 if (!prs_uint16("pw_len", ps
, depth
, &usr
->pw_len
))
5414 } else if (UNMARSHALLING(ps
)) {
5415 if (!prs_uint16("pw_len", ps
, depth
, &usr
->pw_len
))
5422 /*******************************************************************
5423 reads or writes a structure.
5424 ********************************************************************/
5426 static BOOL
sam_io_user_info26(const char *desc
, SAM_USER_INFO_26
* usr
,
5427 prs_struct
*ps
, int depth
)
5432 prs_debug(ps
, depth
, desc
, "sam_io_user_info26");
5438 if(!prs_uint8s(False
, "password", ps
, depth
, usr
->pass
,
5442 if (!prs_uint8("pw_len", ps
, depth
, &usr
->pw_len
))
5449 /*************************************************************************
5450 init_sam_user_info23
5452 unknown_6 = 0x0000 04ec
5454 *************************************************************************/
5456 void init_sam_user_info23W(SAM_USER_INFO_23
* usr
, NTTIME
* logon_time
, /* all zeros */
5457 NTTIME
* logoff_time
, /* all zeros */
5458 NTTIME
* kickoff_time
, /* all zeros */
5459 NTTIME
* pass_last_set_time
, /* all zeros */
5460 NTTIME
* pass_can_change_time
, /* all zeros */
5461 NTTIME
* pass_must_change_time
, /* all zeros */
5472 uint32 user_rid
, /* 0x0000 0000 */
5475 uint32 fields_present
,
5478 uint16 bad_password_count
,
5482 usr
->logon_time
= *logon_time
; /* all zeros */
5483 usr
->logoff_time
= *logoff_time
; /* all zeros */
5484 usr
->kickoff_time
= *kickoff_time
; /* all zeros */
5485 usr
->pass_last_set_time
= *pass_last_set_time
; /* all zeros */
5486 usr
->pass_can_change_time
= *pass_can_change_time
; /* all zeros */
5487 usr
->pass_must_change_time
= *pass_must_change_time
; /* all zeros */
5489 ZERO_STRUCT(usr
->nt_pwd
);
5490 ZERO_STRUCT(usr
->lm_pwd
);
5492 usr
->user_rid
= user_rid
; /* 0x0000 0000 */
5493 usr
->group_rid
= group_rid
;
5494 usr
->acb_info
= acb_info
;
5495 usr
->fields_present
= fields_present
; /* 09f8 27fa */
5497 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5498 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5500 if (nt_time_is_zero(pass_must_change_time
)) {
5501 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5503 usr
->passmustchange
=0;
5506 ZERO_STRUCT(usr
->padding1
);
5507 ZERO_STRUCT(usr
->padding2
);
5509 usr
->bad_password_count
= bad_password_count
;
5510 usr
->logon_count
= logon_count
;
5512 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5514 copy_unistr2(&usr
->uni_user_name
, user_name
);
5515 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
5517 copy_unistr2(&usr
->uni_full_name
, full_name
);
5518 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
5520 copy_unistr2(&usr
->uni_home_dir
, home_dir
);
5521 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
5523 copy_unistr2(&usr
->uni_dir_drive
, dir_drive
);
5524 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
5526 copy_unistr2(&usr
->uni_logon_script
, log_scr
);
5527 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
5529 copy_unistr2(&usr
->uni_profile_path
, prof_path
);
5530 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
5532 copy_unistr2(&usr
->uni_acct_desc
, desc
);
5533 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
5535 copy_unistr2(&usr
->uni_workstations
, wkstas
);
5536 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
5538 copy_unistr2(&usr
->uni_unknown_str
, unk_str
);
5539 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
5541 copy_unistr2(&usr
->uni_munged_dial
, mung_dial
);
5542 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
5544 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5547 /*************************************************************************
5548 init_sam_user_info23
5550 unknown_6 = 0x0000 04ec
5552 *************************************************************************/
5554 void init_sam_user_info23A(SAM_USER_INFO_23
* usr
, NTTIME
* logon_time
, /* all zeros */
5555 NTTIME
* logoff_time
, /* all zeros */
5556 NTTIME
* kickoff_time
, /* all zeros */
5557 NTTIME
* pass_last_set_time
, /* all zeros */
5558 NTTIME
* pass_can_change_time
, /* all zeros */
5559 NTTIME
* pass_must_change_time
, /* all zeros */
5560 char *user_name
, /* NULL */
5562 char *home_dir
, char *dir_drive
, char *log_scr
,
5563 char *prof_path
, const char *desc
, char *wkstas
,
5564 char *unk_str
, char *mung_dial
, uint32 user_rid
, /* 0x0000 0000 */
5565 uint32 group_rid
, uint32 acb_info
,
5566 uint32 fields_present
, uint16 logon_divs
,
5567 LOGON_HRS
* hrs
, uint16 bad_password_count
, uint16 logon_count
,
5570 DATA_BLOB blob
= base64_decode_data_blob(mung_dial
);
5572 usr
->logon_time
= *logon_time
; /* all zeros */
5573 usr
->logoff_time
= *logoff_time
; /* all zeros */
5574 usr
->kickoff_time
= *kickoff_time
; /* all zeros */
5575 usr
->pass_last_set_time
= *pass_last_set_time
; /* all zeros */
5576 usr
->pass_can_change_time
= *pass_can_change_time
; /* all zeros */
5577 usr
->pass_must_change_time
= *pass_must_change_time
; /* all zeros */
5579 ZERO_STRUCT(usr
->nt_pwd
);
5580 ZERO_STRUCT(usr
->lm_pwd
);
5582 usr
->user_rid
= user_rid
; /* 0x0000 0000 */
5583 usr
->group_rid
= group_rid
;
5584 usr
->acb_info
= acb_info
;
5585 usr
->fields_present
= fields_present
; /* 09f8 27fa */
5587 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5588 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5590 if (nt_time_is_zero(pass_must_change_time
)) {
5591 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5593 usr
->passmustchange
=0;
5596 ZERO_STRUCT(usr
->padding1
);
5597 ZERO_STRUCT(usr
->padding2
);
5599 usr
->bad_password_count
= bad_password_count
;
5600 usr
->logon_count
= logon_count
;
5602 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5604 init_unistr2(&usr
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
5605 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
5607 init_unistr2(&usr
->uni_full_name
, full_name
, UNI_FLAGS_NONE
);
5608 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
5610 init_unistr2(&usr
->uni_home_dir
, home_dir
, UNI_FLAGS_NONE
);
5611 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
5613 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, UNI_FLAGS_NONE
);
5614 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
5616 init_unistr2(&usr
->uni_logon_script
, log_scr
, UNI_FLAGS_NONE
);
5617 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
5619 init_unistr2(&usr
->uni_profile_path
, prof_path
, UNI_FLAGS_NONE
);
5620 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
5622 init_unistr2(&usr
->uni_acct_desc
, desc
, UNI_FLAGS_NONE
);
5623 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
5625 init_unistr2(&usr
->uni_workstations
, wkstas
, UNI_FLAGS_NONE
);
5626 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
5628 init_unistr2(&usr
->uni_unknown_str
, unk_str
, UNI_FLAGS_NONE
);
5629 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
5631 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &blob
);
5632 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
5634 data_blob_free(&blob
);
5637 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5639 ZERO_STRUCT(usr
->logon_hrs
);
5643 /*******************************************************************
5644 reads or writes a structure.
5645 ********************************************************************/
5647 static BOOL
sam_io_user_info23(const char *desc
, SAM_USER_INFO_23
* usr
,
5648 prs_struct
*ps
, int depth
)
5653 prs_debug(ps
, depth
, desc
, "sam_io_user_info23");
5659 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
5661 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
5663 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
5665 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
5667 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
5669 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
5672 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
5674 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
5676 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
5678 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
5680 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
5682 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
5684 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
5686 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
5688 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
5690 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
5693 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
5695 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
5698 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
5700 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
5702 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
5705 if(!prs_uint32("fields_present ", ps
, depth
, &usr
->fields_present
))
5707 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
5711 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
5714 if(!prs_uint16("bad_password_count ", ps
, depth
, &usr
->bad_password_count
))
5716 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
))
5719 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
5721 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
5723 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
5727 if(!prs_uint8s(False
, "password ", ps
, depth
, usr
->pass
, sizeof(usr
->pass
)))
5730 /* here begins pointed-to data */
5732 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
5735 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
5738 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
5741 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
5744 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
5747 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
5750 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
5753 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
5756 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
5759 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
))
5762 /* ok, this is only guess-work (as usual) */
5763 if (usr
->ptr_logon_hrs
) {
5764 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
5771 /*******************************************************************
5772 reads or writes a structure.
5773 NB. This structure is *definately* incorrect. It's my best guess
5774 currently for W2K SP2. The password field is encrypted in a different
5775 way than normal... And there are definately other problems. JRA.
5776 ********************************************************************/
5778 static BOOL
sam_io_user_info25(const char *desc
, SAM_USER_INFO_25
* usr
, prs_struct
*ps
, int depth
)
5783 prs_debug(ps
, depth
, desc
, "sam_io_user_info25");
5789 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
5791 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
5793 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
5795 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
5797 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
5799 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
5802 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
5804 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
5806 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
5808 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
5810 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
5812 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
5814 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
5816 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
5818 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
5820 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
5823 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
5825 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
5828 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
5830 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
5832 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
5835 if(!prs_uint32s(False
, "unknown_6 ", ps
, depth
, usr
->unknown_6
, 6))
5838 if(!prs_uint8s(False
, "password ", ps
, depth
, usr
->pass
, sizeof(usr
->pass
)))
5841 /* here begins pointed-to data */
5843 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
5846 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
5849 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
5852 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
5855 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
5858 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
5861 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
5864 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
5867 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
5870 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
))
5873 #if 0 /* JRA - unknown... */
5874 /* ok, this is only guess-work (as usual) */
5875 if (usr
->ptr_logon_hrs
) {
5876 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
5885 /*************************************************************************
5886 init_sam_user_info21W
5888 unknown_6 = 0x0000 04ec
5890 *************************************************************************/
5892 void init_sam_user_info21W(SAM_USER_INFO_21
* usr
,
5893 NTTIME
* logon_time
,
5894 NTTIME
* logoff_time
,
5895 NTTIME
* kickoff_time
,
5896 NTTIME
* pass_last_set_time
,
5897 NTTIME
* pass_can_change_time
,
5898 NTTIME
* pass_must_change_time
,
5914 uint32 fields_present
,
5917 uint16 bad_password_count
,
5920 usr
->logon_time
= *logon_time
;
5921 usr
->logoff_time
= *logoff_time
;
5922 usr
->kickoff_time
= *kickoff_time
;
5923 usr
->pass_last_set_time
= *pass_last_set_time
;
5924 usr
->pass_can_change_time
= *pass_can_change_time
;
5925 usr
->pass_must_change_time
= *pass_must_change_time
;
5927 memcpy(usr
->lm_pwd
, lm_pwd
, sizeof(usr
->lm_pwd
));
5928 memcpy(usr
->nt_pwd
, nt_pwd
, sizeof(usr
->nt_pwd
));
5930 usr
->user_rid
= user_rid
;
5931 usr
->group_rid
= group_rid
;
5932 usr
->acb_info
= acb_info
;
5933 usr
->fields_present
= fields_present
; /* 0x00ff ffff */
5935 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5936 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5937 usr
->bad_password_count
= bad_password_count
;
5938 usr
->logon_count
= logon_count
;
5940 if (nt_time_is_zero(pass_must_change_time
)) {
5941 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5943 usr
->passmustchange
=0;
5946 ZERO_STRUCT(usr
->padding1
);
5947 ZERO_STRUCT(usr
->padding2
);
5949 copy_unistr2(&usr
->uni_user_name
, user_name
);
5950 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
5952 copy_unistr2(&usr
->uni_full_name
, full_name
);
5953 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
5955 copy_unistr2(&usr
->uni_home_dir
, home_dir
);
5956 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
5958 copy_unistr2(&usr
->uni_dir_drive
, dir_drive
);
5959 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
5961 copy_unistr2(&usr
->uni_logon_script
, log_scr
);
5962 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
5964 copy_unistr2(&usr
->uni_profile_path
, prof_path
);
5965 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
5967 copy_unistr2(&usr
->uni_acct_desc
, desc
);
5968 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
5970 copy_unistr2(&usr
->uni_workstations
, wkstas
);
5971 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
5973 copy_unistr2(&usr
->uni_unknown_str
, unk_str
);
5974 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
5976 copy_unistr2(&usr
->uni_munged_dial
, mung_dial
);
5977 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
5980 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5982 ZERO_STRUCT(usr
->logon_hrs
);
5986 /*************************************************************************
5987 init_sam_user_info21
5989 unknown_6 = 0x0000 04ec
5991 *************************************************************************/
5993 NTSTATUS
init_sam_user_info21A(SAM_USER_INFO_21
*usr
, struct samu
*pw
, DOM_SID
*domain_sid
)
5995 NTTIME logon_time
, logoff_time
, kickoff_time
,
5996 pass_last_set_time
, pass_can_change_time
,
5997 pass_must_change_time
;
5999 const char* user_name
= pdb_get_username(pw
);
6000 const char* full_name
= pdb_get_fullname(pw
);
6001 const char* home_dir
= pdb_get_homedir(pw
);
6002 const char* dir_drive
= pdb_get_dir_drive(pw
);
6003 const char* logon_script
= pdb_get_logon_script(pw
);
6004 const char* profile_path
= pdb_get_profile_path(pw
);
6005 const char* description
= pdb_get_acct_desc(pw
);
6006 const char* workstations
= pdb_get_workstations(pw
);
6007 const char* munged_dial
= pdb_get_munged_dial(pw
);
6008 DATA_BLOB munged_dial_blob
;
6011 const DOM_SID
*user_sid
;
6014 const DOM_SID
*group_sid
;
6017 munged_dial_blob
= base64_decode_data_blob(munged_dial
);
6019 munged_dial_blob
= data_blob(NULL
, 0);
6022 /* Create NTTIME structs */
6023 unix_to_nt_time (&logon_time
, pdb_get_logon_time(pw
));
6024 unix_to_nt_time (&logoff_time
, pdb_get_logoff_time(pw
));
6025 unix_to_nt_time (&kickoff_time
, pdb_get_kickoff_time(pw
));
6026 unix_to_nt_time (&pass_last_set_time
, pdb_get_pass_last_set_time(pw
));
6027 unix_to_nt_time (&pass_can_change_time
, pdb_get_pass_can_change_time(pw
));
6028 unix_to_nt_time (&pass_must_change_time
,pdb_get_pass_must_change_time(pw
));
6030 /* structure assignment */
6031 usr
->logon_time
= logon_time
;
6032 usr
->logoff_time
= logoff_time
;
6033 usr
->kickoff_time
= kickoff_time
;
6034 usr
->pass_last_set_time
= pass_last_set_time
;
6035 usr
->pass_can_change_time
= pass_can_change_time
;
6036 usr
->pass_must_change_time
= pass_must_change_time
;
6038 ZERO_STRUCT(usr
->nt_pwd
);
6039 ZERO_STRUCT(usr
->lm_pwd
);
6041 user_sid
= pdb_get_user_sid(pw
);
6043 if (!sid_peek_check_rid(domain_sid
, user_sid
, &user_rid
)) {
6044 fstring user_sid_string
;
6045 fstring domain_sid_string
;
6046 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6047 "the domain sid %s. Failing operation.\n",
6049 sid_to_string(user_sid_string
, user_sid
),
6050 sid_to_string(domain_sid_string
, domain_sid
)));
6051 data_blob_free(&munged_dial_blob
);
6052 return NT_STATUS_UNSUCCESSFUL
;
6055 group_sid
= pdb_get_group_sid(pw
);
6057 if (!sid_peek_check_rid(domain_sid
, group_sid
, &group_rid
)) {
6058 fstring group_sid_string
;
6059 fstring domain_sid_string
;
6060 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6061 "which conflicts with the domain sid %s. Failing operation.\n",
6063 sid_to_string(group_sid_string
, group_sid
),
6064 sid_to_string(domain_sid_string
, domain_sid
)));
6065 data_blob_free(&munged_dial_blob
);
6066 return NT_STATUS_UNSUCCESSFUL
;
6069 usr
->user_rid
= user_rid
;
6070 usr
->group_rid
= group_rid
;
6071 usr
->acb_info
= pdb_get_acct_ctrl(pw
);
6074 Look at a user on a real NT4 PDC with usrmgr, press
6075 'ok'. Then you will see that fields_present is set to
6076 0x08f827fa. Look at the user immediately after that again,
6077 and you will see that 0x00fffff is returned. This solves
6078 the problem that you get access denied after having looked
6082 usr
->fields_present
= pdb_build_fields_present(pw
);
6084 usr
->logon_divs
= pdb_get_logon_divs(pw
);
6085 usr
->ptr_logon_hrs
= pdb_get_hours(pw
) ? 1 : 0;
6086 usr
->bad_password_count
= pdb_get_bad_password_count(pw
);
6087 usr
->logon_count
= pdb_get_logon_count(pw
);
6089 if (pdb_get_pass_must_change_time(pw
) == 0) {
6090 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
6092 usr
->passmustchange
=0;
6095 ZERO_STRUCT(usr
->padding1
);
6096 ZERO_STRUCT(usr
->padding2
);
6098 init_unistr2(&usr
->uni_user_name
, user_name
, UNI_STR_TERMINATE
);
6099 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
6101 init_unistr2(&usr
->uni_full_name
, full_name
, UNI_STR_TERMINATE
);
6102 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
6104 init_unistr2(&usr
->uni_home_dir
, home_dir
, UNI_STR_TERMINATE
);
6105 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
6107 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, UNI_STR_TERMINATE
);
6108 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
6110 init_unistr2(&usr
->uni_logon_script
, logon_script
, UNI_STR_TERMINATE
);
6111 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
6113 init_unistr2(&usr
->uni_profile_path
, profile_path
, UNI_STR_TERMINATE
);
6114 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
6116 init_unistr2(&usr
->uni_acct_desc
, description
, UNI_STR_TERMINATE
);
6117 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
6119 init_unistr2(&usr
->uni_workstations
, workstations
, UNI_STR_TERMINATE
);
6120 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
6122 init_unistr2(&usr
->uni_unknown_str
, NULL
, UNI_STR_TERMINATE
);
6123 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
6125 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &munged_dial_blob
);
6126 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
6127 data_blob_free(&munged_dial_blob
);
6129 if (pdb_get_hours(pw
)) {
6130 usr
->logon_hrs
.max_len
= 1260;
6131 usr
->logon_hrs
.offset
= 0;
6132 usr
->logon_hrs
.len
= pdb_get_hours_len(pw
);
6133 memcpy(&usr
->logon_hrs
.hours
, pdb_get_hours(pw
), MAX_HOURS_LEN
);
6135 usr
->logon_hrs
.max_len
= 1260;
6136 usr
->logon_hrs
.offset
= 0;
6137 usr
->logon_hrs
.len
= 0;
6138 memset(&usr
->logon_hrs
, 0xff, sizeof(usr
->logon_hrs
));
6141 return NT_STATUS_OK
;
6144 /*******************************************************************
6145 reads or writes a structure.
6146 ********************************************************************/
6148 static BOOL
sam_io_user_info21(const char *desc
, SAM_USER_INFO_21
* usr
,
6149 prs_struct
*ps
, int depth
)
6154 prs_debug(ps
, depth
, desc
, "sam_io_user_info21");
6160 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
6162 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
6164 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
,depth
))
6166 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
6168 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
,depth
))
6170 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
6173 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
6175 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
6177 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
6179 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
6181 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
6183 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
6185 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
6187 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
6189 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
6191 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
6194 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
6196 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
6199 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
6201 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
6203 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
6206 if(!prs_uint32("fields_present ", ps
, depth
, &usr
->fields_present
))
6208 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
6212 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
6215 if(!prs_uint16("bad_password_count ", ps
, depth
, &usr
->bad_password_count
))
6217 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
))
6220 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
6222 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
6224 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
6227 /* here begins pointed-to data */
6229 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
,usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
6231 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
6233 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
6235 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
6237 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
6239 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
6241 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
6243 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
6245 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
6247 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
,usr
->hdr_munged_dial
.buffer
, ps
, depth
)) /* worksations user can log on from */
6250 /* ok, this is only guess-work (as usual) */
6251 if (usr
->ptr_logon_hrs
) {
6252 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
6259 void init_sam_user_info20A(SAM_USER_INFO_20
*usr
, struct samu
*pw
)
6261 const char *munged_dial
= pdb_get_munged_dial(pw
);
6262 DATA_BLOB blob
= base64_decode_data_blob(munged_dial
);
6264 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &blob
);
6265 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
6266 data_blob_free(&blob
);
6269 /*******************************************************************
6270 reads or writes a structure.
6271 ********************************************************************/
6273 static BOOL
sam_io_user_info20(const char *desc
, SAM_USER_INFO_20
*usr
,
6274 prs_struct
*ps
, int depth
)
6279 prs_debug(ps
, depth
, desc
, "sam_io_user_info20");
6285 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
6288 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
,usr
->hdr_munged_dial
.buffer
, ps
, depth
)) /* worksations user can log on from */
6294 /*******************************************************************
6295 inits a SAM_USERINFO_CTR structure.
6296 ********************************************************************/
6298 NTSTATUS
make_samr_userinfo_ctr_usr21(TALLOC_CTX
*ctx
, SAM_USERINFO_CTR
* ctr
,
6299 uint16 switch_value
,
6300 SAM_USER_INFO_21
* usr
)
6302 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6304 ctr
->switch_value
= switch_value
;
6305 ctr
->info
.id
= NULL
;
6307 switch (switch_value
) {
6309 ctr
->info
.id16
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_16
);
6310 if (ctr
->info
.id16
== NULL
)
6311 return NT_STATUS_NO_MEMORY
;
6313 init_sam_user_info16(ctr
->info
.id16
, usr
->acb_info
);
6316 /* whoops - got this wrong. i think. or don't understand what's happening. */
6320 info
= (void *)&id11
;
6322 expire
.low
= 0xffffffff;
6323 expire
.high
= 0x7fffffff;
6325 ctr
->info
.id
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_17
);
6326 init_sam_user_info11(ctr
->info
.id17
, &expire
,
6327 "BROOKFIELDS$", /* name */
6328 0x03ef, /* user rid */
6329 0x201, /* group rid */
6330 0x0080); /* acb info */
6336 ctr
->info
.id18
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_18
);
6337 if (ctr
->info
.id18
== NULL
)
6338 return NT_STATUS_NO_MEMORY
;
6340 init_sam_user_info18(ctr
->info
.id18
, usr
->lm_pwd
, usr
->nt_pwd
);
6344 SAM_USER_INFO_21
*cusr
;
6345 cusr
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_21
);
6346 ctr
->info
.id21
= cusr
;
6347 if (ctr
->info
.id21
== NULL
)
6348 return NT_STATUS_NO_MEMORY
;
6349 memcpy(cusr
, usr
, sizeof(*usr
));
6350 memset(cusr
->lm_pwd
, 0, sizeof(cusr
->lm_pwd
));
6351 memset(cusr
->nt_pwd
, 0, sizeof(cusr
->nt_pwd
));
6355 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6356 return NT_STATUS_INVALID_INFO_CLASS
;
6359 return NT_STATUS_OK
;
6362 /*******************************************************************
6363 inits a SAM_USERINFO_CTR structure.
6364 ********************************************************************/
6366 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR
* ctr
, DATA_BLOB
*sess_key
,
6367 uint16 switch_value
, void *info
)
6369 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6371 ctr
->switch_value
= switch_value
;
6372 ctr
->info
.id
= info
;
6374 switch (switch_value
) {
6376 SamOEMhashBlob(ctr
->info
.id24
->pass
, 516, sess_key
);
6377 dump_data(100, (char *)sess_key
->data
, sess_key
->length
);
6378 dump_data(100, (char *)ctr
->info
.id24
->pass
, 516);
6381 SamOEMhashBlob(ctr
->info
.id23
->pass
, 516, sess_key
);
6382 dump_data(100, (char *)sess_key
->data
, sess_key
->length
);
6383 dump_data(100, (char *)ctr
->info
.id23
->pass
, 516);
6388 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value
));
6392 /*******************************************************************
6393 reads or writes a structure.
6394 ********************************************************************/
6396 static BOOL
samr_io_userinfo_ctr(const char *desc
, SAM_USERINFO_CTR
**ppctr
,
6397 prs_struct
*ps
, int depth
)
6400 SAM_USERINFO_CTR
*ctr
;
6402 prs_debug(ps
, depth
, desc
, "samr_io_userinfo_ctr");
6405 if (UNMARSHALLING(ps
)) {
6406 ctr
= PRS_ALLOC_MEM(ps
,SAM_USERINFO_CTR
,1);
6414 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6416 if(!prs_uint16("switch_value", ps
, depth
, &ctr
->switch_value
))
6423 switch (ctr
->switch_value
) {
6425 if (UNMARSHALLING(ps
))
6426 ctr
->info
.id7
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_7
,1);
6427 if (ctr
->info
.id7
== NULL
) {
6428 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6431 ret
= sam_io_user_info7("", ctr
->info
.id7
, ps
, depth
);
6434 if (UNMARSHALLING(ps
))
6435 ctr
->info
.id9
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_9
,1);
6436 if (ctr
->info
.id9
== NULL
) {
6437 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6440 ret
= sam_io_user_info9("", ctr
->info
.id9
, ps
, depth
);
6443 if (UNMARSHALLING(ps
))
6444 ctr
->info
.id16
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_16
,1);
6445 if (ctr
->info
.id16
== NULL
) {
6446 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6449 ret
= sam_io_user_info16("", ctr
->info
.id16
, ps
, depth
);
6452 if (UNMARSHALLING(ps
))
6453 ctr
->info
.id17
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_17
,1);
6455 if (ctr
->info
.id17
== NULL
) {
6456 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6459 ret
= sam_io_user_info17("", ctr
->info
.id17
, ps
, depth
);
6462 if (UNMARSHALLING(ps
))
6463 ctr
->info
.id18
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_18
,1);
6465 if (ctr
->info
.id18
== NULL
) {
6466 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6469 ret
= sam_io_user_info18("", ctr
->info
.id18
, ps
, depth
);
6472 if (UNMARSHALLING(ps
))
6473 ctr
->info
.id20
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_20
,1);
6475 if (ctr
->info
.id20
== NULL
) {
6476 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6479 ret
= sam_io_user_info20("", ctr
->info
.id20
, ps
, depth
);
6482 if (UNMARSHALLING(ps
))
6483 ctr
->info
.id21
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_21
,1);
6485 if (ctr
->info
.id21
== NULL
) {
6486 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6489 ret
= sam_io_user_info21("", ctr
->info
.id21
, ps
, depth
);
6492 if (UNMARSHALLING(ps
))
6493 ctr
->info
.id23
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_23
,1);
6495 if (ctr
->info
.id23
== NULL
) {
6496 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6499 ret
= sam_io_user_info23("", ctr
->info
.id23
, ps
, depth
);
6502 if (UNMARSHALLING(ps
))
6503 ctr
->info
.id24
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_24
,1);
6505 if (ctr
->info
.id24
== NULL
) {
6506 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6509 ret
= sam_io_user_info24("", ctr
->info
.id24
, ps
, depth
);
6512 if (UNMARSHALLING(ps
))
6513 ctr
->info
.id25
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_25
,1);
6515 if (ctr
->info
.id25
== NULL
) {
6516 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6519 ret
= sam_io_user_info25("", ctr
->info
.id25
, ps
, depth
);
6522 if (UNMARSHALLING(ps
))
6523 ctr
->info
.id26
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_26
,1);
6525 if (ctr
->info
.id26
== NULL
) {
6526 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6529 ret
= sam_io_user_info26("", ctr
->info
.id26
, ps
, depth
);
6532 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr
->switch_value
));
6540 /*******************************************************************
6541 inits a SAMR_R_QUERY_USERINFO structure.
6542 ********************************************************************/
6544 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO
* r_u
,
6545 SAM_USERINFO_CTR
* ctr
, NTSTATUS status
)
6547 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6552 if (NT_STATUS_IS_OK(status
)) {
6557 r_u
->status
= status
; /* return status */
6560 /*******************************************************************
6561 reads or writes a structure.
6562 ********************************************************************/
6564 BOOL
samr_io_r_query_userinfo(const char *desc
, SAMR_R_QUERY_USERINFO
* r_u
,
6565 prs_struct
*ps
, int depth
)
6570 prs_debug(ps
, depth
, desc
, "samr_io_r_query_userinfo");
6576 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
6579 if (r_u
->ptr
!= 0) {
6580 if(!samr_io_userinfo_ctr("ctr", &r_u
->ctr
, ps
, depth
))
6586 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6592 /*******************************************************************
6593 inits a SAMR_Q_SET_USERINFO structure.
6594 ********************************************************************/
6596 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO
* q_u
,
6597 const POLICY_HND
*hnd
, DATA_BLOB
*sess_key
,
6598 uint16 switch_value
, void *info
)
6600 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6603 q_u
->switch_value
= switch_value
;
6604 init_samr_userinfo_ctr(q_u
->ctr
, sess_key
, switch_value
, info
);
6607 /*******************************************************************
6608 reads or writes a structure.
6609 ********************************************************************/
6611 BOOL
samr_io_q_set_userinfo(const char *desc
, SAMR_Q_SET_USERINFO
* q_u
,
6612 prs_struct
*ps
, int depth
)
6617 prs_debug(ps
, depth
, desc
, "samr_io_q_set_userinfo");
6623 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
6625 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
6627 if(!samr_io_userinfo_ctr("ctr", &q_u
->ctr
, ps
, depth
))
6633 /*******************************************************************
6634 inits a SAMR_R_SET_USERINFO structure.
6635 ********************************************************************/
6637 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO
* r_u
, NTSTATUS status
)
6639 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6641 r_u
->status
= status
; /* return status */
6644 /*******************************************************************
6645 reads or writes a structure.
6646 ********************************************************************/
6648 BOOL
samr_io_r_set_userinfo(const char *desc
, SAMR_R_SET_USERINFO
* r_u
,
6649 prs_struct
*ps
, int depth
)
6654 prs_debug(ps
, depth
, desc
, "samr_io_r_set_userinfo");
6660 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6666 /*******************************************************************
6667 inits a SAMR_Q_SET_USERINFO2 structure.
6668 ********************************************************************/
6670 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2
* q_u
,
6671 const POLICY_HND
*hnd
, DATA_BLOB
*sess_key
,
6672 uint16 switch_value
, SAM_USERINFO_CTR
* ctr
)
6674 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6677 q_u
->switch_value
= switch_value
;
6680 if (q_u
->ctr
!= NULL
)
6681 q_u
->ctr
->switch_value
= switch_value
;
6683 switch (switch_value
) {
6685 SamOEMhashBlob(ctr
->info
.id18
->lm_pwd
, 16, sess_key
);
6686 SamOEMhashBlob(ctr
->info
.id18
->nt_pwd
, 16, sess_key
);
6687 dump_data(100, (char *)sess_key
->data
, sess_key
->length
);
6688 dump_data(100, (char *)ctr
->info
.id18
->lm_pwd
, 16);
6689 dump_data(100, (char *)ctr
->info
.id18
->nt_pwd
, 16);
6694 /*******************************************************************
6695 reads or writes a structure.
6696 ********************************************************************/
6698 BOOL
samr_io_q_set_userinfo2(const char *desc
, SAMR_Q_SET_USERINFO2
* q_u
,
6699 prs_struct
*ps
, int depth
)
6704 prs_debug(ps
, depth
, desc
, "samr_io_q_set_userinfo2");
6710 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
6713 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
6715 if(!samr_io_userinfo_ctr("ctr", &q_u
->ctr
, ps
, depth
))
6721 /*******************************************************************
6722 inits a SAMR_R_SET_USERINFO2 structure.
6723 ********************************************************************/
6725 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2
* r_u
, NTSTATUS status
)
6727 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6729 r_u
->status
= status
; /* return status */
6732 /*******************************************************************
6733 reads or writes a structure.
6734 ********************************************************************/
6736 BOOL
samr_io_r_set_userinfo2(const char *desc
, SAMR_R_SET_USERINFO2
* r_u
,
6737 prs_struct
*ps
, int depth
)
6742 prs_debug(ps
, depth
, desc
, "samr_io_r_set_userinfo2");
6748 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6754 /*******************************************************************
6755 inits a SAMR_Q_CONNECT structure.
6756 ********************************************************************/
6758 void init_samr_q_connect(SAMR_Q_CONNECT
* q_u
,
6759 char *srv_name
, uint32 access_mask
)
6761 DEBUG(5, ("init_samr_q_connect\n"));
6763 /* make PDC server name \\server */
6764 q_u
->ptr_srv_name
= (srv_name
!= NULL
&& *srv_name
) ? 1 : 0;
6765 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
6767 /* example values: 0x0000 0002 */
6768 q_u
->access_mask
= access_mask
;
6771 /*******************************************************************
6772 reads or writes a structure.
6773 ********************************************************************/
6775 BOOL
samr_io_q_connect(const char *desc
, SAMR_Q_CONNECT
* q_u
,
6776 prs_struct
*ps
, int depth
)
6781 prs_debug(ps
, depth
, desc
, "samr_io_q_connect");
6787 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
6789 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
6794 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6800 /*******************************************************************
6801 reads or writes a structure.
6802 ********************************************************************/
6804 BOOL
samr_io_r_connect(const char *desc
, SAMR_R_CONNECT
* r_u
,
6805 prs_struct
*ps
, int depth
)
6810 prs_debug(ps
, depth
, desc
, "samr_io_r_connect");
6816 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6819 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6825 /*******************************************************************
6826 inits a SAMR_Q_CONNECT4 structure.
6827 ********************************************************************/
6829 void init_samr_q_connect4(SAMR_Q_CONNECT4
* q_u
,
6830 char *srv_name
, uint32 access_mask
)
6832 DEBUG(5, ("init_samr_q_connect4\n"));
6834 /* make PDC server name \\server */
6835 q_u
->ptr_srv_name
= (srv_name
!= NULL
&& *srv_name
) ? 1 : 0;
6836 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
6838 /* Only value we've seen, possibly an address type ? */
6841 /* example values: 0x0000 0002 */
6842 q_u
->access_mask
= access_mask
;
6845 /*******************************************************************
6846 reads or writes a structure.
6847 ********************************************************************/
6849 BOOL
samr_io_q_connect4(const char *desc
, SAMR_Q_CONNECT4
* q_u
,
6850 prs_struct
*ps
, int depth
)
6855 prs_debug(ps
, depth
, desc
, "samr_io_q_connect4");
6861 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
6863 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
6868 if(!prs_uint32("unk_0", ps
, depth
, &q_u
->unk_0
))
6870 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6876 /*******************************************************************
6877 reads or writes a structure.
6878 ********************************************************************/
6880 BOOL
samr_io_r_connect4(const char *desc
, SAMR_R_CONNECT4
* r_u
,
6881 prs_struct
*ps
, int depth
)
6886 prs_debug(ps
, depth
, desc
, "samr_io_r_connect4");
6892 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6895 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6901 /*******************************************************************
6902 inits a SAMR_Q_CONNECT5 structure.
6903 ********************************************************************/
6905 void init_samr_q_connect5(SAMR_Q_CONNECT5
* q_u
,
6906 char *srv_name
, uint32 access_mask
)
6908 DEBUG(5, ("init_samr_q_connect5\n"));
6910 /* make PDC server name \\server */
6911 q_u
->ptr_srv_name
= (srv_name
!= NULL
&& *srv_name
) ? 1 : 0;
6912 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
6914 /* example values: 0x0000 0002 */
6915 q_u
->access_mask
= access_mask
;
6918 q_u
->info1_unk1
= 3;
6919 q_u
->info1_unk2
= 0;
6922 /*******************************************************************
6923 inits a SAMR_R_CONNECT5 structure.
6924 ********************************************************************/
6926 void init_samr_r_connect5(SAMR_R_CONNECT5
* r_u
, POLICY_HND
*pol
, NTSTATUS status
)
6928 DEBUG(5, ("init_samr_q_connect5\n"));
6931 r_u
->info1_unk1
= 3;
6932 r_u
->info1_unk2
= 0;
6934 r_u
->connect_pol
= *pol
;
6935 r_u
->status
= status
;
6938 /*******************************************************************
6939 reads or writes a structure.
6940 ********************************************************************/
6942 BOOL
samr_io_q_connect5(const char *desc
, SAMR_Q_CONNECT5
* q_u
,
6943 prs_struct
*ps
, int depth
)
6948 prs_debug(ps
, depth
, desc
, "samr_io_q_connect5");
6954 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
6956 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
6961 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6964 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6966 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6969 if(!prs_uint32("info1_unk1", ps
, depth
, &q_u
->info1_unk1
))
6971 if(!prs_uint32("info1_unk2", ps
, depth
, &q_u
->info1_unk2
))
6977 /*******************************************************************
6978 reads or writes a structure.
6979 ********************************************************************/
6981 BOOL
samr_io_r_connect5(const char *desc
, SAMR_R_CONNECT5
* r_u
,
6982 prs_struct
*ps
, int depth
)
6987 prs_debug(ps
, depth
, desc
, "samr_io_r_connect5");
6993 if(!prs_uint32("level", ps
, depth
, &r_u
->level
))
6995 if(!prs_uint32("level", ps
, depth
, &r_u
->level
))
6997 if(!prs_uint32("info1_unk1", ps
, depth
, &r_u
->info1_unk1
))
6999 if(!prs_uint32("info1_unk2", ps
, depth
, &r_u
->info1_unk2
))
7002 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
7005 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7011 /*******************************************************************
7012 inits a SAMR_Q_CONNECT_ANON structure.
7013 ********************************************************************/
7015 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON
* q_u
)
7017 DEBUG(5, ("init_samr_q_connect_anon\n"));
7020 q_u
->unknown_0
= 0x5c; /* server name (?!!) */
7021 q_u
->access_mask
= MAXIMUM_ALLOWED_ACCESS
;
7024 /*******************************************************************
7025 reads or writes a structure.
7026 ********************************************************************/
7028 BOOL
samr_io_q_connect_anon(const char *desc
, SAMR_Q_CONNECT_ANON
* q_u
,
7029 prs_struct
*ps
, int depth
)
7034 prs_debug(ps
, depth
, desc
, "samr_io_q_connect_anon");
7040 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
7043 if(!prs_uint16("unknown_0", ps
, depth
, &q_u
->unknown_0
))
7048 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
7054 /*******************************************************************
7055 reads or writes a structure.
7056 ********************************************************************/
7058 BOOL
samr_io_r_connect_anon(const char *desc
, SAMR_R_CONNECT_ANON
* r_u
,
7059 prs_struct
*ps
, int depth
)
7064 prs_debug(ps
, depth
, desc
, "samr_io_r_connect_anon");
7070 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
7073 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7079 /*******************************************************************
7080 inits a SAMR_Q_GET_DOM_PWINFO structure.
7081 ********************************************************************/
7083 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO
* q_u
,
7086 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7089 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_FLAGS_NONE
);
7090 init_uni_hdr(&q_u
->hdr_srv_name
, &q_u
->uni_srv_name
);
7093 /*******************************************************************
7094 reads or writes a structure.
7095 ********************************************************************/
7097 BOOL
samr_io_q_get_dom_pwinfo(const char *desc
, SAMR_Q_GET_DOM_PWINFO
* q_u
,
7098 prs_struct
*ps
, int depth
)
7103 prs_debug(ps
, depth
, desc
, "samr_io_q_get_dom_pwinfo");
7109 if(!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
7111 if (q_u
->ptr
!= 0) {
7112 if(!smb_io_unihdr("", &q_u
->hdr_srv_name
, ps
, depth
))
7114 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->hdr_srv_name
.buffer
, ps
, depth
))
7121 /*******************************************************************
7122 reads or writes a structure.
7123 ********************************************************************/
7125 BOOL
samr_io_r_get_dom_pwinfo(const char *desc
, SAMR_R_GET_DOM_PWINFO
* r_u
,
7126 prs_struct
*ps
, int depth
)
7131 prs_debug(ps
, depth
, desc
, "samr_io_r_get_dom_pwinfo");
7137 if(!prs_uint16("min_pwd_length", ps
, depth
, &r_u
->min_pwd_length
))
7141 if(!prs_uint32("password_properties", ps
, depth
, &r_u
->password_properties
))
7144 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7150 /*******************************************************************
7151 make a SAMR_ENC_PASSWD structure.
7152 ********************************************************************/
7154 void init_enc_passwd(SAMR_ENC_PASSWD
* pwd
, const char pass
[512])
7162 memcpy(pwd
->pass
, pass
, sizeof(pwd
->pass
));
7166 /*******************************************************************
7167 reads or writes a SAMR_ENC_PASSWD structure.
7168 ********************************************************************/
7170 BOOL
samr_io_enc_passwd(const char *desc
, SAMR_ENC_PASSWD
* pwd
,
7171 prs_struct
*ps
, int depth
)
7176 prs_debug(ps
, depth
, desc
, "samr_io_enc_passwd");
7182 if(!prs_uint32("ptr", ps
, depth
, &pwd
->ptr
))
7185 if (pwd
->ptr
!= 0) {
7186 if(!prs_uint8s(False
, "pwd", ps
, depth
, pwd
->pass
, sizeof(pwd
->pass
)))
7193 /*******************************************************************
7194 inits a SAMR_ENC_HASH structure.
7195 ********************************************************************/
7197 void init_enc_hash(SAMR_ENC_HASH
* hsh
, const uchar hash
[16])
7205 memcpy(hsh
->hash
, hash
, sizeof(hsh
->hash
));
7209 /*******************************************************************
7210 reads or writes a SAMR_ENC_HASH structure.
7211 ********************************************************************/
7213 BOOL
samr_io_enc_hash(const char *desc
, SAMR_ENC_HASH
* hsh
,
7214 prs_struct
*ps
, int depth
)
7219 prs_debug(ps
, depth
, desc
, "samr_io_enc_hash");
7225 if(!prs_uint32("ptr ", ps
, depth
, &hsh
->ptr
))
7227 if (hsh
->ptr
!= 0) {
7228 if(!prs_uint8s(False
, "hash", ps
, depth
, hsh
->hash
,sizeof(hsh
->hash
)))
7235 /*******************************************************************
7236 inits a SAMR_Q_CHGPASSWD_USER structure.
7237 ********************************************************************/
7239 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER
* q_u
,
7240 const char *dest_host
, const char *user_name
,
7241 const uchar nt_newpass
[516],
7242 const uchar nt_oldhash
[16],
7243 const uchar lm_newpass
[516],
7244 const uchar lm_oldhash
[16])
7246 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7249 init_unistr2(&q_u
->uni_dest_host
, dest_host
, UNI_FLAGS_NONE
);
7250 init_uni_hdr(&q_u
->hdr_dest_host
, &q_u
->uni_dest_host
);
7252 init_unistr2(&q_u
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
7253 init_uni_hdr(&q_u
->hdr_user_name
, &q_u
->uni_user_name
);
7255 init_enc_passwd(&q_u
->nt_newpass
, (const char *)nt_newpass
);
7256 init_enc_hash(&q_u
->nt_oldhash
, nt_oldhash
);
7258 q_u
->unknown
= 0x01;
7260 init_enc_passwd(&q_u
->lm_newpass
, (const char *)lm_newpass
);
7261 init_enc_hash(&q_u
->lm_oldhash
, lm_oldhash
);
7264 /*******************************************************************
7265 reads or writes a structure.
7266 ********************************************************************/
7268 BOOL
samr_io_q_chgpasswd_user(const char *desc
, SAMR_Q_CHGPASSWD_USER
* q_u
,
7269 prs_struct
*ps
, int depth
)
7274 prs_debug(ps
, depth
, desc
, "samr_io_q_chgpasswd_user");
7280 if(!prs_uint32("ptr_0", ps
, depth
, &q_u
->ptr_0
))
7283 if(!smb_io_unihdr("", &q_u
->hdr_dest_host
, ps
, depth
))
7285 if(!smb_io_unistr2("", &q_u
->uni_dest_host
, q_u
->hdr_dest_host
.buffer
, ps
, depth
))
7290 if(!smb_io_unihdr("", &q_u
->hdr_user_name
, ps
, depth
))
7292 if(!smb_io_unistr2("", &q_u
->uni_user_name
, q_u
->hdr_user_name
.buffer
,ps
, depth
))
7295 if(!samr_io_enc_passwd("nt_newpass", &q_u
->nt_newpass
, ps
, depth
))
7297 if(!samr_io_enc_hash("nt_oldhash", &q_u
->nt_oldhash
, ps
, depth
))
7300 if(!prs_uint32("unknown", ps
, depth
, &q_u
->unknown
))
7303 if(!samr_io_enc_passwd("lm_newpass", &q_u
->lm_newpass
, ps
, depth
))
7305 if(!samr_io_enc_hash("lm_oldhash", &q_u
->lm_oldhash
, ps
, depth
))
7311 /*******************************************************************
7312 inits a SAMR_R_CHGPASSWD_USER structure.
7313 ********************************************************************/
7315 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER
* r_u
, NTSTATUS status
)
7317 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
7319 r_u
->status
= status
;
7322 /*******************************************************************
7323 reads or writes a structure.
7324 ********************************************************************/
7326 BOOL
samr_io_r_chgpasswd_user(const char *desc
, SAMR_R_CHGPASSWD_USER
* r_u
,
7327 prs_struct
*ps
, int depth
)
7332 prs_debug(ps
, depth
, desc
, "samr_io_r_chgpasswd_user");
7338 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7344 /*******************************************************************
7345 inits a SAMR_Q_CHGPASSWD3 structure.
7346 ********************************************************************/
7348 void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3
* q_u
,
7349 const char *dest_host
, const char *user_name
,
7350 const uchar nt_newpass
[516],
7351 const uchar nt_oldhash
[16],
7352 const uchar lm_newpass
[516],
7353 const uchar lm_oldhash
[16])
7355 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
7358 init_unistr2(&q_u
->uni_dest_host
, dest_host
, UNI_FLAGS_NONE
);
7359 init_uni_hdr(&q_u
->hdr_dest_host
, &q_u
->uni_dest_host
);
7361 init_unistr2(&q_u
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
7362 init_uni_hdr(&q_u
->hdr_user_name
, &q_u
->uni_user_name
);
7364 init_enc_passwd(&q_u
->nt_newpass
, (const char *)nt_newpass
);
7365 init_enc_hash(&q_u
->nt_oldhash
, nt_oldhash
);
7367 q_u
->lm_change
= 0x01;
7369 init_enc_passwd(&q_u
->lm_newpass
, (const char *)lm_newpass
);
7370 init_enc_hash(&q_u
->lm_oldhash
, lm_oldhash
);
7372 init_enc_passwd(&q_u
->password3
, NULL
);
7375 /*******************************************************************
7376 reads or writes a structure.
7377 ********************************************************************/
7379 BOOL
samr_io_q_chgpasswd_user3(const char *desc
, SAMR_Q_CHGPASSWD_USER3
* q_u
,
7380 prs_struct
*ps
, int depth
)
7385 prs_debug(ps
, depth
, desc
, "samr_io_q_chgpasswd_user3");
7391 if(!prs_uint32("ptr_0", ps
, depth
, &q_u
->ptr_0
))
7394 if(!smb_io_unihdr("", &q_u
->hdr_dest_host
, ps
, depth
))
7396 if(!smb_io_unistr2("", &q_u
->uni_dest_host
, q_u
->hdr_dest_host
.buffer
, ps
, depth
))
7401 if(!smb_io_unihdr("", &q_u
->hdr_user_name
, ps
, depth
))
7403 if(!smb_io_unistr2("", &q_u
->uni_user_name
, q_u
->hdr_user_name
.buffer
,ps
, depth
))
7406 if(!samr_io_enc_passwd("nt_newpass", &q_u
->nt_newpass
, ps
, depth
))
7408 if(!samr_io_enc_hash("nt_oldhash", &q_u
->nt_oldhash
, ps
, depth
))
7411 if(!prs_uint32("lm_change", ps
, depth
, &q_u
->lm_change
))
7414 if(!samr_io_enc_passwd("lm_newpass", &q_u
->lm_newpass
, ps
, depth
))
7416 if(!samr_io_enc_hash("lm_oldhash", &q_u
->lm_oldhash
, ps
, depth
))
7419 if(!samr_io_enc_passwd("password3", &q_u
->password3
, ps
, depth
))
7425 /*******************************************************************
7426 inits a SAMR_R_CHGPASSWD_USER3 structure.
7427 ********************************************************************/
7429 void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3
*r_u
, NTSTATUS status
,
7430 SAMR_CHANGE_REJECT
*reject
, SAM_UNK_INFO_1
*info
)
7432 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
7434 r_u
->status
= status
;
7438 r_u
->ptr_reject
= 0;
7444 if (reject
&& (reject
->reject_reason
!= Undefined
)) {
7445 r_u
->reject
= reject
;
7446 r_u
->ptr_reject
= 1;
7450 /*******************************************************************
7451 Reads or writes an SAMR_CHANGE_REJECT structure.
7452 ********************************************************************/
7454 BOOL
samr_io_change_reject(const char *desc
, SAMR_CHANGE_REJECT
*reject
, prs_struct
*ps
, int depth
)
7459 prs_debug(ps
, depth
, desc
, "samr_io_change_reject");
7465 if(UNMARSHALLING(ps
))
7466 ZERO_STRUCTP(reject
);
7468 if (!prs_uint32("reject_reason", ps
, depth
, &reject
->reject_reason
))
7471 if (!prs_uint32("unknown1", ps
, depth
, &reject
->unknown1
))
7474 if (!prs_uint32("unknown2", ps
, depth
, &reject
->unknown2
))
7480 /*******************************************************************
7481 reads or writes a structure.
7482 ********************************************************************/
7484 BOOL
samr_io_r_chgpasswd_user3(const char *desc
, SAMR_R_CHGPASSWD_USER3
*r_u
,
7485 prs_struct
*ps
, int depth
)
7490 prs_debug(ps
, depth
, desc
, "samr_io_r_chgpasswd_user3");
7496 if (!prs_uint32("ptr_info", ps
, depth
, &r_u
->ptr_info
))
7499 if (r_u
->ptr_info
&& r_u
->info
!= NULL
) {
7500 /* SAM_UNK_INFO_1 */
7501 if (!sam_io_unk_info1("info", r_u
->info
, ps
, depth
))
7505 if (!prs_uint32("ptr_reject", ps
, depth
, &r_u
->ptr_reject
))
7508 if (r_u
->ptr_reject
&& r_u
->reject
!= NULL
) {
7509 /* SAMR_CHANGE_REJECT */
7510 if (!samr_io_change_reject("reject", r_u
->reject
, ps
, depth
))
7514 if (!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7520 /*******************************************************************
7521 reads or writes a structure.
7522 ********************************************************************/
7524 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2
*q_u
,
7525 POLICY_HND
*domain_pol
, uint16 switch_value
)
7527 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7529 q_u
->domain_pol
= *domain_pol
;
7530 q_u
->switch_value
= switch_value
;
7533 /*******************************************************************
7534 reads or writes a structure.
7535 ********************************************************************/
7537 BOOL
samr_io_q_query_domain_info2(const char *desc
, SAMR_Q_QUERY_DOMAIN_INFO2
*q_u
,
7538 prs_struct
*ps
, int depth
)
7543 prs_debug(ps
, depth
, desc
, "samr_io_q_query_domain_info2");
7549 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
7552 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
7558 /*******************************************************************
7559 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7560 ********************************************************************/
7562 void init_samr_r_samr_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2
* r_u
,
7563 uint16 switch_value
, SAM_UNK_CTR
* ctr
,
7566 DEBUG(5, ("init_samr_r_samr_query_domain_info2\n"));
7569 r_u
->switch_value
= 0;
7570 r_u
->status
= status
; /* return status */
7572 if (NT_STATUS_IS_OK(status
)) {
7573 r_u
->switch_value
= switch_value
;
7579 /*******************************************************************
7580 reads or writes a structure.
7581 ********************************************************************/
7583 BOOL
samr_io_r_samr_query_domain_info2(const char *desc
, SAMR_R_QUERY_DOMAIN_INFO2
* r_u
,
7584 prs_struct
*ps
, int depth
)
7589 prs_debug(ps
, depth
, desc
, "samr_io_r_samr_query_domain_info2");
7595 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
7598 if (r_u
->ptr_0
!= 0 && r_u
->ctr
!= NULL
) {
7599 if(!prs_uint16("switch_value", ps
, depth
, &r_u
->switch_value
))
7604 switch (r_u
->switch_value
) {
7606 if(!sam_io_unk_info12("unk_inf12", &r_u
->ctr
->info
.inf12
, ps
, depth
))
7610 if(!sam_io_unk_info7("unk_inf7",&r_u
->ctr
->info
.inf7
, ps
,depth
))
7614 if(!sam_io_unk_info6("unk_inf6",&r_u
->ctr
->info
.inf6
, ps
,depth
))
7618 if(!sam_io_unk_info5("unk_inf5",&r_u
->ctr
->info
.inf5
, ps
,depth
))
7622 if(!sam_io_unk_info3("unk_inf3",&r_u
->ctr
->info
.inf3
, ps
,depth
))
7626 if(!sam_io_unk_info2("unk_inf2",&r_u
->ctr
->info
.inf2
, ps
,depth
))
7630 if(!sam_io_unk_info1("unk_inf1",&r_u
->ctr
->info
.inf1
, ps
,depth
))
7634 DEBUG(0, ("samr_io_r_samr_query_domain_info2: unknown switch level 0x%x\n",
7635 r_u
->switch_value
));
7636 r_u
->status
= NT_STATUS_INVALID_INFO_CLASS
;
7644 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7651 /*******************************************************************
7652 reads or writes a structure.
7653 ********************************************************************/
7655 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO
*q_u
,
7656 POLICY_HND
*domain_pol
, uint16 switch_value
, SAM_UNK_CTR
*ctr
)
7658 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7660 q_u
->domain_pol
= *domain_pol
;
7661 q_u
->switch_value0
= switch_value
;
7663 q_u
->switch_value
= switch_value
;
7668 /*******************************************************************
7669 reads or writes a structure.
7670 ********************************************************************/
7672 BOOL
samr_io_q_set_domain_info(const char *desc
, SAMR_Q_SET_DOMAIN_INFO
*q_u
,
7673 prs_struct
*ps
, int depth
)
7678 prs_debug(ps
, depth
, desc
, "samr_io_q_set_domain_info");
7684 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
7687 if(!prs_uint16("switch_value0", ps
, depth
, &q_u
->switch_value0
))
7690 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
7696 if (UNMARSHALLING(ps
)) {
7697 if ((q_u
->ctr
= PRS_ALLOC_MEM(ps
, SAM_UNK_CTR
, 1)) == NULL
)
7701 switch (q_u
->switch_value
) {
7704 if(!sam_io_unk_info12("unk_inf12", &q_u
->ctr
->info
.inf12
, ps
, depth
))
7708 if(!sam_io_unk_info7("unk_inf7",&q_u
->ctr
->info
.inf7
, ps
,depth
))
7712 if(!sam_io_unk_info6("unk_inf6",&q_u
->ctr
->info
.inf6
, ps
,depth
))
7716 if(!sam_io_unk_info5("unk_inf5",&q_u
->ctr
->info
.inf5
, ps
,depth
))
7720 if(!sam_io_unk_info3("unk_inf3",&q_u
->ctr
->info
.inf3
, ps
,depth
))
7724 if(!sam_io_unk_info2("unk_inf2",&q_u
->ctr
->info
.inf2
, ps
,depth
))
7728 if(!sam_io_unk_info1("unk_inf1",&q_u
->ctr
->info
.inf1
, ps
,depth
))
7732 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7733 q_u
->switch_value
));
7740 /*******************************************************************
7741 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7742 ********************************************************************/
7744 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO
* r_u
, NTSTATUS status
)
7746 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7748 r_u
->status
= status
; /* return status */
7751 /*******************************************************************
7752 reads or writes a structure.
7753 ********************************************************************/
7755 BOOL
samr_io_r_set_domain_info(const char *desc
, SAMR_R_SET_DOMAIN_INFO
* r_u
,
7756 prs_struct
*ps
, int depth
)
7761 prs_debug(ps
, depth
, desc
, "samr_io_r_samr_unknown_2e");
7767 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))