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.
28 #include "rpc_parse.h"
32 #define DBGC_CLASS DBGC_RPC_PARSE
34 /*******************************************************************
35 inits a SAMR_Q_CLOSE_HND structure.
36 ********************************************************************/
38 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND
* q_c
, POLICY_HND
*hnd
)
40 DEBUG(5, ("init_samr_q_close_hnd\n"));
45 /*******************************************************************
46 reads or writes a structure.
47 ********************************************************************/
49 BOOL
samr_io_q_close_hnd(const char *desc
, SAMR_Q_CLOSE_HND
* q_u
,
50 prs_struct
*ps
, int depth
)
55 prs_debug(ps
, depth
, desc
, "samr_io_q_close_hnd");
61 return smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
);
64 /*******************************************************************
65 reads or writes a structure.
66 ********************************************************************/
68 BOOL
samr_io_r_close_hnd(const char *desc
, SAMR_R_CLOSE_HND
* r_u
,
69 prs_struct
*ps
, int depth
)
74 prs_debug(ps
, depth
, desc
, "samr_io_r_close_hnd");
80 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
83 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
89 /*******************************************************************
90 inits a SAMR_Q_LOOKUP_DOMAIN structure.
91 ********************************************************************/
93 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN
* q_u
,
94 POLICY_HND
*pol
, char *dom_name
)
96 int len_name
= strlen(dom_name
);
98 DEBUG(5, ("init_samr_q_lookup_domain\n"));
100 q_u
->connect_pol
= *pol
;
102 init_uni_hdr(&q_u
->hdr_domain
, len_name
);
103 init_unistr2(&q_u
->uni_domain
, dom_name
, len_name
);
106 /*******************************************************************
107 reads or writes a structure.
108 ********************************************************************/
109 BOOL
samr_io_q_lookup_domain(const char *desc
, SAMR_Q_LOOKUP_DOMAIN
* q_u
,
110 prs_struct
*ps
, int depth
)
115 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_domain");
121 if(!smb_io_pol_hnd("connect_pol", &q_u
->connect_pol
, ps
, depth
))
124 if(!smb_io_unihdr("hdr_domain", &q_u
->hdr_domain
, ps
, depth
))
127 if(!smb_io_unistr2("uni_domain", &q_u
->uni_domain
, q_u
->hdr_domain
.buffer
, ps
, depth
))
133 /*******************************************************************
134 inits a SAMR_R_LOOKUP_DOMAIN structure.
135 ********************************************************************/
137 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN
* r_u
,
138 DOM_SID
*dom_sid
, NTSTATUS status
)
140 DEBUG(5, ("init_samr_r_lookup_domain\n"));
142 r_u
->status
= status
;
144 if (NT_STATUS_IS_OK(status
)) {
146 init_dom_sid2(&r_u
->dom_sid
, dom_sid
);
150 /*******************************************************************
151 reads or writes a structure.
152 ********************************************************************/
154 BOOL
samr_io_r_lookup_domain(const char *desc
, SAMR_R_LOOKUP_DOMAIN
* r_u
,
155 prs_struct
*ps
, int depth
)
160 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_domain");
166 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr_sid
))
169 if (r_u
->ptr_sid
!= 0) {
170 if(!smb_io_dom_sid2("sid", &r_u
->dom_sid
, ps
, depth
))
176 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
182 /*******************************************************************
183 reads or writes a structure.
184 ********************************************************************/
186 void init_samr_q_unknown_2d(SAMR_Q_UNKNOWN_2D
* q_u
, POLICY_HND
*dom_pol
, DOM_SID
*sid
)
188 DEBUG(5, ("samr_init_samr_q_unknown_2d\n"));
190 q_u
->dom_pol
= *dom_pol
;
191 init_dom_sid2(&q_u
->sid
, sid
);
194 /*******************************************************************
195 reads or writes a structure.
196 ********************************************************************/
198 BOOL
samr_io_q_unknown_2d(const char *desc
, SAMR_Q_UNKNOWN_2D
* q_u
,
199 prs_struct
*ps
, int depth
)
204 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_2d");
210 if(!smb_io_pol_hnd("domain_pol", &q_u
->dom_pol
, ps
, depth
))
213 if(!smb_io_dom_sid2("sid", &q_u
->sid
, ps
, depth
))
222 /*******************************************************************
223 reads or writes a structure.
224 ********************************************************************/
226 BOOL
samr_io_r_unknown_2d(const char *desc
, SAMR_R_UNKNOWN_2D
* r_u
,
227 prs_struct
*ps
, int depth
)
232 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_2d");
238 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
244 /*******************************************************************
245 reads or writes a structure.
246 ********************************************************************/
248 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN
* q_u
,
249 POLICY_HND
*pol
, uint32 flags
,
252 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
256 init_dom_sid2(&q_u
->dom_sid
, sid
);
259 /*******************************************************************
260 reads or writes a structure.
261 ********************************************************************/
263 BOOL
samr_io_q_open_domain(const char *desc
, SAMR_Q_OPEN_DOMAIN
* q_u
,
264 prs_struct
*ps
, int depth
)
269 prs_debug(ps
, depth
, desc
, "samr_io_q_open_domain");
275 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
278 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
281 if(!smb_io_dom_sid2("sid", &q_u
->dom_sid
, ps
, depth
))
287 /*******************************************************************
288 reads or writes a structure.
289 ********************************************************************/
291 BOOL
samr_io_r_open_domain(const char *desc
, SAMR_R_OPEN_DOMAIN
* r_u
,
292 prs_struct
*ps
, int depth
)
297 prs_debug(ps
, depth
, desc
, "samr_io_r_open_domain");
303 if(!smb_io_pol_hnd("domain_pol", &r_u
->domain_pol
, ps
, depth
))
306 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
312 /*******************************************************************
313 reads or writes a structure.
314 ********************************************************************/
316 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO
* q_u
,
317 POLICY_HND
*user_pol
)
319 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
321 q_u
->user_pol
= *user_pol
;
324 /*******************************************************************
325 reads or writes a structure.
326 ********************************************************************/
328 BOOL
samr_io_q_get_usrdom_pwinfo(const char *desc
, SAMR_Q_GET_USRDOM_PWINFO
* q_u
,
329 prs_struct
*ps
, int depth
)
334 prs_debug(ps
, depth
, desc
, "samr_io_q_get_usrdom_pwinfo");
340 return smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
);
343 /*******************************************************************
345 ********************************************************************/
347 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO
*r_u
, NTSTATUS status
)
349 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
351 r_u
->unknown_0
= 0x0000;
355 * r_u->unknown_1 = 0x0015;
358 r_u
->unknown_1
= 0x01D1;
359 r_u
->unknown_1
= 0x0015;
361 r_u
->unknown_2
= 0x00000000;
363 r_u
->status
= status
;
366 /*******************************************************************
367 reads or writes a structure.
368 ********************************************************************/
370 BOOL
samr_io_r_get_usrdom_pwinfo(const char *desc
, SAMR_R_GET_USRDOM_PWINFO
* r_u
,
371 prs_struct
*ps
, int depth
)
376 prs_debug(ps
, depth
, desc
, "samr_io_r_get_usrdom_pwinfo");
382 if(!prs_uint16("unknown_0", ps
, depth
, &r_u
->unknown_0
))
384 if(!prs_uint16("unknown_1", ps
, depth
, &r_u
->unknown_1
))
386 if(!prs_uint32("unknown_2", ps
, depth
, &r_u
->unknown_2
))
388 if(!prs_ntstatus("status ", ps
, depth
, &r_u
->status
))
395 /*******************************************************************
396 reads or writes a structure.
397 ********************************************************************/
399 BOOL
samr_io_q_set_sec_obj(const char *desc
, SAMR_Q_SET_SEC_OBJ
* q_u
,
400 prs_struct
*ps
, int depth
)
405 prs_debug(ps
, depth
, desc
, "samr_io_q_set_sec_obj");
411 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
414 if(!prs_uint32("sec_info", ps
, depth
, &q_u
->sec_info
))
417 if(!sec_io_desc_buf("sec_desc", &q_u
->buf
, ps
, depth
))
424 /*******************************************************************
425 reads or writes a structure.
426 ********************************************************************/
428 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ
* q_u
,
429 POLICY_HND
*user_pol
, uint32 sec_info
)
431 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
433 q_u
->user_pol
= *user_pol
;
434 q_u
->sec_info
= sec_info
;
438 /*******************************************************************
439 reads or writes a structure.
440 ********************************************************************/
442 BOOL
samr_io_q_query_sec_obj(const char *desc
, SAMR_Q_QUERY_SEC_OBJ
* q_u
,
443 prs_struct
*ps
, int depth
)
448 prs_debug(ps
, depth
, desc
, "samr_io_q_query_sec_obj");
454 if(!smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
))
457 if(!prs_uint32("sec_info", ps
, depth
, &q_u
->sec_info
))
463 /*******************************************************************
464 reads or writes a structure.
465 ********************************************************************/
467 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO
* q_u
,
468 POLICY_HND
*domain_pol
, uint16 switch_value
)
470 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
472 q_u
->domain_pol
= *domain_pol
;
473 q_u
->switch_value
= switch_value
;
476 /*******************************************************************
477 reads or writes a structure.
478 ********************************************************************/
480 BOOL
samr_io_q_query_dom_info(const char *desc
, SAMR_Q_QUERY_DOMAIN_INFO
* q_u
,
481 prs_struct
*ps
, int depth
)
486 prs_debug(ps
, depth
, desc
, "samr_io_q_query_dom_info");
492 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
495 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
502 /*******************************************************************
504 ********************************************************************/
506 void init_unk_info3(SAM_UNK_INFO_3
*u_3
, NTTIME nt_logout
)
508 u_3
->logout
.low
= nt_logout
.low
;
509 u_3
->logout
.high
= nt_logout
.high
;
512 /*******************************************************************
513 reads or writes a structure.
514 ********************************************************************/
516 static BOOL
sam_io_unk_info3(const char *desc
, SAM_UNK_INFO_3
* u_3
,
517 prs_struct
*ps
, int depth
)
522 prs_debug(ps
, depth
, desc
, "sam_io_unk_info3");
525 if(!smb_io_time("logout", &u_3
->logout
, ps
, depth
))
531 /*******************************************************************
533 ********************************************************************/
535 void init_unk_info6(SAM_UNK_INFO_6
* u_6
)
537 u_6
->unknown_0
= 0x00000000;
539 memset(u_6
->padding
, 0, sizeof(u_6
->padding
)); /* 12 bytes zeros */
542 /*******************************************************************
543 reads or writes a structure.
544 ********************************************************************/
546 static BOOL
sam_io_unk_info6(const char *desc
, SAM_UNK_INFO_6
* u_6
,
547 prs_struct
*ps
, int depth
)
552 prs_debug(ps
, depth
, desc
, "sam_io_unk_info6");
555 if(!prs_uint32("unknown_0", ps
, depth
, &u_6
->unknown_0
)) /* 0x0000 0000 */
557 if(!prs_uint32("ptr_0", ps
, depth
, &u_6
->ptr_0
)) /* pointer to unknown structure */
559 if(!prs_uint8s(False
, "padding", ps
, depth
, u_6
->padding
, sizeof(u_6
->padding
))) /* 12 bytes zeros */
565 /*******************************************************************
567 ********************************************************************/
569 void init_unk_info7(SAM_UNK_INFO_7
* u_7
)
571 u_7
->unknown_0
= 0x0003;
574 /*******************************************************************
575 reads or writes a structure.
576 ********************************************************************/
578 static BOOL
sam_io_unk_info7(const char *desc
, SAM_UNK_INFO_7
* u_7
,
579 prs_struct
*ps
, int depth
)
584 prs_debug(ps
, depth
, desc
, "sam_io_unk_info7");
587 if(!prs_uint16("unknown_0", ps
, depth
, &u_7
->unknown_0
)) /* 0x0003 */
593 /*******************************************************************
595 ********************************************************************/
597 void init_unk_info12(SAM_UNK_INFO_12
* u_12
, NTTIME nt_lock_duration
, NTTIME nt_reset_time
, uint16 lockout
)
599 u_12
->duration
.low
= nt_lock_duration
.low
;
600 u_12
->duration
.high
= nt_lock_duration
.high
;
601 u_12
->reset_count
.low
= nt_reset_time
.low
;
602 u_12
->reset_count
.high
= nt_reset_time
.high
;
604 u_12
->bad_attempt_lockout
= lockout
;
607 /*******************************************************************
608 reads or writes a structure.
609 ********************************************************************/
611 static BOOL
sam_io_unk_info12(const char *desc
, SAM_UNK_INFO_12
* u_12
,
612 prs_struct
*ps
, int depth
)
617 prs_debug(ps
, depth
, desc
, "sam_io_unk_info12");
620 if(!smb_io_time("duration", &u_12
->duration
, ps
, depth
))
622 if(!smb_io_time("reset_count", &u_12
->reset_count
, ps
, depth
))
624 if(!prs_uint16("bad_attempt_lockout", ps
, depth
, &u_12
->bad_attempt_lockout
))
630 /*******************************************************************
632 ********************************************************************/
633 void init_unk_info5(SAM_UNK_INFO_5
* u_5
,const char *server
)
635 int len_server
= strlen(server
);
637 init_uni_hdr(&u_5
->hdr_server
, len_server
);
639 init_unistr2(&u_5
->uni_server
, server
, len_server
);
642 /*******************************************************************
643 reads or writes a structure.
644 ********************************************************************/
646 static BOOL
sam_io_unk_info5(const char *desc
, SAM_UNK_INFO_5
* u_5
,
647 prs_struct
*ps
, int depth
)
652 prs_debug(ps
, depth
, desc
, "sam_io_unk_info5");
655 if(!smb_io_unihdr("hdr_server", &u_5
->hdr_server
, ps
, depth
))
658 if(!smb_io_unistr2("uni_server", &u_5
->uni_server
, u_5
->hdr_server
.buffer
, ps
, depth
))
664 /*******************************************************************
666 ********************************************************************/
667 void init_unk_info2(SAM_UNK_INFO_2
* u_2
,
668 const char *domain
, const char *server
,
669 uint32 seq_num
, uint32 num_users
, uint32 num_groups
, uint32 num_alias
)
671 int len_domain
= strlen(domain
);
672 int len_server
= strlen(server
);
674 u_2
->unknown_0
= 0x00000000;
675 u_2
->unknown_1
= 0x80000000;
676 u_2
->unknown_2
= 0x00000000;
679 init_uni_hdr(&u_2
->hdr_domain
, len_domain
);
680 init_uni_hdr(&u_2
->hdr_server
, len_server
);
682 u_2
->seq_num
= seq_num
;
683 u_2
->unknown_3
= 0x00000000;
685 u_2
->unknown_4
= 0x00000001;
686 u_2
->unknown_5
= 0x00000003;
687 u_2
->unknown_6
= 0x00000001;
688 u_2
->num_domain_usrs
= num_users
;
689 u_2
->num_domain_grps
= num_groups
;
690 u_2
->num_local_grps
= num_alias
;
692 memset(u_2
->padding
, 0, sizeof(u_2
->padding
)); /* 12 bytes zeros */
694 init_unistr2(&u_2
->uni_domain
, domain
, len_domain
);
695 init_unistr2(&u_2
->uni_server
, server
, len_server
);
698 /*******************************************************************
699 reads or writes a structure.
700 ********************************************************************/
702 static BOOL
sam_io_unk_info2(const char *desc
, SAM_UNK_INFO_2
* u_2
,
703 prs_struct
*ps
, int depth
)
708 prs_debug(ps
, depth
, desc
, "sam_io_unk_info2");
711 if(!prs_uint32("unknown_0", ps
, depth
, &u_2
->unknown_0
)) /* 0x0000 0000 */
713 if(!prs_uint32("unknown_1", ps
, depth
, &u_2
->unknown_1
)) /* 0x8000 0000 */
715 if(!prs_uint32("unknown_2", ps
, depth
, &u_2
->unknown_2
)) /* 0x0000 0000 */
718 if(!prs_uint32("ptr_0", ps
, depth
, &u_2
->ptr_0
))
720 if(!smb_io_unihdr("hdr_domain", &u_2
->hdr_domain
, ps
, depth
))
722 if(!smb_io_unihdr("hdr_server", &u_2
->hdr_server
, ps
, depth
))
725 /* put all the data in here, at the moment, including what the above
726 pointer is referring to
729 if(!prs_uint32("seq_num ", ps
, depth
, &u_2
->seq_num
)) /* 0x0000 0099 or 0x1000 0000 */
731 if(!prs_uint32("unknown_3 ", ps
, depth
, &u_2
->unknown_3
)) /* 0x0000 0000 */
734 if(!prs_uint32("unknown_4 ", ps
, depth
, &u_2
->unknown_4
)) /* 0x0000 0001 */
736 if(!prs_uint32("unknown_5 ", ps
, depth
, &u_2
->unknown_5
)) /* 0x0000 0003 */
738 if(!prs_uint32("unknown_6 ", ps
, depth
, &u_2
->unknown_6
)) /* 0x0000 0001 */
740 if(!prs_uint32("num_domain_usrs ", ps
, depth
, &u_2
->num_domain_usrs
))
742 if(!prs_uint32("num_domain_grps", ps
, depth
, &u_2
->num_domain_grps
))
744 if(!prs_uint32("num_local_grps", ps
, depth
, &u_2
->num_local_grps
))
748 /* this was originally marked as 'padding'. It isn't
749 padding, it is some sort of optional 12 byte
750 structure. When it is present it contains zeros
752 if(!prs_uint8s(False
, "unknown", ps
, depth
, u_2
->padding
,sizeof(u_2
->padding
)))
756 if(!smb_io_unistr2("uni_domain", &u_2
->uni_domain
, u_2
->hdr_domain
.buffer
, ps
, depth
))
758 if(!smb_io_unistr2("uni_server", &u_2
->uni_server
, u_2
->hdr_server
.buffer
, ps
, depth
))
764 /*******************************************************************
766 ********************************************************************/
768 void init_unk_info1(SAM_UNK_INFO_1
*u_1
, uint16 min_pass_len
, uint16 pass_hist
,
769 uint32 flag
, NTTIME nt_expire
, NTTIME nt_min_age
)
771 u_1
->min_length_password
= min_pass_len
;
772 u_1
->password_history
= pass_hist
;
775 /* password never expire */
776 u_1
->expire
.high
= nt_expire
.high
;
777 u_1
->expire
.low
= nt_expire
.low
;
779 /* can change the password now */
780 u_1
->min_passwordage
.high
= nt_min_age
.high
;
781 u_1
->min_passwordage
.low
= nt_min_age
.low
;
785 /*******************************************************************
786 reads or writes a structure.
787 ********************************************************************/
789 static BOOL
sam_io_unk_info1(const char *desc
, SAM_UNK_INFO_1
* u_1
,
790 prs_struct
*ps
, int depth
)
795 prs_debug(ps
, depth
, desc
, "sam_io_unk_info1");
798 if(!prs_uint16("min_length_password", ps
, depth
, &u_1
->min_length_password
))
800 if(!prs_uint16("password_history", ps
, depth
, &u_1
->password_history
))
802 if(!prs_uint32("flag", ps
, depth
, &u_1
->flag
))
804 if(!smb_io_time("expire", &u_1
->expire
, ps
, depth
))
806 if(!smb_io_time("min_passwordage", &u_1
->min_passwordage
, ps
, depth
))
812 /*******************************************************************
813 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
814 ********************************************************************/
816 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO
* r_u
,
817 uint16 switch_value
, SAM_UNK_CTR
* ctr
,
820 DEBUG(5, ("init_samr_r_query_dom_info\n"));
823 r_u
->switch_value
= 0;
824 r_u
->status
= status
; /* return status */
826 if (NT_STATUS_IS_OK(status
)) {
827 r_u
->switch_value
= switch_value
;
833 /*******************************************************************
834 reads or writes a structure.
835 ********************************************************************/
837 BOOL
samr_io_r_query_dom_info(const char *desc
, SAMR_R_QUERY_DOMAIN_INFO
* r_u
,
838 prs_struct
*ps
, int depth
)
843 prs_debug(ps
, depth
, desc
, "samr_io_r_query_dom_info");
849 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
852 if (r_u
->ptr_0
!= 0 && r_u
->ctr
!= NULL
) {
853 if(!prs_uint16("switch_value", ps
, depth
, &r_u
->switch_value
))
858 switch (r_u
->switch_value
) {
860 if(!sam_io_unk_info12("unk_inf12", &r_u
->ctr
->info
.inf12
, ps
, depth
))
864 if(!sam_io_unk_info7("unk_inf7",&r_u
->ctr
->info
.inf7
, ps
,depth
))
868 if(!sam_io_unk_info6("unk_inf6",&r_u
->ctr
->info
.inf6
, ps
,depth
))
872 if(!sam_io_unk_info5("unk_inf5",&r_u
->ctr
->info
.inf5
, ps
,depth
))
876 if(!sam_io_unk_info3("unk_inf3",&r_u
->ctr
->info
.inf3
, ps
,depth
))
880 if(!sam_io_unk_info2("unk_inf2",&r_u
->ctr
->info
.inf2
, ps
,depth
))
884 if(!sam_io_unk_info1("unk_inf1",&r_u
->ctr
->info
.inf1
, ps
,depth
))
888 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
890 r_u
->status
= NT_STATUS_INVALID_INFO_CLASS
;
898 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
904 /*******************************************************************
905 reads or writes a SAMR_R_SET_SEC_OBJ structure.
906 ********************************************************************/
908 BOOL
samr_io_r_set_sec_obj(const char *desc
, SAMR_R_SET_SEC_OBJ
* r_u
,
909 prs_struct
*ps
, int depth
)
914 prs_debug(ps
, depth
, desc
, "samr_io_r_set_sec_obj");
920 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
926 /*******************************************************************
927 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
928 ********************************************************************/
930 BOOL
samr_io_r_query_sec_obj(const char *desc
, SAMR_R_QUERY_SEC_OBJ
* r_u
,
931 prs_struct
*ps
, int depth
)
936 prs_debug(ps
, depth
, desc
, "samr_io_r_query_sec_obj");
942 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
945 if(!sec_io_desc_buf("sec", &r_u
->buf
, ps
, depth
))
949 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
955 /*******************************************************************
956 reads or writes a SAM_STR1 structure.
957 ********************************************************************/
959 static BOOL
sam_io_sam_str1(const char *desc
, SAM_STR1
* sam
, uint32 acct_buf
,
960 uint32 name_buf
, uint32 desc_buf
,
961 prs_struct
*ps
, int depth
)
966 prs_debug(ps
, depth
, desc
, "sam_io_sam_str1");
971 if (!smb_io_unistr2("name", &sam
->uni_acct_name
, acct_buf
, ps
, depth
))
974 if (!smb_io_unistr2("desc", &sam
->uni_acct_desc
, desc_buf
, ps
, depth
))
977 if (!smb_io_unistr2("full", &sam
->uni_full_name
, name_buf
, ps
, depth
))
983 /*******************************************************************
984 inits a SAM_ENTRY1 structure.
985 ********************************************************************/
987 static void init_sam_entry1(SAM_ENTRY1
* sam
, uint32 user_idx
,
988 uint32 len_sam_name
, uint32 len_sam_full
,
989 uint32 len_sam_desc
, uint32 rid_user
,
992 DEBUG(5, ("init_sam_entry1\n"));
996 sam
->user_idx
= user_idx
;
997 sam
->rid_user
= rid_user
;
998 sam
->acb_info
= acb_info
;
1000 init_uni_hdr(&sam
->hdr_acct_name
, len_sam_name
);
1001 init_uni_hdr(&sam
->hdr_user_name
, len_sam_full
);
1002 init_uni_hdr(&sam
->hdr_user_desc
, len_sam_desc
);
1005 /*******************************************************************
1006 reads or writes a SAM_ENTRY1 structure.
1007 ********************************************************************/
1009 static BOOL
sam_io_sam_entry1(const char *desc
, SAM_ENTRY1
* sam
,
1010 prs_struct
*ps
, int depth
)
1015 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry1");
1021 if(!prs_uint32("user_idx ", ps
, depth
, &sam
->user_idx
))
1024 if(!prs_uint32("rid_user ", ps
, depth
, &sam
->rid_user
))
1026 if(!prs_uint16("acb_info ", ps
, depth
, &sam
->acb_info
))
1032 if (!smb_io_unihdr("hdr_acct_name", &sam
->hdr_acct_name
, ps
, depth
))
1034 if (!smb_io_unihdr("hdr_user_desc", &sam
->hdr_user_desc
, ps
, depth
))
1036 if (!smb_io_unihdr("hdr_user_name", &sam
->hdr_user_name
, ps
, depth
))
1042 /*******************************************************************
1043 reads or writes a SAM_STR2 structure.
1044 ********************************************************************/
1046 static BOOL
sam_io_sam_str2(const char *desc
, SAM_STR2
* sam
, uint32 acct_buf
,
1047 uint32 desc_buf
, prs_struct
*ps
, int depth
)
1052 prs_debug(ps
, depth
, desc
, "sam_io_sam_str2");
1058 if(!smb_io_unistr2("uni_srv_name", &sam
->uni_srv_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
1060 if(!smb_io_unistr2("uni_srv_desc", &sam
->uni_srv_desc
, desc_buf
, ps
, depth
)) /* account desc unicode string */
1066 /*******************************************************************
1067 inits a SAM_ENTRY2 structure.
1068 ********************************************************************/
1069 static void init_sam_entry2(SAM_ENTRY2
* sam
, uint32 user_idx
,
1070 uint32 len_sam_name
, uint32 len_sam_desc
,
1071 uint32 rid_user
, uint16 acb_info
)
1073 DEBUG(5, ("init_sam_entry2\n"));
1075 sam
->user_idx
= user_idx
;
1076 sam
->rid_user
= rid_user
;
1077 sam
->acb_info
= acb_info
;
1079 init_uni_hdr(&sam
->hdr_srv_name
, len_sam_name
);
1080 init_uni_hdr(&sam
->hdr_srv_desc
, len_sam_desc
);
1083 /*******************************************************************
1084 reads or writes a SAM_ENTRY2 structure.
1085 ********************************************************************/
1087 static BOOL
sam_io_sam_entry2(const char *desc
, SAM_ENTRY2
* sam
,
1088 prs_struct
*ps
, int depth
)
1093 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry2");
1099 if(!prs_uint32("user_idx ", ps
, depth
, &sam
->user_idx
))
1102 if(!prs_uint32("rid_user ", ps
, depth
, &sam
->rid_user
))
1104 if(!prs_uint16("acb_info ", ps
, depth
, &sam
->acb_info
))
1110 if(!smb_io_unihdr("unihdr", &sam
->hdr_srv_name
, ps
, depth
)) /* account name unicode string header */
1112 if(!smb_io_unihdr("unihdr", &sam
->hdr_srv_desc
, ps
, depth
)) /* account name unicode string header */
1118 /*******************************************************************
1119 reads or writes a SAM_STR3 structure.
1120 ********************************************************************/
1122 static BOOL
sam_io_sam_str3(const char *desc
, SAM_STR3
* sam
, uint32 acct_buf
,
1123 uint32 desc_buf
, prs_struct
*ps
, int depth
)
1128 prs_debug(ps
, depth
, desc
, "sam_io_sam_str3");
1134 if(!smb_io_unistr2("uni_grp_name", &sam
->uni_grp_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
1136 if(!smb_io_unistr2("uni_grp_desc", &sam
->uni_grp_desc
, desc_buf
, ps
, depth
)) /* account desc unicode string */
1142 /*******************************************************************
1143 inits a SAM_ENTRY3 structure.
1144 ********************************************************************/
1146 static void init_sam_entry3(SAM_ENTRY3
* sam
, uint32 grp_idx
,
1147 uint32 len_grp_name
, uint32 len_grp_desc
,
1150 DEBUG(5, ("init_sam_entry3\n"));
1152 sam
->grp_idx
= grp_idx
;
1153 sam
->rid_grp
= rid_grp
;
1154 sam
->attr
= 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1156 init_uni_hdr(&sam
->hdr_grp_name
, len_grp_name
);
1157 init_uni_hdr(&sam
->hdr_grp_desc
, len_grp_desc
);
1160 /*******************************************************************
1161 reads or writes a SAM_ENTRY3 structure.
1162 ********************************************************************/
1164 static BOOL
sam_io_sam_entry3(const char *desc
, SAM_ENTRY3
* sam
,
1165 prs_struct
*ps
, int depth
)
1170 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry3");
1176 if(!prs_uint32("grp_idx", ps
, depth
, &sam
->grp_idx
))
1179 if(!prs_uint32("rid_grp", ps
, depth
, &sam
->rid_grp
))
1181 if(!prs_uint32("attr ", ps
, depth
, &sam
->attr
))
1184 if(!smb_io_unihdr("unihdr", &sam
->hdr_grp_name
, ps
, depth
)) /* account name unicode string header */
1186 if(!smb_io_unihdr("unihdr", &sam
->hdr_grp_desc
, ps
, depth
)) /* account name unicode string header */
1192 /*******************************************************************
1193 inits a SAM_ENTRY4 structure.
1194 ********************************************************************/
1196 static void init_sam_entry4(SAM_ENTRY4
* sam
, uint32 user_idx
,
1197 uint32 len_acct_name
)
1199 DEBUG(5, ("init_sam_entry4\n"));
1201 sam
->user_idx
= user_idx
;
1202 init_str_hdr(&sam
->hdr_acct_name
, len_acct_name
+1, len_acct_name
, len_acct_name
!= 0);
1205 /*******************************************************************
1206 reads or writes a SAM_ENTRY4 structure.
1207 ********************************************************************/
1209 static BOOL
sam_io_sam_entry4(const char *desc
, SAM_ENTRY4
* sam
,
1210 prs_struct
*ps
, int depth
)
1215 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry4");
1221 if(!prs_uint32("user_idx", ps
, depth
, &sam
->user_idx
))
1223 if(!smb_io_strhdr("strhdr", &sam
->hdr_acct_name
, ps
, depth
))
1229 /*******************************************************************
1230 inits a SAM_ENTRY5 structure.
1231 ********************************************************************/
1233 static void init_sam_entry5(SAM_ENTRY5
* sam
, uint32 grp_idx
,
1234 uint32 len_grp_name
)
1236 DEBUG(5, ("init_sam_entry5\n"));
1238 sam
->grp_idx
= grp_idx
;
1239 init_str_hdr(&sam
->hdr_grp_name
, len_grp_name
, len_grp_name
,
1243 /*******************************************************************
1244 reads or writes a SAM_ENTRY5 structure.
1245 ********************************************************************/
1247 static BOOL
sam_io_sam_entry5(const char *desc
, SAM_ENTRY5
* sam
,
1248 prs_struct
*ps
, int depth
)
1253 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry5");
1259 if(!prs_uint32("grp_idx", ps
, depth
, &sam
->grp_idx
))
1261 if(!smb_io_strhdr("strhdr", &sam
->hdr_grp_name
, ps
, depth
))
1267 /*******************************************************************
1268 inits a SAM_ENTRY structure.
1269 ********************************************************************/
1271 void init_sam_entry(SAM_ENTRY
* sam
, uint32 len_sam_name
, uint32 rid
)
1273 DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name
, rid
));
1276 init_uni_hdr(&sam
->hdr_name
, len_sam_name
);
1279 /*******************************************************************
1280 reads or writes a SAM_ENTRY structure.
1281 ********************************************************************/
1283 static BOOL
sam_io_sam_entry(const char *desc
, SAM_ENTRY
* sam
,
1284 prs_struct
*ps
, int depth
)
1289 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry");
1294 if(!prs_uint32("rid", ps
, depth
, &sam
->rid
))
1296 if(!smb_io_unihdr("unihdr", &sam
->hdr_name
, ps
, depth
)) /* account name unicode string header */
1302 /*******************************************************************
1303 inits a SAMR_Q_ENUM_DOM_USERS structure.
1304 ********************************************************************/
1306 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS
* q_e
, POLICY_HND
*pol
,
1308 uint16 acb_mask
, uint16 unk_1
, uint32 size
)
1310 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1314 q_e
->start_idx
= start_idx
; /* zero indicates lots */
1315 q_e
->acb_mask
= acb_mask
;
1316 q_e
->unknown_1
= unk_1
;
1317 q_e
->max_size
= size
;
1320 /*******************************************************************
1321 reads or writes a structure.
1322 ********************************************************************/
1324 BOOL
samr_io_q_enum_dom_users(const char *desc
, SAMR_Q_ENUM_DOM_USERS
* q_e
,
1325 prs_struct
*ps
, int depth
)
1330 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_users");
1336 if(!smb_io_pol_hnd("domain_pol", &q_e
->pol
, ps
, depth
))
1339 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
1341 if(!prs_uint16("acb_mask ", ps
, depth
, &q_e
->acb_mask
))
1343 if(!prs_uint16("unknown_1", ps
, depth
, &q_e
->unknown_1
))
1346 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1353 /*******************************************************************
1354 inits a SAMR_R_ENUM_DOM_USERS structure.
1355 ********************************************************************/
1357 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS
* r_u
,
1358 uint32 next_idx
, uint32 num_sam_entries
)
1360 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1362 r_u
->next_idx
= next_idx
;
1364 if (num_sam_entries
!= 0) {
1365 r_u
->ptr_entries1
= 1;
1366 r_u
->ptr_entries2
= 1;
1367 r_u
->num_entries2
= num_sam_entries
;
1368 r_u
->num_entries3
= num_sam_entries
;
1370 r_u
->num_entries4
= num_sam_entries
;
1372 r_u
->ptr_entries1
= 0;
1373 r_u
->num_entries2
= num_sam_entries
;
1374 r_u
->ptr_entries2
= 1;
1378 /*******************************************************************
1379 reads or writes a structure.
1380 ********************************************************************/
1382 BOOL
samr_io_r_enum_dom_users(const char *desc
, SAMR_R_ENUM_DOM_USERS
* r_u
,
1383 prs_struct
*ps
, int depth
)
1390 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_users");
1396 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
1398 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
1401 if (r_u
->ptr_entries1
!= 0) {
1402 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
1404 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
1406 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
1409 if (UNMARSHALLING(ps
) && (r_u
->num_entries2
!= 0)) {
1410 r_u
->sam
= (SAM_ENTRY
*)prs_alloc_mem(ps
,sizeof(SAM_ENTRY
)*r_u
->num_entries2
);
1411 r_u
->uni_acct_name
= (UNISTR2
*)prs_alloc_mem(ps
,sizeof(UNISTR2
)*r_u
->num_entries2
);
1414 if ((r_u
->sam
== NULL
|| r_u
->uni_acct_name
== NULL
) && r_u
->num_entries2
!= 0) {
1415 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1416 r_u
->num_entries4
= 0;
1417 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
1421 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1422 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
1426 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1427 if(!smb_io_unistr2("", &r_u
->uni_acct_name
[i
],r_u
->sam
[i
].hdr_name
.buffer
, ps
,depth
))
1436 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
1438 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
1444 /*******************************************************************
1445 inits a SAMR_Q_QUERY_DISPINFO structure.
1446 ********************************************************************/
1448 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO
* q_e
, POLICY_HND
*pol
,
1449 uint16 switch_level
, uint32 start_idx
,
1450 uint32 max_entries
, uint32 max_size
)
1452 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1454 q_e
->domain_pol
= *pol
;
1456 q_e
->switch_level
= switch_level
;
1458 q_e
->start_idx
= start_idx
;
1459 q_e
->max_entries
= max_entries
;
1460 q_e
->max_size
= max_size
;
1463 /*******************************************************************
1464 reads or writes a structure.
1465 ********************************************************************/
1467 BOOL
samr_io_q_query_dispinfo(const char *desc
, SAMR_Q_QUERY_DISPINFO
* q_e
,
1468 prs_struct
*ps
, int depth
)
1473 prs_debug(ps
, depth
, desc
, "samr_io_q_query_dispinfo");
1479 if(!smb_io_pol_hnd("domain_pol", &q_e
->domain_pol
, ps
, depth
))
1482 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
1487 if(!prs_uint32("start_idx ", ps
, depth
, &q_e
->start_idx
))
1489 if(!prs_uint32("max_entries ", ps
, depth
, &q_e
->max_entries
))
1491 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1497 /*******************************************************************
1498 inits a SAM_DISPINFO_1 structure.
1499 ********************************************************************/
1501 NTSTATUS
init_sam_dispinfo_1(TALLOC_CTX
*ctx
, SAM_DISPINFO_1
*sam
, uint32 num_entries
,
1502 uint32 start_idx
, SAM_ACCOUNT
*disp_user_info
,
1503 DOM_SID
*domain_sid
)
1505 uint32 len_sam_name
, len_sam_full
, len_sam_desc
;
1508 SAM_ACCOUNT
*pwd
= NULL
;
1511 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries
));
1514 return NT_STATUS_OK
;
1516 sam
->sam
=(SAM_ENTRY1
*)talloc(ctx
, num_entries
*sizeof(SAM_ENTRY1
));
1518 return NT_STATUS_NO_MEMORY
;
1520 sam
->str
=(SAM_STR1
*)talloc(ctx
, num_entries
*sizeof(SAM_STR1
));
1522 return NT_STATUS_NO_MEMORY
;
1524 ZERO_STRUCTP(sam
->sam
);
1525 ZERO_STRUCTP(sam
->str
);
1527 for (i
= 0; i
< num_entries
; i
++) {
1528 const char *username
;
1529 const char *fullname
;
1530 const char *acct_desc
;
1532 const DOM_SID
*user_sid
;
1533 fstring user_sid_string
, domain_sid_string
;
1535 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i
));
1537 pwd
=&disp_user_info
[i
+start_idx
];
1539 username
= pdb_get_username(pwd
);
1540 fullname
= pdb_get_fullname(pwd
);
1541 acct_desc
= pdb_get_acct_desc(pwd
);
1552 user_sid
= pdb_get_user_sid(pwd
);
1554 if (!sid_peek_check_rid(domain_sid
, user_sid
, &user_rid
)) {
1555 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with "
1556 "the domain sid %s. Failing operation.\n",
1558 sid_to_string(user_sid_string
, user_sid
),
1559 sid_to_string(domain_sid_string
, domain_sid
)));
1560 return NT_STATUS_UNSUCCESSFUL
;
1563 len_sam_name
= strlen(username
);
1564 len_sam_full
= strlen(fullname
);
1565 len_sam_desc
= strlen(acct_desc
);
1567 init_sam_entry1(&sam
->sam
[i
], start_idx
+ i
+ 1,
1568 len_sam_name
, len_sam_full
, len_sam_desc
,
1569 user_rid
, pdb_get_acct_ctrl(pwd
));
1571 ZERO_STRUCTP(&sam
->str
[i
].uni_acct_name
);
1572 ZERO_STRUCTP(&sam
->str
[i
].uni_full_name
);
1573 ZERO_STRUCTP(&sam
->str
[i
].uni_acct_desc
);
1575 init_unistr2(&sam
->str
[i
].uni_acct_name
, pdb_get_username(pwd
), len_sam_name
);
1576 init_unistr2(&sam
->str
[i
].uni_full_name
, pdb_get_fullname(pwd
), len_sam_full
);
1577 init_unistr2(&sam
->str
[i
].uni_acct_desc
, pdb_get_acct_desc(pwd
), len_sam_desc
);
1580 return NT_STATUS_OK
;
1583 /*******************************************************************
1584 reads or writes a structure.
1585 ********************************************************************/
1587 static BOOL
sam_io_sam_dispinfo_1(const char *desc
, SAM_DISPINFO_1
* sam
,
1589 prs_struct
*ps
, int depth
)
1593 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_1");
1599 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1601 if ((sam
->sam
= (SAM_ENTRY1
*)
1602 prs_alloc_mem(ps
, sizeof(SAM_ENTRY1
) *
1603 num_entries
)) == NULL
) {
1604 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1608 if ((sam
->str
= (SAM_STR1
*)
1609 prs_alloc_mem(ps
, sizeof(SAM_STR1
) *
1610 num_entries
)) == NULL
) {
1611 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1616 for (i
= 0; i
< num_entries
; i
++) {
1617 if(!sam_io_sam_entry1("", &sam
->sam
[i
], ps
, depth
))
1621 for (i
= 0; i
< num_entries
; i
++) {
1622 if(!sam_io_sam_str1("", &sam
->str
[i
],
1623 sam
->sam
[i
].hdr_acct_name
.buffer
,
1624 sam
->sam
[i
].hdr_user_name
.buffer
,
1625 sam
->sam
[i
].hdr_user_desc
.buffer
, ps
, depth
))
1632 /*******************************************************************
1633 inits a SAM_DISPINFO_2 structure.
1634 ********************************************************************/
1636 NTSTATUS
init_sam_dispinfo_2(TALLOC_CTX
*ctx
, SAM_DISPINFO_2
*sam
, uint32 num_entries
,
1637 uint32 start_idx
, SAM_ACCOUNT
*disp_user_info
,
1638 DOM_SID
*domain_sid
)
1640 uint32 len_sam_name
, len_sam_desc
;
1643 SAM_ACCOUNT
*pwd
= NULL
;
1646 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries
));
1649 return NT_STATUS_OK
;
1651 if (!(sam
->sam
=(SAM_ENTRY2
*)talloc(ctx
, num_entries
*sizeof(SAM_ENTRY2
))))
1652 return NT_STATUS_NO_MEMORY
;
1654 if (!(sam
->str
=(SAM_STR2
*)talloc(ctx
, num_entries
*sizeof(SAM_STR2
))))
1655 return NT_STATUS_NO_MEMORY
;
1657 ZERO_STRUCTP(sam
->sam
);
1658 ZERO_STRUCTP(sam
->str
);
1660 for (i
= 0; i
< num_entries
; i
++) {
1662 const DOM_SID
*user_sid
;
1663 const char *username
;
1664 const char *acct_desc
;
1665 fstring user_sid_string
, domain_sid_string
;
1667 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i
));
1668 pwd
=&disp_user_info
[i
+start_idx
];
1670 username
= pdb_get_username(pwd
);
1671 acct_desc
= pdb_get_acct_desc(pwd
);
1672 user_sid
= pdb_get_user_sid(pwd
);
1674 if (!sid_peek_check_rid(domain_sid
, user_sid
, &user_rid
)) {
1675 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with "
1676 "the domain sid %s. Failing operation.\n",
1678 sid_to_string(user_sid_string
, user_sid
),
1679 sid_to_string(domain_sid_string
, domain_sid
)));
1680 return NT_STATUS_UNSUCCESSFUL
;
1683 len_sam_name
= strlen(username
);
1684 len_sam_desc
= strlen(acct_desc
);
1686 init_sam_entry2(&sam
->sam
[i
], start_idx
+ i
+ 1,
1687 len_sam_name
, len_sam_desc
,
1688 user_rid
, pdb_get_acct_ctrl(pwd
));
1690 ZERO_STRUCTP(&sam
->str
[i
].uni_srv_name
);
1691 ZERO_STRUCTP(&sam
->str
[i
].uni_srv_desc
);
1693 init_unistr2(&sam
->str
[i
].uni_srv_name
, username
, len_sam_name
);
1694 init_unistr2(&sam
->str
[i
].uni_srv_desc
, pdb_get_acct_desc(pwd
), len_sam_desc
);
1697 return NT_STATUS_OK
;
1700 /*******************************************************************
1701 reads or writes a structure.
1702 ********************************************************************/
1704 static BOOL
sam_io_sam_dispinfo_2(const char *desc
, SAM_DISPINFO_2
* sam
,
1706 prs_struct
*ps
, int depth
)
1713 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_2");
1719 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1721 if ((sam
->sam
= (SAM_ENTRY2
*)
1722 prs_alloc_mem(ps
, sizeof(SAM_ENTRY2
) *
1723 num_entries
)) == NULL
) {
1724 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1728 if ((sam
->str
= (SAM_STR2
*)
1729 prs_alloc_mem(ps
, sizeof(SAM_STR2
) *
1730 num_entries
)) == NULL
) {
1731 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1736 for (i
= 0; i
< num_entries
; i
++) {
1737 if(!sam_io_sam_entry2("", &sam
->sam
[i
], ps
, depth
))
1741 for (i
= 0; i
< num_entries
; i
++) {
1742 if(!sam_io_sam_str2("", &sam
->str
[i
],
1743 sam
->sam
[i
].hdr_srv_name
.buffer
,
1744 sam
->sam
[i
].hdr_srv_desc
.buffer
, ps
, depth
))
1751 /*******************************************************************
1752 inits a SAM_DISPINFO_3 structure.
1753 ********************************************************************/
1755 NTSTATUS
init_sam_dispinfo_3(TALLOC_CTX
*ctx
, SAM_DISPINFO_3
*sam
, uint32 num_entries
,
1756 uint32 start_idx
, DOMAIN_GRP
*disp_group_info
)
1758 uint32 len_sam_name
, len_sam_desc
;
1763 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries
));
1766 return NT_STATUS_OK
;
1768 if (!(sam
->sam
=(SAM_ENTRY3
*)talloc(ctx
, num_entries
*sizeof(SAM_ENTRY3
))))
1769 return NT_STATUS_NO_MEMORY
;
1771 if (!(sam
->str
=(SAM_STR3
*)talloc(ctx
, num_entries
*sizeof(SAM_STR3
))))
1772 return NT_STATUS_NO_MEMORY
;
1774 ZERO_STRUCTP(sam
->sam
);
1775 ZERO_STRUCTP(sam
->str
);
1777 for (i
= 0; i
< num_entries
; i
++) {
1778 DOMAIN_GRP
*grp
= &disp_group_info
[i
+start_idx
];
1780 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i
));
1782 len_sam_name
= strlen(grp
->name
);
1783 len_sam_desc
= strlen(grp
->comment
);
1785 init_sam_entry3(&sam
->sam
[i
], start_idx
+ i
+ 1, len_sam_name
, len_sam_desc
, grp
->rid
);
1787 init_unistr2(&sam
->str
[i
].uni_grp_name
, grp
->name
, len_sam_name
);
1788 init_unistr2(&sam
->str
[i
].uni_grp_desc
, grp
->comment
, len_sam_desc
);
1791 return NT_STATUS_OK
;
1794 /*******************************************************************
1795 reads or writes a structure.
1796 ********************************************************************/
1798 static BOOL
sam_io_sam_dispinfo_3(const char *desc
, SAM_DISPINFO_3
* sam
,
1800 prs_struct
*ps
, int depth
)
1807 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_3");
1813 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1815 if ((sam
->sam
= (SAM_ENTRY3
*)
1816 prs_alloc_mem(ps
, sizeof(SAM_ENTRY3
) *
1817 num_entries
)) == NULL
) {
1818 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1822 if ((sam
->str
= (SAM_STR3
*)
1823 prs_alloc_mem(ps
, sizeof(SAM_STR3
) *
1824 num_entries
)) == NULL
) {
1825 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1830 for (i
= 0; i
< num_entries
; i
++) {
1831 if(!sam_io_sam_entry3("", &sam
->sam
[i
], ps
, depth
))
1835 for (i
= 0; i
< num_entries
; i
++) {
1836 if(!sam_io_sam_str3("", &sam
->str
[i
],
1837 sam
->sam
[i
].hdr_grp_name
.buffer
,
1838 sam
->sam
[i
].hdr_grp_desc
.buffer
, ps
, depth
))
1845 /*******************************************************************
1846 inits a SAM_DISPINFO_4 structure.
1847 ********************************************************************/
1849 NTSTATUS
init_sam_dispinfo_4(TALLOC_CTX
*ctx
, SAM_DISPINFO_4
*sam
, uint32 num_entries
,
1850 uint32 start_idx
, SAM_ACCOUNT
*disp_user_info
)
1852 uint32 len_sam_name
;
1855 SAM_ACCOUNT
*pwd
= NULL
;
1858 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries
));
1861 return NT_STATUS_OK
;
1863 if (!(sam
->sam
=(SAM_ENTRY4
*)talloc(ctx
, num_entries
*sizeof(SAM_ENTRY4
))))
1864 return NT_STATUS_NO_MEMORY
;
1866 if (!(sam
->str
=(SAM_STR4
*)talloc(ctx
, num_entries
*sizeof(SAM_STR4
))))
1867 return NT_STATUS_NO_MEMORY
;
1869 ZERO_STRUCTP(sam
->sam
);
1870 ZERO_STRUCTP(sam
->str
);
1872 for (i
= 0; i
< num_entries
; i
++) {
1873 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i
));
1874 pwd
=&disp_user_info
[i
+start_idx
];
1876 len_sam_name
= strlen(pdb_get_username(pwd
));
1878 init_sam_entry4(&sam
->sam
[i
], start_idx
+ i
+ 1, len_sam_name
);
1880 init_string2(&sam
->str
[i
].acct_name
, pdb_get_username(pwd
), len_sam_name
+1, len_sam_name
);
1883 return NT_STATUS_OK
;
1886 /*******************************************************************
1887 reads or writes a structure.
1888 ********************************************************************/
1890 static BOOL
sam_io_sam_dispinfo_4(const char *desc
, SAM_DISPINFO_4
* sam
,
1892 prs_struct
*ps
, int depth
)
1899 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_4");
1905 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1907 if ((sam
->sam
= (SAM_ENTRY4
*)
1908 prs_alloc_mem(ps
, sizeof(SAM_ENTRY4
) *
1909 num_entries
)) == NULL
) {
1910 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1914 if ((sam
->str
= (SAM_STR4
*)
1915 prs_alloc_mem(ps
, sizeof(SAM_STR4
) *
1916 num_entries
)) == NULL
) {
1917 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1922 for (i
= 0; i
< num_entries
; i
++) {
1923 if(!sam_io_sam_entry4("", &sam
->sam
[i
], ps
, depth
))
1927 for (i
= 0; i
< num_entries
; i
++) {
1928 if(!smb_io_string2("acct_name", &sam
->str
[i
].acct_name
,
1929 sam
->sam
[i
].hdr_acct_name
.buffer
, ps
, depth
))
1936 /*******************************************************************
1937 inits a SAM_DISPINFO_5 structure.
1938 ********************************************************************/
1940 NTSTATUS
init_sam_dispinfo_5(TALLOC_CTX
*ctx
, SAM_DISPINFO_5
*sam
, uint32 num_entries
,
1941 uint32 start_idx
, DOMAIN_GRP
*disp_group_info
)
1943 uint32 len_sam_name
;
1948 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries
));
1951 return NT_STATUS_OK
;
1953 if (!(sam
->sam
=(SAM_ENTRY5
*)talloc(ctx
, num_entries
*sizeof(SAM_ENTRY5
))))
1954 return NT_STATUS_NO_MEMORY
;
1956 if (!(sam
->str
=(SAM_STR5
*)talloc(ctx
, num_entries
*sizeof(SAM_STR5
))))
1957 return NT_STATUS_NO_MEMORY
;
1959 ZERO_STRUCTP(sam
->sam
);
1960 ZERO_STRUCTP(sam
->str
);
1962 for (i
= 0; i
< num_entries
; i
++) {
1963 DOMAIN_GRP
*grp
= &disp_group_info
[i
+start_idx
];
1965 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i
));
1967 len_sam_name
= strlen(grp
->name
);
1969 init_sam_entry5(&sam
->sam
[i
], start_idx
+ i
+ 1, len_sam_name
);
1970 init_string2(&sam
->str
[i
].grp_name
, grp
->name
, len_sam_name
+1, len_sam_name
);
1973 return NT_STATUS_OK
;
1976 /*******************************************************************
1977 reads or writes a structure.
1978 ********************************************************************/
1980 static BOOL
sam_io_sam_dispinfo_5(const char *desc
, SAM_DISPINFO_5
* sam
,
1982 prs_struct
*ps
, int depth
)
1989 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_5");
1995 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1997 if ((sam
->sam
= (SAM_ENTRY5
*)
1998 prs_alloc_mem(ps
, sizeof(SAM_ENTRY5
) *
1999 num_entries
)) == NULL
) {
2000 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
2004 if ((sam
->str
= (SAM_STR5
*)
2005 prs_alloc_mem(ps
, sizeof(SAM_STR5
) *
2006 num_entries
)) == NULL
) {
2007 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
2012 for (i
= 0; i
< num_entries
; i
++) {
2013 if(!sam_io_sam_entry5("", &sam
->sam
[i
], ps
, depth
))
2017 for (i
= 0; i
< num_entries
; i
++) {
2018 if(!smb_io_string2("grp_name", &sam
->str
[i
].grp_name
,
2019 sam
->sam
[i
].hdr_grp_name
.buffer
, ps
, depth
))
2026 /*******************************************************************
2027 inits a SAMR_R_QUERY_DISPINFO structure.
2028 ********************************************************************/
2030 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO
* r_u
,
2031 uint32 num_entries
, uint32 total_size
, uint32 data_size
,
2032 uint16 switch_level
, SAM_DISPINFO_CTR
* ctr
,
2035 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level
));
2037 r_u
->total_size
= total_size
;
2039 r_u
->data_size
= data_size
;
2041 r_u
->switch_level
= switch_level
;
2042 r_u
->num_entries
= num_entries
;
2045 r_u
->ptr_entries
= 0;
2047 r_u
->ptr_entries
= 1;
2049 r_u
->num_entries2
= num_entries
;
2052 r_u
->status
= status
;
2055 /*******************************************************************
2056 reads or writes a structure.
2057 ********************************************************************/
2059 BOOL
samr_io_r_query_dispinfo(const char *desc
, SAMR_R_QUERY_DISPINFO
* r_u
,
2060 prs_struct
*ps
, int depth
)
2065 prs_debug(ps
, depth
, desc
, "samr_io_r_query_dispinfo");
2071 if(!prs_uint32("total_size ", ps
, depth
, &r_u
->total_size
))
2073 if(!prs_uint32("data_size ", ps
, depth
, &r_u
->data_size
))
2075 if(!prs_uint16("switch_level", ps
, depth
, &r_u
->switch_level
))
2080 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
2082 if(!prs_uint32("ptr_entries ", ps
, depth
, &r_u
->ptr_entries
))
2085 if (r_u
->ptr_entries
==0) {
2088 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2094 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
2097 switch (r_u
->switch_level
) {
2099 if(!sam_io_sam_dispinfo_1("users", r_u
->ctr
->sam
.info1
,
2100 r_u
->num_entries
, ps
, depth
))
2104 if(!sam_io_sam_dispinfo_2("servers", r_u
->ctr
->sam
.info2
,
2105 r_u
->num_entries
, ps
, depth
))
2109 if(!sam_io_sam_dispinfo_3("groups", r_u
->ctr
->sam
.info3
,
2110 r_u
->num_entries
, ps
, depth
))
2114 if(!sam_io_sam_dispinfo_4("user list",
2115 r_u
->ctr
->sam
.info4
,
2116 r_u
->num_entries
, ps
, depth
))
2120 if(!sam_io_sam_dispinfo_5("group list",
2121 r_u
->ctr
->sam
.info5
,
2122 r_u
->num_entries
, ps
, depth
))
2126 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2132 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2138 /*******************************************************************
2139 inits a SAMR_Q_OPEN_GROUP structure.
2140 ********************************************************************/
2142 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP
* q_c
,
2144 uint32 access_mask
, uint32 rid
)
2146 DEBUG(5, ("init_samr_q_open_group\n"));
2148 q_c
->domain_pol
= *hnd
;
2149 q_c
->access_mask
= access_mask
;
2150 q_c
->rid_group
= rid
;
2153 /*******************************************************************
2154 reads or writes a structure.
2155 ********************************************************************/
2157 BOOL
samr_io_q_open_group(const char *desc
, SAMR_Q_OPEN_GROUP
* q_u
,
2158 prs_struct
*ps
, int depth
)
2163 prs_debug(ps
, depth
, desc
, "samr_io_q_open_group");
2169 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
2172 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
2174 if(!prs_uint32("rid_group", ps
, depth
, &q_u
->rid_group
))
2180 /*******************************************************************
2181 reads or writes a structure.
2182 ********************************************************************/
2184 BOOL
samr_io_r_open_group(const char *desc
, SAMR_R_OPEN_GROUP
* r_u
,
2185 prs_struct
*ps
, int depth
)
2190 prs_debug(ps
, depth
, desc
, "samr_io_r_open_group");
2196 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2199 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2205 /*******************************************************************
2206 inits a GROUP_INFO1 structure.
2207 ********************************************************************/
2209 void init_samr_group_info1(GROUP_INFO1
* gr1
,
2210 char *acct_name
, char *acct_desc
,
2213 int desc_len
= acct_desc
!= NULL
? strlen(acct_desc
) : 0;
2214 int acct_len
= acct_name
!= NULL
? strlen(acct_name
) : 0;
2216 DEBUG(5, ("init_samr_group_info1\n"));
2218 init_uni_hdr(&gr1
->hdr_acct_name
, acct_len
);
2220 gr1
->unknown_1
= 0x3;
2221 gr1
->num_members
= num_members
;
2223 init_uni_hdr(&gr1
->hdr_acct_desc
, desc_len
);
2225 init_unistr2(&gr1
->uni_acct_name
, acct_name
, acct_len
);
2226 init_unistr2(&gr1
->uni_acct_desc
, acct_desc
, desc_len
);
2229 /*******************************************************************
2230 reads or writes a structure.
2231 ********************************************************************/
2233 BOOL
samr_io_group_info1(const char *desc
, GROUP_INFO1
* gr1
,
2234 prs_struct
*ps
, int depth
)
2239 prs_debug(ps
, depth
, desc
, "samr_io_group_info1");
2245 if(!smb_io_unihdr("hdr_acct_name", &gr1
->hdr_acct_name
, ps
, depth
))
2248 if(!prs_uint32("unknown_1", ps
, depth
, &gr1
->unknown_1
))
2250 if(!prs_uint32("num_members", ps
, depth
, &gr1
->num_members
))
2253 if(!smb_io_unihdr("hdr_acct_desc", &gr1
->hdr_acct_desc
, ps
, depth
))
2256 if(!smb_io_unistr2("uni_acct_name", &gr1
->uni_acct_name
,
2257 gr1
->hdr_acct_name
.buffer
, ps
, depth
))
2260 if(!smb_io_unistr2("uni_acct_desc", &gr1
->uni_acct_desc
,
2261 gr1
->hdr_acct_desc
.buffer
, ps
, depth
))
2267 /*******************************************************************
2268 inits a GROUP_INFO3 structure.
2269 ********************************************************************/
2271 void init_samr_group_info3(GROUP_INFO3
*gr3
)
2273 DEBUG(5, ("init_samr_group_info3\n"));
2275 gr3
->unknown_1
= 0x3;
2278 /*******************************************************************
2279 reads or writes a structure.
2280 ********************************************************************/
2282 BOOL
samr_io_group_info3(const char *desc
, GROUP_INFO3
*gr3
, prs_struct
*ps
, int depth
)
2287 prs_debug(ps
, depth
, desc
, "samr_io_group_info3");
2293 if(!prs_uint32("unknown_1", ps
, depth
, &gr3
->unknown_1
))
2299 /*******************************************************************
2300 inits a GROUP_INFO4 structure.
2301 ********************************************************************/
2303 void init_samr_group_info4(GROUP_INFO4
* gr4
, char *acct_desc
)
2305 int acct_len
= acct_desc
!= NULL
? strlen(acct_desc
) : 0;
2307 DEBUG(5, ("init_samr_group_info4\n"));
2309 init_uni_hdr(&gr4
->hdr_acct_desc
, acct_len
);
2310 init_unistr2(&gr4
->uni_acct_desc
, acct_desc
, acct_len
);
2313 /*******************************************************************
2314 reads or writes a structure.
2315 ********************************************************************/
2317 BOOL
samr_io_group_info4(const char *desc
, GROUP_INFO4
* gr4
,
2318 prs_struct
*ps
, int depth
)
2323 prs_debug(ps
, depth
, desc
, "samr_io_group_info4");
2329 if(!smb_io_unihdr("hdr_acct_desc", &gr4
->hdr_acct_desc
, ps
, depth
))
2331 if(!smb_io_unistr2("uni_acct_desc", &gr4
->uni_acct_desc
,
2332 gr4
->hdr_acct_desc
.buffer
, ps
, depth
))
2338 /*******************************************************************
2339 reads or writes a structure.
2340 ********************************************************************/
2342 static BOOL
samr_group_info_ctr(const char *desc
, GROUP_INFO_CTR
**ctr
,
2343 prs_struct
*ps
, int depth
)
2345 if (UNMARSHALLING(ps
))
2346 *ctr
= (GROUP_INFO_CTR
*)prs_alloc_mem(ps
,sizeof(GROUP_INFO_CTR
));
2351 prs_debug(ps
, depth
, desc
, "samr_group_info_ctr");
2354 if(!prs_uint16("switch_value1", ps
, depth
, &(*ctr
)->switch_value1
))
2357 switch ((*ctr
)->switch_value1
) {
2359 if(!samr_io_group_info1("group_info1", &(*ctr
)->group
.info1
, ps
, depth
))
2363 if(!samr_io_group_info3("group_info3", &(*ctr
)->group
.info3
, ps
, depth
))
2367 if(!samr_io_group_info4("group_info4", &(*ctr
)->group
.info4
, ps
, depth
))
2371 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2378 /*******************************************************************
2379 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2380 ********************************************************************/
2382 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP
* q_e
,
2383 POLICY_HND
*pol
, char *acct_desc
,
2386 int acct_len
= acct_desc
!= NULL
? strlen(acct_desc
) : 0;
2388 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2392 init_uni_hdr(&q_e
->hdr_acct_desc
, acct_len
);
2393 init_unistr2(&q_e
->uni_acct_desc
, acct_desc
, acct_len
);
2395 q_e
->access_mask
= access_mask
;
2398 /*******************************************************************
2399 reads or writes a structure.
2400 ********************************************************************/
2402 BOOL
samr_io_q_create_dom_group(const char *desc
, SAMR_Q_CREATE_DOM_GROUP
* q_e
,
2403 prs_struct
*ps
, int depth
)
2408 prs_debug(ps
, depth
, desc
, "samr_io_q_create_dom_group");
2414 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2417 if(!smb_io_unihdr("hdr_acct_desc", &q_e
->hdr_acct_desc
, ps
, depth
))
2419 if(!smb_io_unistr2("uni_acct_desc", &q_e
->uni_acct_desc
,
2420 q_e
->hdr_acct_desc
.buffer
, ps
, depth
))
2425 if(!prs_uint32("access", ps
, depth
, &q_e
->access_mask
))
2431 /*******************************************************************
2432 reads or writes a structure.
2433 ********************************************************************/
2435 BOOL
samr_io_r_create_dom_group(const char *desc
, SAMR_R_CREATE_DOM_GROUP
* r_u
,
2436 prs_struct
*ps
, int depth
)
2441 prs_debug(ps
, depth
, desc
, "samr_io_r_create_dom_group");
2447 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2450 if(!prs_uint32("rid ", ps
, depth
, &r_u
->rid
))
2452 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2458 /*******************************************************************
2459 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2460 ********************************************************************/
2462 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP
* q_c
,
2465 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2467 q_c
->group_pol
= *hnd
;
2470 /*******************************************************************
2471 reads or writes a structure.
2472 ********************************************************************/
2474 BOOL
samr_io_q_delete_dom_group(const char *desc
, SAMR_Q_DELETE_DOM_GROUP
* q_u
,
2475 prs_struct
*ps
, int depth
)
2480 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_group");
2486 if(!smb_io_pol_hnd("group_pol", &q_u
->group_pol
, ps
, depth
))
2492 /*******************************************************************
2493 reads or writes a structure.
2494 ********************************************************************/
2496 BOOL
samr_io_r_delete_dom_group(const char *desc
, SAMR_R_DELETE_DOM_GROUP
* r_u
,
2497 prs_struct
*ps
, int depth
)
2502 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_group");
2508 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2511 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2517 /*******************************************************************
2518 inits a SAMR_Q_DEL_GROUPMEM structure.
2519 ********************************************************************/
2521 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM
* q_e
,
2522 POLICY_HND
*pol
, uint32 rid
)
2524 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2530 /*******************************************************************
2531 reads or writes a structure.
2532 ********************************************************************/
2534 BOOL
samr_io_q_del_groupmem(const char *desc
, SAMR_Q_DEL_GROUPMEM
* q_e
,
2535 prs_struct
*ps
, int depth
)
2540 prs_debug(ps
, depth
, desc
, "samr_io_q_del_groupmem");
2546 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2549 if(!prs_uint32("rid", ps
, depth
, &q_e
->rid
))
2555 /*******************************************************************
2556 inits a SAMR_R_DEL_GROUPMEM structure.
2557 ********************************************************************/
2559 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM
* r_u
, POLICY_HND
*pol
,
2562 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2564 r_u
->status
= status
;
2567 /*******************************************************************
2568 reads or writes a structure.
2569 ********************************************************************/
2571 BOOL
samr_io_r_del_groupmem(const char *desc
, SAMR_R_DEL_GROUPMEM
* r_u
,
2572 prs_struct
*ps
, int depth
)
2577 prs_debug(ps
, depth
, desc
, "samr_io_r_del_groupmem");
2583 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2589 /*******************************************************************
2590 inits a SAMR_Q_ADD_GROUPMEM structure.
2591 ********************************************************************/
2593 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM
* q_e
,
2594 POLICY_HND
*pol
, uint32 rid
)
2596 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2600 q_e
->unknown
= 0x0005;
2603 /*******************************************************************
2604 reads or writes a structure.
2605 ********************************************************************/
2607 BOOL
samr_io_q_add_groupmem(const char *desc
, SAMR_Q_ADD_GROUPMEM
* q_e
,
2608 prs_struct
*ps
, int depth
)
2613 prs_debug(ps
, depth
, desc
, "samr_io_q_add_groupmem");
2619 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2622 if(!prs_uint32("rid ", ps
, depth
, &q_e
->rid
))
2624 if(!prs_uint32("unknown", ps
, depth
, &q_e
->unknown
))
2630 /*******************************************************************
2631 inits a SAMR_R_ADD_GROUPMEM structure.
2632 ********************************************************************/
2634 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM
* r_u
, POLICY_HND
*pol
,
2637 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2639 r_u
->status
= status
;
2642 /*******************************************************************
2643 reads or writes a structure.
2644 ********************************************************************/
2646 BOOL
samr_io_r_add_groupmem(const char *desc
, SAMR_R_ADD_GROUPMEM
* r_u
,
2647 prs_struct
*ps
, int depth
)
2652 prs_debug(ps
, depth
, desc
, "samr_io_r_add_groupmem");
2658 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2664 /*******************************************************************
2665 inits a SAMR_Q_SET_GROUPINFO structure.
2666 ********************************************************************/
2668 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO
* q_e
,
2669 POLICY_HND
*pol
, GROUP_INFO_CTR
* ctr
)
2671 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2677 /*******************************************************************
2678 reads or writes a structure.
2679 ********************************************************************/
2681 BOOL
samr_io_q_set_groupinfo(const char *desc
, SAMR_Q_SET_GROUPINFO
* q_e
,
2682 prs_struct
*ps
, int depth
)
2687 prs_debug(ps
, depth
, desc
, "samr_io_q_set_groupinfo");
2693 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2696 if(!samr_group_info_ctr("ctr", &q_e
->ctr
, ps
, depth
))
2702 /*******************************************************************
2703 inits a SAMR_R_SET_GROUPINFO structure.
2704 ********************************************************************/
2706 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO
* r_u
, NTSTATUS status
)
2708 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2710 r_u
->status
= status
;
2713 /*******************************************************************
2714 reads or writes a structure.
2715 ********************************************************************/
2717 BOOL
samr_io_r_set_groupinfo(const char *desc
, SAMR_R_SET_GROUPINFO
* r_u
,
2718 prs_struct
*ps
, int depth
)
2723 prs_debug(ps
, depth
, desc
, "samr_io_r_set_groupinfo");
2729 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2735 /*******************************************************************
2736 inits a SAMR_Q_QUERY_GROUPINFO structure.
2737 ********************************************************************/
2739 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO
* q_e
,
2740 POLICY_HND
*pol
, uint16 switch_level
)
2742 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2746 q_e
->switch_level
= switch_level
;
2749 /*******************************************************************
2750 reads or writes a structure.
2751 ********************************************************************/
2753 BOOL
samr_io_q_query_groupinfo(const char *desc
, SAMR_Q_QUERY_GROUPINFO
* q_e
,
2754 prs_struct
*ps
, int depth
)
2759 prs_debug(ps
, depth
, desc
, "samr_io_q_query_groupinfo");
2765 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2768 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
2774 /*******************************************************************
2775 inits a SAMR_R_QUERY_GROUPINFO structure.
2776 ********************************************************************/
2778 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO
* r_u
,
2779 GROUP_INFO_CTR
* ctr
, NTSTATUS status
)
2781 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2783 r_u
->ptr
= (NT_STATUS_IS_OK(status
) && ctr
!= NULL
) ? 1 : 0;
2785 r_u
->status
= status
;
2788 /*******************************************************************
2789 reads or writes a structure.
2790 ********************************************************************/
2792 BOOL
samr_io_r_query_groupinfo(const char *desc
, SAMR_R_QUERY_GROUPINFO
* r_u
,
2793 prs_struct
*ps
, int depth
)
2798 prs_debug(ps
, depth
, desc
, "samr_io_r_query_groupinfo");
2804 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
2807 if (r_u
->ptr
!= 0) {
2808 if(!samr_group_info_ctr("ctr", &r_u
->ctr
, ps
, depth
))
2814 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2820 /*******************************************************************
2821 inits a SAMR_Q_QUERY_GROUPMEM structure.
2822 ********************************************************************/
2824 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM
* q_c
, POLICY_HND
*hnd
)
2826 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2828 q_c
->group_pol
= *hnd
;
2831 /*******************************************************************
2832 reads or writes a structure.
2833 ********************************************************************/
2835 BOOL
samr_io_q_query_groupmem(const char *desc
, SAMR_Q_QUERY_GROUPMEM
* q_u
,
2836 prs_struct
*ps
, int depth
)
2841 prs_debug(ps
, depth
, desc
, "samr_io_q_query_groupmem");
2847 if(!smb_io_pol_hnd("group_pol", &q_u
->group_pol
, ps
, depth
))
2853 /*******************************************************************
2854 inits a SAMR_R_QUERY_GROUPMEM structure.
2855 ********************************************************************/
2857 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM
* r_u
,
2858 uint32 num_entries
, uint32
*rid
,
2859 uint32
*attr
, NTSTATUS status
)
2861 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2863 if (NT_STATUS_IS_OK(status
)) {
2865 r_u
->num_entries
= num_entries
;
2867 r_u
->ptr_attrs
= attr
!= NULL
? 1 : 0;
2868 r_u
->ptr_rids
= rid
!= NULL
? 1 : 0;
2870 r_u
->num_rids
= num_entries
;
2873 r_u
->num_attrs
= num_entries
;
2877 r_u
->num_entries
= 0;
2880 r_u
->status
= status
;
2883 /*******************************************************************
2884 reads or writes a structure.
2885 ********************************************************************/
2887 BOOL
samr_io_r_query_groupmem(const char *desc
, SAMR_R_QUERY_GROUPMEM
* r_u
,
2888 prs_struct
*ps
, int depth
)
2895 if (UNMARSHALLING(ps
))
2898 prs_debug(ps
, depth
, desc
, "samr_io_r_query_groupmem");
2904 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
2906 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
2909 if (r_u
->ptr
!= 0) {
2910 if(!prs_uint32("ptr_rids ", ps
, depth
, &r_u
->ptr_rids
))
2912 if(!prs_uint32("ptr_attrs", ps
, depth
, &r_u
->ptr_attrs
))
2915 if (r_u
->ptr_rids
!= 0) {
2916 if(!prs_uint32("num_rids", ps
, depth
, &r_u
->num_rids
))
2918 if (UNMARSHALLING(ps
) && r_u
->num_rids
!= 0) {
2919 r_u
->rid
= (uint32
*)prs_alloc_mem(ps
,sizeof(r_u
->rid
[0])*r_u
->num_rids
);
2920 if (r_u
->rid
== NULL
)
2924 for (i
= 0; i
< r_u
->num_rids
; i
++) {
2925 if(!prs_uint32("", ps
, depth
, &r_u
->rid
[i
]))
2930 if (r_u
->ptr_attrs
!= 0) {
2931 if(!prs_uint32("num_attrs", ps
, depth
, &r_u
->num_attrs
))
2934 if (UNMARSHALLING(ps
) && r_u
->num_attrs
!= 0) {
2935 r_u
->attr
= (uint32
*)prs_alloc_mem(ps
,sizeof(r_u
->attr
[0])*r_u
->num_attrs
);
2936 if (r_u
->attr
== NULL
)
2940 for (i
= 0; i
< r_u
->num_attrs
; i
++) {
2941 if(!prs_uint32("", ps
, depth
, &r_u
->attr
[i
]))
2947 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2953 /*******************************************************************
2954 inits a SAMR_Q_QUERY_USERGROUPS structure.
2955 ********************************************************************/
2957 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS
* q_u
,
2960 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2965 /*******************************************************************
2966 reads or writes a structure.
2967 ********************************************************************/
2969 BOOL
samr_io_q_query_usergroups(const char *desc
, SAMR_Q_QUERY_USERGROUPS
* q_u
,
2970 prs_struct
*ps
, int depth
)
2975 prs_debug(ps
, depth
, desc
, "samr_io_q_query_usergroups");
2981 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
2987 /*******************************************************************
2988 inits a SAMR_R_QUERY_USERGROUPS structure.
2989 ********************************************************************/
2991 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS
* r_u
,
2992 uint32 num_gids
, DOM_GID
* gid
,
2995 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2997 if (NT_STATUS_IS_OK(status
)) {
2999 r_u
->num_entries
= num_gids
;
3000 r_u
->ptr_1
= (num_gids
!= 0) ? 1 : 0;
3001 r_u
->num_entries2
= num_gids
;
3006 r_u
->num_entries
= 0;
3011 r_u
->status
= status
;
3014 /*******************************************************************
3015 reads or writes a structure.
3016 ********************************************************************/
3018 BOOL
samr_io_gids(const char *desc
, uint32
*num_gids
, DOM_GID
** gid
,
3019 prs_struct
*ps
, int depth
)
3025 prs_debug(ps
, depth
, desc
, "samr_io_gids");
3031 if(!prs_uint32("num_gids", ps
, depth
, num_gids
))
3034 if ((*num_gids
) != 0) {
3035 if (UNMARSHALLING(ps
)) {
3036 (*gid
) = (DOM_GID
*)prs_alloc_mem(ps
,sizeof(DOM_GID
)*(*num_gids
));
3039 if ((*gid
) == NULL
) {
3043 for (i
= 0; i
< (*num_gids
); i
++) {
3044 if(!smb_io_gid("gids", &(*gid
)[i
], ps
, depth
))
3052 /*******************************************************************
3053 reads or writes a structure.
3054 ********************************************************************/
3056 BOOL
samr_io_r_query_usergroups(const char *desc
, SAMR_R_QUERY_USERGROUPS
* r_u
,
3057 prs_struct
*ps
, int depth
)
3062 prs_debug(ps
, depth
, desc
, "samr_io_r_query_usergroups");
3068 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
3071 if (r_u
->ptr_0
!= 0) {
3072 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
3074 if(!prs_uint32("ptr_1 ", ps
, depth
, &r_u
->ptr_1
))
3077 if (r_u
->num_entries
!= 0 && r_u
->ptr_1
!= 0) {
3078 if(!samr_io_gids("gids", &r_u
->num_entries2
, &r_u
->gid
, ps
, depth
))
3085 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3091 /*******************************************************************
3092 inits a SAMR_Q_ENUM_DOMAINS structure.
3093 ********************************************************************/
3095 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS
* q_e
,
3097 uint32 start_idx
, uint32 size
)
3099 DEBUG(5, ("init_samr_q_enum_domains\n"));
3103 q_e
->start_idx
= start_idx
;
3104 q_e
->max_size
= size
;
3107 /*******************************************************************
3108 reads or writes a structure.
3109 ********************************************************************/
3111 BOOL
samr_io_q_enum_domains(const char *desc
, SAMR_Q_ENUM_DOMAINS
* q_e
,
3112 prs_struct
*ps
, int depth
)
3117 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_domains");
3123 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
3126 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3128 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3134 /*******************************************************************
3135 inits a SAMR_R_ENUM_DOMAINS structure.
3136 ********************************************************************/
3138 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS
* r_u
,
3139 uint32 next_idx
, uint32 num_sam_entries
)
3141 DEBUG(5, ("init_samr_r_enum_domains\n"));
3143 r_u
->next_idx
= next_idx
;
3145 if (num_sam_entries
!= 0) {
3146 r_u
->ptr_entries1
= 1;
3147 r_u
->ptr_entries2
= 1;
3148 r_u
->num_entries2
= num_sam_entries
;
3149 r_u
->num_entries3
= num_sam_entries
;
3151 r_u
->num_entries4
= num_sam_entries
;
3153 r_u
->ptr_entries1
= 0;
3154 r_u
->num_entries2
= num_sam_entries
;
3155 r_u
->ptr_entries2
= 1;
3159 /*******************************************************************
3160 reads or writes a structure.
3161 ********************************************************************/
3163 BOOL
samr_io_r_enum_domains(const char *desc
, SAMR_R_ENUM_DOMAINS
* r_u
,
3164 prs_struct
*ps
, int depth
)
3171 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_domains");
3177 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3179 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3182 if (r_u
->ptr_entries1
!= 0) {
3183 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3185 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3187 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3190 if (UNMARSHALLING(ps
)) {
3191 r_u
->sam
= (SAM_ENTRY
*)prs_alloc_mem(ps
,sizeof(SAM_ENTRY
)*r_u
->num_entries2
);
3192 r_u
->uni_dom_name
= (UNISTR2
*)prs_alloc_mem(ps
,sizeof(UNISTR2
)*r_u
->num_entries2
);
3195 if ((r_u
->sam
== NULL
|| r_u
->uni_dom_name
== NULL
) && r_u
->num_entries2
!= 0) {
3196 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3197 r_u
->num_entries4
= 0;
3198 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3202 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3204 slprintf(tmp
, sizeof(tmp
) - 1, "dom[%d]", i
);
3205 if(!sam_io_sam_entry(tmp
, &r_u
->sam
[i
], ps
, depth
))
3209 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3211 slprintf(tmp
, sizeof(tmp
) - 1, "dom[%d]", i
);
3212 if(!smb_io_unistr2(tmp
, &r_u
->uni_dom_name
[i
],
3213 r_u
->sam
[i
].hdr_name
.buffer
, ps
,
3222 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3224 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3230 /*******************************************************************
3231 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3232 ********************************************************************/
3234 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS
* q_e
,
3236 uint32 start_idx
, uint32 size
)
3238 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3242 q_e
->start_idx
= start_idx
;
3243 q_e
->max_size
= size
;
3246 /*******************************************************************
3247 reads or writes a structure.
3248 ********************************************************************/
3250 BOOL
samr_io_q_enum_dom_groups(const char *desc
, SAMR_Q_ENUM_DOM_GROUPS
* q_e
,
3251 prs_struct
*ps
, int depth
)
3256 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_groups");
3262 if(!smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
))
3265 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3267 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3273 /*******************************************************************
3274 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3275 ********************************************************************/
3277 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS
* r_u
,
3278 uint32 next_idx
, uint32 num_sam_entries
)
3280 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3282 r_u
->next_idx
= next_idx
;
3284 if (num_sam_entries
!= 0) {
3285 r_u
->ptr_entries1
= 1;
3286 r_u
->ptr_entries2
= 1;
3287 r_u
->num_entries2
= num_sam_entries
;
3288 r_u
->num_entries3
= num_sam_entries
;
3290 r_u
->num_entries4
= num_sam_entries
;
3292 r_u
->ptr_entries1
= 0;
3293 r_u
->num_entries2
= num_sam_entries
;
3294 r_u
->ptr_entries2
= 1;
3298 /*******************************************************************
3299 reads or writes a structure.
3300 ********************************************************************/
3302 BOOL
samr_io_r_enum_dom_groups(const char *desc
, SAMR_R_ENUM_DOM_GROUPS
* r_u
,
3303 prs_struct
*ps
, int depth
)
3310 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_groups");
3316 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3318 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3321 if (r_u
->ptr_entries1
!= 0) {
3322 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3324 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3326 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3329 if (UNMARSHALLING(ps
)) {
3330 r_u
->sam
= (SAM_ENTRY
*)prs_alloc_mem(ps
,sizeof(SAM_ENTRY
)*r_u
->num_entries2
);
3331 r_u
->uni_grp_name
= (UNISTR2
*)prs_alloc_mem(ps
,sizeof(UNISTR2
)*r_u
->num_entries2
);
3334 if ((r_u
->sam
== NULL
|| r_u
->uni_grp_name
== NULL
) && r_u
->num_entries2
!= 0) {
3336 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3337 r_u
->num_entries4
= 0;
3338 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3342 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3343 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
3347 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3348 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
],
3349 r_u
->sam
[i
].hdr_name
.buffer
, ps
, depth
))
3356 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3358 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3364 /*******************************************************************
3365 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3366 ********************************************************************/
3368 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES
* q_e
,
3369 POLICY_HND
*pol
, uint32 start_idx
,
3372 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3376 q_e
->start_idx
= start_idx
;
3377 q_e
->max_size
= size
;
3381 /*******************************************************************
3382 reads or writes a structure.
3383 ********************************************************************/
3385 BOOL
samr_io_q_enum_dom_aliases(const char *desc
, SAMR_Q_ENUM_DOM_ALIASES
* q_e
,
3386 prs_struct
*ps
, int depth
)
3391 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_aliases");
3397 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
3400 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3402 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3408 /*******************************************************************
3409 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3410 ********************************************************************/
3412 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES
*r_u
, uint32 next_idx
, uint32 num_sam_entries
)
3414 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3416 r_u
->next_idx
= next_idx
;
3418 if (num_sam_entries
!= 0) {
3419 r_u
->ptr_entries1
= 1;
3420 r_u
->ptr_entries2
= 1;
3421 r_u
->num_entries2
= num_sam_entries
;
3422 r_u
->num_entries3
= num_sam_entries
;
3424 r_u
->num_entries4
= num_sam_entries
;
3426 r_u
->ptr_entries1
= 0;
3427 r_u
->num_entries2
= num_sam_entries
;
3428 r_u
->ptr_entries2
= 1;
3432 /*******************************************************************
3433 reads or writes a structure.
3434 ********************************************************************/
3436 BOOL
samr_io_r_enum_dom_aliases(const char *desc
, SAMR_R_ENUM_DOM_ALIASES
* r_u
,
3437 prs_struct
*ps
, int depth
)
3444 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_aliases");
3450 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3452 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3455 if (r_u
->ptr_entries1
!= 0) {
3456 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3458 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3460 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3463 if (UNMARSHALLING(ps
) && (r_u
->num_entries2
> 0)) {
3464 r_u
->sam
= (SAM_ENTRY
*)prs_alloc_mem(ps
,sizeof(SAM_ENTRY
)*r_u
->num_entries2
);
3465 r_u
->uni_grp_name
= (UNISTR2
*)prs_alloc_mem(ps
,sizeof(UNISTR2
)*r_u
->num_entries2
);
3468 if (r_u
->num_entries2
!= 0 &&
3469 (r_u
->sam
== NULL
|| r_u
->uni_grp_name
== NULL
)) {
3470 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3471 r_u
->num_entries4
= 0;
3472 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3476 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3477 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
3481 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3482 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
],
3483 r_u
->sam
[i
].hdr_name
.buffer
, ps
,
3491 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3493 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3499 /*******************************************************************
3500 inits a ALIAS_INFO1 structure.
3501 ********************************************************************/
3503 void init_samr_alias_info1(ALIAS_INFO1
* al1
, char *acct_name
, uint32 num_member
, char *acct_desc
)
3505 int acct_len_name
= acct_name
!= NULL
? strlen(acct_name
) : 0;
3506 int acct_len_desc
= acct_desc
!= NULL
? strlen(acct_desc
) : 0;
3508 DEBUG(5, ("init_samr_alias_info1\n"));
3510 init_uni_hdr(&al1
->hdr_acct_name
, acct_len_name
);
3511 init_unistr2(&al1
->uni_acct_name
, acct_name
, acct_len_name
);
3513 al1
->num_member
=num_member
;
3515 init_uni_hdr(&al1
->hdr_acct_desc
, acct_len_desc
);
3516 init_unistr2(&al1
->uni_acct_desc
, acct_desc
, acct_len_desc
);
3519 /*******************************************************************
3520 reads or writes a structure.
3521 ********************************************************************/
3523 BOOL
samr_io_alias_info1(const char *desc
, ALIAS_INFO1
* al1
,
3524 prs_struct
*ps
, int depth
)
3529 prs_debug(ps
, depth
, desc
, "samr_io_alias_info1");
3535 if(!smb_io_unihdr("hdr_acct_name", &al1
->hdr_acct_name
, ps
, depth
))
3537 if(!prs_uint32("num_member", ps
, depth
, &al1
->num_member
))
3539 if(!smb_io_unihdr("hdr_acct_desc", &al1
->hdr_acct_desc
, ps
, depth
))
3542 if(!smb_io_unistr2("uni_acct_name", &al1
->uni_acct_name
,
3543 al1
->hdr_acct_name
.buffer
, ps
, depth
))
3549 if(!smb_io_unistr2("uni_acct_desc", &al1
->uni_acct_desc
,
3550 al1
->hdr_acct_desc
.buffer
, ps
, depth
))
3556 /*******************************************************************
3557 inits a ALIAS_INFO3 structure.
3558 ********************************************************************/
3560 void init_samr_alias_info3(ALIAS_INFO3
* al3
, char *acct_desc
)
3562 int acct_len
= acct_desc
!= NULL
? strlen(acct_desc
) : 0;
3564 DEBUG(5, ("init_samr_alias_info3\n"));
3566 init_uni_hdr(&al3
->hdr_acct_desc
, acct_len
);
3567 init_unistr2(&al3
->uni_acct_desc
, acct_desc
, acct_len
);
3570 /*******************************************************************
3571 reads or writes a structure.
3572 ********************************************************************/
3574 BOOL
samr_io_alias_info3(const char *desc
, ALIAS_INFO3
* al3
,
3575 prs_struct
*ps
, int depth
)
3580 prs_debug(ps
, depth
, desc
, "samr_io_alias_info3");
3586 if(!smb_io_unihdr("hdr_acct_desc", &al3
->hdr_acct_desc
, ps
, depth
))
3588 if(!smb_io_unistr2("uni_acct_desc", &al3
->uni_acct_desc
,
3589 al3
->hdr_acct_desc
.buffer
, ps
, depth
))
3595 /*******************************************************************
3596 reads or writes a structure.
3597 ********************************************************************/
3599 BOOL
samr_alias_info_ctr(const char *desc
, ALIAS_INFO_CTR
* ctr
,
3600 prs_struct
*ps
, int depth
)
3605 prs_debug(ps
, depth
, desc
, "samr_alias_info_ctr");
3608 if(!prs_uint16("switch_value1", ps
, depth
, &ctr
->switch_value1
))
3610 if(!prs_uint16("switch_value2", ps
, depth
, &ctr
->switch_value2
))
3613 switch (ctr
->switch_value1
) {
3615 if(!samr_io_alias_info1("alias_info1", &ctr
->alias
.info1
, ps
, depth
))
3619 if(!samr_io_alias_info3("alias_info3", &ctr
->alias
.info3
, ps
, depth
))
3623 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3630 /*******************************************************************
3631 inits a SAMR_Q_QUERY_ALIASINFO structure.
3632 ********************************************************************/
3634 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO
* q_e
,
3635 POLICY_HND
*pol
, uint16 switch_level
)
3637 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3640 q_e
->switch_level
= switch_level
;
3643 /*******************************************************************
3644 reads or writes a structure.
3645 ********************************************************************/
3647 BOOL
samr_io_q_query_aliasinfo(const char *desc
, SAMR_Q_QUERY_ALIASINFO
* q_e
,
3648 prs_struct
*ps
, int depth
)
3653 prs_debug(ps
, depth
, desc
, "samr_io_q_query_aliasinfo");
3659 if(!smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
))
3662 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
3668 /*******************************************************************
3669 inits a SAMR_R_QUERY_ALIASINFO structure.
3670 ********************************************************************/
3672 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO
* r_u
,
3673 ALIAS_INFO_CTR
* ctr
, NTSTATUS status
)
3675 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3677 r_u
->ptr
= (NT_STATUS_IS_OK(status
) && ctr
!= NULL
) ? 1 : 0;
3679 r_u
->status
= status
;
3682 /*******************************************************************
3683 reads or writes a structure.
3684 ********************************************************************/
3686 BOOL
samr_io_r_query_aliasinfo(const char *desc
, SAMR_R_QUERY_ALIASINFO
* r_u
,
3687 prs_struct
*ps
, int depth
)
3692 prs_debug(ps
, depth
, desc
, "samr_io_r_query_aliasinfo");
3698 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
3701 if (r_u
->ptr
!= 0) {
3702 if(!samr_alias_info_ctr("ctr", &r_u
->ctr
, ps
, depth
))
3708 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3714 /*******************************************************************
3715 inits a SAMR_Q_SET_ALIASINFO structure.
3716 ********************************************************************/
3718 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO
* q_u
,
3719 POLICY_HND
*hnd
, ALIAS_INFO_CTR
* ctr
)
3721 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3723 q_u
->alias_pol
= *hnd
;
3727 /*******************************************************************
3728 reads or writes a structure.
3729 ********************************************************************/
3731 BOOL
samr_io_q_set_aliasinfo(const char *desc
, SAMR_Q_SET_ALIASINFO
* q_u
,
3732 prs_struct
*ps
, int depth
)
3737 prs_debug(ps
, depth
, desc
, "samr_io_q_set_aliasinfo");
3743 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
3745 if(!samr_alias_info_ctr("ctr", &q_u
->ctr
, ps
, depth
))
3751 /*******************************************************************
3752 reads or writes a structure.
3753 ********************************************************************/
3755 BOOL
samr_io_r_set_aliasinfo(const char *desc
, SAMR_R_SET_ALIASINFO
* r_u
,
3756 prs_struct
*ps
, int depth
)
3761 prs_debug(ps
, depth
, desc
, "samr_io_r_set_aliasinfo");
3766 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3772 /*******************************************************************
3773 inits a SAMR_Q_QUERY_USERALIASES structure.
3774 ********************************************************************/
3776 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES
* q_u
,
3779 uint32
*ptr_sid
, DOM_SID2
* sid
)
3781 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3785 q_u
->num_sids1
= num_sids
;
3787 q_u
->num_sids2
= num_sids
;
3789 q_u
->ptr_sid
= ptr_sid
;
3793 /*******************************************************************
3794 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3795 ********************************************************************/
3797 BOOL
samr_io_q_query_useraliases(const char *desc
, SAMR_Q_QUERY_USERALIASES
* q_u
,
3798 prs_struct
*ps
, int depth
)
3806 prs_debug(ps
, depth
, desc
, "samr_io_q_query_useraliases");
3812 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
3815 if(!prs_uint32("num_sids1", ps
, depth
, &q_u
->num_sids1
))
3817 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
3823 if(!prs_uint32("num_sids2", ps
, depth
, &q_u
->num_sids2
))
3826 if (UNMARSHALLING(ps
) && (q_u
->num_sids2
!= 0)) {
3827 q_u
->ptr_sid
= (uint32
*)prs_alloc_mem(ps
,sizeof(q_u
->ptr_sid
[0])*q_u
->num_sids2
);
3828 if (q_u
->ptr_sid
== NULL
)
3831 q_u
->sid
= (DOM_SID2
*)prs_alloc_mem(ps
, sizeof(q_u
->sid
[0]) * q_u
->num_sids2
);
3832 if (q_u
->sid
== NULL
)
3836 for (i
= 0; i
< q_u
->num_sids2
; i
++) {
3837 slprintf(tmp
, sizeof(tmp
) - 1, "ptr[%02d]", i
);
3838 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->ptr_sid
[i
]))
3842 for (i
= 0; i
< q_u
->num_sids2
; i
++) {
3843 if (q_u
->ptr_sid
[i
] != 0) {
3844 slprintf(tmp
, sizeof(tmp
) - 1, "sid[%02d]", i
);
3845 if(!smb_io_dom_sid2(tmp
, &q_u
->sid
[i
], ps
, depth
))
3853 /*******************************************************************
3854 inits a SAMR_R_QUERY_USERALIASES structure.
3855 ********************************************************************/
3857 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES
* r_u
,
3858 uint32 num_rids
, uint32
*rid
,
3861 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3863 if (NT_STATUS_IS_OK(status
)) {
3864 r_u
->num_entries
= num_rids
;
3866 r_u
->num_entries2
= num_rids
;
3870 r_u
->num_entries
= 0;
3872 r_u
->num_entries2
= 0;
3875 r_u
->status
= status
;
3878 /*******************************************************************
3879 reads or writes a structure.
3880 ********************************************************************/
3882 BOOL
samr_io_rids(const char *desc
, uint32
*num_rids
, uint32
**rid
,
3883 prs_struct
*ps
, int depth
)
3890 prs_debug(ps
, depth
, desc
, "samr_io_rids");
3896 if(!prs_uint32("num_rids", ps
, depth
, num_rids
))
3899 if ((*num_rids
) != 0) {
3900 if (UNMARSHALLING(ps
)) {
3902 (*rid
) = (uint32
*)prs_alloc_mem(ps
,sizeof(uint32
)*(*num_rids
));
3907 for (i
= 0; i
< (*num_rids
); i
++) {
3908 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d]", i
);
3909 if(!prs_uint32(tmp
, ps
, depth
, &((*rid
)[i
])))
3917 /*******************************************************************
3918 reads or writes a structure.
3919 ********************************************************************/
3921 BOOL
samr_io_r_query_useraliases(const char *desc
, SAMR_R_QUERY_USERALIASES
* r_u
,
3922 prs_struct
*ps
, int depth
)
3927 prs_debug(ps
, depth
, desc
, "samr_io_r_query_useraliases");
3933 if(!prs_uint32("num_entries", ps
, depth
, &r_u
->num_entries
))
3935 if(!prs_uint32("ptr ", ps
, depth
, &r_u
->ptr
))
3938 if (r_u
->ptr
!= 0) {
3939 if(!samr_io_rids("rids", &r_u
->num_entries2
, &r_u
->rid
, ps
, depth
))
3945 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3951 /*******************************************************************
3952 inits a SAMR_Q_OPEN_ALIAS structure.
3953 ********************************************************************/
3955 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS
* q_u
, POLICY_HND
*pol
,
3956 uint32 access_mask
, uint32 rid
)
3958 DEBUG(5, ("init_samr_q_open_alias\n"));
3960 q_u
->dom_pol
= *pol
;
3961 q_u
->access_mask
= access_mask
;
3962 q_u
->rid_alias
= rid
;
3965 /*******************************************************************
3966 reads or writes a structure.
3967 ********************************************************************/
3969 BOOL
samr_io_q_open_alias(const char *desc
, SAMR_Q_OPEN_ALIAS
* q_u
,
3970 prs_struct
*ps
, int depth
)
3975 prs_debug(ps
, depth
, desc
, "samr_io_q_open_alias");
3981 if(!smb_io_pol_hnd("domain_pol", &q_u
->dom_pol
, ps
, depth
))
3984 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
3986 if(!prs_uint32("rid_alias", ps
, depth
, &q_u
->rid_alias
))
3992 /*******************************************************************
3993 reads or writes a structure.
3994 ********************************************************************/
3996 BOOL
samr_io_r_open_alias(const char *desc
, SAMR_R_OPEN_ALIAS
* r_u
,
3997 prs_struct
*ps
, int depth
)
4002 prs_debug(ps
, depth
, desc
, "samr_io_r_open_alias");
4008 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4011 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4017 /*******************************************************************
4018 inits a SAMR_Q_LOOKUP_RIDS structure.
4019 ********************************************************************/
4021 void init_samr_q_lookup_rids(TALLOC_CTX
*ctx
, SAMR_Q_LOOKUP_RIDS
* q_u
,
4022 POLICY_HND
*pol
, uint32 flags
,
4023 uint32 num_rids
, uint32
*rid
)
4025 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4029 q_u
->num_rids1
= num_rids
;
4032 q_u
->num_rids2
= num_rids
;
4033 q_u
->rid
= (uint32
*)talloc_zero(ctx
, num_rids
* sizeof(q_u
->rid
[0]));
4034 if (q_u
->rid
== NULL
) {
4038 memcpy(q_u
->rid
, rid
, num_rids
* sizeof(q_u
->rid
[0]));
4042 /*******************************************************************
4043 reads or writes a structure.
4044 ********************************************************************/
4046 BOOL
samr_io_q_lookup_rids(const char *desc
, SAMR_Q_LOOKUP_RIDS
* q_u
,
4047 prs_struct
*ps
, int depth
)
4055 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_rids");
4058 if (UNMARSHALLING(ps
))
4064 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
4067 if(!prs_uint32("num_rids1", ps
, depth
, &q_u
->num_rids1
))
4069 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
4071 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
4073 if(!prs_uint32("num_rids2", ps
, depth
, &q_u
->num_rids2
))
4076 if (UNMARSHALLING(ps
) && (q_u
->num_rids2
!= 0)) {
4077 q_u
->rid
= (uint32
*)prs_alloc_mem(ps
, sizeof(q_u
->rid
[0])*q_u
->num_rids2
);
4078 if (q_u
->rid
== NULL
)
4082 for (i
= 0; i
< q_u
->num_rids2
; i
++) {
4083 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
4084 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->rid
[i
]))
4091 /*******************************************************************
4092 inits a SAMR_R_LOOKUP_RIDS structure.
4093 ********************************************************************/
4095 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS
* r_u
,
4096 uint32 num_names
, UNIHDR
* hdr_name
,
4097 UNISTR2
*uni_name
, uint32
*type
)
4099 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4101 r_u
->hdr_name
= NULL
;
4102 r_u
->uni_name
= NULL
;
4105 if (num_names
!= 0) {
4106 r_u
->num_names1
= num_names
;
4108 r_u
->num_names2
= num_names
;
4110 r_u
->num_types1
= num_names
;
4112 r_u
->num_types2
= num_names
;
4114 r_u
->hdr_name
= hdr_name
;
4115 r_u
->uni_name
= uni_name
;
4118 r_u
->num_names1
= num_names
;
4120 r_u
->num_names2
= num_names
;
4122 r_u
->num_types1
= num_names
;
4124 r_u
->num_types2
= num_names
;
4128 /*******************************************************************
4129 reads or writes a structure.
4130 ********************************************************************/
4132 BOOL
samr_io_r_lookup_rids(const char *desc
, SAMR_R_LOOKUP_RIDS
* r_u
,
4133 prs_struct
*ps
, int depth
)
4140 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_rids");
4146 if(!prs_uint32("num_names1", ps
, depth
, &r_u
->num_names1
))
4148 if(!prs_uint32("ptr_names ", ps
, depth
, &r_u
->ptr_names
))
4151 if (r_u
->ptr_names
!= 0) {
4153 if(!prs_uint32("num_names2", ps
, depth
, &r_u
->num_names2
))
4157 if (UNMARSHALLING(ps
) && (r_u
->num_names2
!= 0)) {
4158 r_u
->hdr_name
= (UNIHDR
*) prs_alloc_mem(ps
, r_u
->num_names2
* sizeof(r_u
->hdr_name
[0]));
4159 if (r_u
->hdr_name
== NULL
)
4162 r_u
->uni_name
= (UNISTR2
*)prs_alloc_mem(ps
, r_u
->num_names2
* sizeof(r_u
->uni_name
[0]));
4163 if (r_u
->uni_name
== NULL
)
4167 for (i
= 0; i
< r_u
->num_names2
; i
++) {
4168 slprintf(tmp
, sizeof(tmp
) - 1, "hdr[%02d] ", i
);
4169 if(!smb_io_unihdr("", &r_u
->hdr_name
[i
], ps
, depth
))
4172 for (i
= 0; i
< r_u
->num_names2
; i
++) {
4173 slprintf(tmp
, sizeof(tmp
) - 1, "str[%02d] ", i
);
4174 if(!smb_io_unistr2("", &r_u
->uni_name
[i
], r_u
->hdr_name
[i
].buffer
, ps
, depth
))
4182 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
4184 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
4187 if (r_u
->ptr_types
!= 0) {
4189 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
4192 if (UNMARSHALLING(ps
) && (r_u
->num_types2
!= 0)) {
4193 r_u
->type
= (uint32
*)prs_alloc_mem(ps
, r_u
->num_types2
* sizeof(r_u
->type
[0]));
4194 if (r_u
->type
== NULL
)
4198 for (i
= 0; i
< r_u
->num_types2
; i
++) {
4199 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
4200 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->type
[i
]))
4205 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4211 /*******************************************************************
4212 inits a SAMR_Q_OPEN_ALIAS structure.
4213 ********************************************************************/
4215 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS
* q_u
, POLICY_HND
*hnd
)
4217 DEBUG(5, ("init_samr_q_delete_alias\n"));
4219 q_u
->alias_pol
= *hnd
;
4222 /*******************************************************************
4223 reads or writes a structure.
4224 ********************************************************************/
4226 BOOL
samr_io_q_delete_alias(const char *desc
, SAMR_Q_DELETE_DOM_ALIAS
* q_u
,
4227 prs_struct
*ps
, int depth
)
4232 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_alias");
4238 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4244 /*******************************************************************
4245 reads or writes a structure.
4246 ********************************************************************/
4248 BOOL
samr_io_r_delete_alias(const char *desc
, SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4249 prs_struct
*ps
, int depth
)
4254 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_alias");
4260 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4262 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4268 /*******************************************************************
4269 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4270 ********************************************************************/
4272 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS
* q_u
,
4273 POLICY_HND
*hnd
, char *acct_desc
)
4275 int acct_len
= acct_desc
!= NULL
? strlen(acct_desc
) : 0;
4277 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4279 q_u
->dom_pol
= *hnd
;
4281 init_uni_hdr(&q_u
->hdr_acct_desc
, acct_len
);
4282 init_unistr2(&q_u
->uni_acct_desc
, acct_desc
, acct_len
);
4284 q_u
->access_mask
= 0x001f000f;
4287 /*******************************************************************
4288 reads or writes a structure.
4289 ********************************************************************/
4291 BOOL
samr_io_q_create_dom_alias(const char *desc
, SAMR_Q_CREATE_DOM_ALIAS
* q_u
,
4292 prs_struct
*ps
, int depth
)
4297 prs_debug(ps
, depth
, desc
, "samr_io_q_create_dom_alias");
4303 if(!smb_io_pol_hnd("dom_pol", &q_u
->dom_pol
, ps
, depth
))
4306 if(!smb_io_unihdr("hdr_acct_desc", &q_u
->hdr_acct_desc
, ps
, depth
))
4308 if(!smb_io_unistr2("uni_acct_desc", &q_u
->uni_acct_desc
,
4309 q_u
->hdr_acct_desc
.buffer
, ps
, depth
))
4314 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
4320 /*******************************************************************
4321 reads or writes a structure.
4322 ********************************************************************/
4324 BOOL
samr_io_r_create_dom_alias(const char *desc
, SAMR_R_CREATE_DOM_ALIAS
* r_u
,
4325 prs_struct
*ps
, int depth
)
4330 prs_debug(ps
, depth
, desc
, "samr_io_r_create_dom_alias");
4336 if(!smb_io_pol_hnd("alias_pol", &r_u
->alias_pol
, ps
, depth
))
4339 if(!prs_uint32("rid", ps
, depth
, &r_u
->rid
))
4342 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4348 /*******************************************************************
4349 inits a SAMR_Q_ADD_ALIASMEM structure.
4350 ********************************************************************/
4352 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM
* q_u
, POLICY_HND
*hnd
,
4355 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4357 q_u
->alias_pol
= *hnd
;
4358 init_dom_sid2(&q_u
->sid
, sid
);
4361 /*******************************************************************
4362 reads or writes a structure.
4363 ********************************************************************/
4365 BOOL
samr_io_q_add_aliasmem(const char *desc
, SAMR_Q_ADD_ALIASMEM
* q_u
,
4366 prs_struct
*ps
, int depth
)
4371 prs_debug(ps
, depth
, desc
, "samr_io_q_add_aliasmem");
4377 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4379 if(!smb_io_dom_sid2("sid ", &q_u
->sid
, ps
, depth
))
4385 /*******************************************************************
4386 reads or writes a structure.
4387 ********************************************************************/
4389 BOOL
samr_io_r_add_aliasmem(const char *desc
, SAMR_R_ADD_ALIASMEM
* r_u
,
4390 prs_struct
*ps
, int depth
)
4395 prs_debug(ps
, depth
, desc
, "samr_io_r_add_aliasmem");
4401 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4407 /*******************************************************************
4408 inits a SAMR_Q_DEL_ALIASMEM structure.
4409 ********************************************************************/
4411 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM
* q_u
, POLICY_HND
*hnd
,
4414 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4416 q_u
->alias_pol
= *hnd
;
4417 init_dom_sid2(&q_u
->sid
, sid
);
4420 /*******************************************************************
4421 reads or writes a structure.
4422 ********************************************************************/
4424 BOOL
samr_io_q_del_aliasmem(const char *desc
, SAMR_Q_DEL_ALIASMEM
* q_u
,
4425 prs_struct
*ps
, int depth
)
4430 prs_debug(ps
, depth
, desc
, "samr_io_q_del_aliasmem");
4436 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4438 if(!smb_io_dom_sid2("sid ", &q_u
->sid
, ps
, depth
))
4444 /*******************************************************************
4445 reads or writes a structure.
4446 ********************************************************************/
4448 BOOL
samr_io_r_del_aliasmem(const char *desc
, SAMR_R_DEL_ALIASMEM
* r_u
,
4449 prs_struct
*ps
, int depth
)
4454 prs_debug(ps
, depth
, desc
, "samr_io_r_del_aliasmem");
4460 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4466 /*******************************************************************
4467 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4468 ********************************************************************/
4470 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS
* q_c
,
4473 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4475 q_c
->alias_pol
= *hnd
;
4478 /*******************************************************************
4479 reads or writes a structure.
4480 ********************************************************************/
4482 BOOL
samr_io_q_delete_dom_alias(const char *desc
, SAMR_Q_DELETE_DOM_ALIAS
* q_u
,
4483 prs_struct
*ps
, int depth
)
4488 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_alias");
4494 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4500 /*******************************************************************
4501 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4502 ********************************************************************/
4504 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4507 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4509 r_u
->status
= status
;
4512 /*******************************************************************
4513 reads or writes a structure.
4514 ********************************************************************/
4516 BOOL
samr_io_r_delete_dom_alias(const char *desc
, SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4517 prs_struct
*ps
, int depth
)
4522 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_alias");
4528 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4534 /*******************************************************************
4535 inits a SAMR_Q_QUERY_ALIASMEM structure.
4536 ********************************************************************/
4538 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM
* q_c
,
4541 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4543 q_c
->alias_pol
= *hnd
;
4546 /*******************************************************************
4547 reads or writes a structure.
4548 ********************************************************************/
4550 BOOL
samr_io_q_query_aliasmem(const char *desc
, SAMR_Q_QUERY_ALIASMEM
* q_u
,
4551 prs_struct
*ps
, int depth
)
4556 prs_debug(ps
, depth
, desc
, "samr_io_q_query_aliasmem");
4562 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4568 /*******************************************************************
4569 inits a SAMR_R_QUERY_ALIASMEM structure.
4570 ********************************************************************/
4572 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM
* r_u
,
4573 uint32 num_sids
, DOM_SID2
* sid
,
4576 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4578 if (NT_STATUS_IS_OK(status
)) {
4579 r_u
->num_sids
= num_sids
;
4580 r_u
->ptr
= (num_sids
!= 0) ? 1 : 0;
4581 r_u
->num_sids1
= num_sids
;
4589 r_u
->status
= status
;
4592 /*******************************************************************
4593 reads or writes a structure.
4594 ********************************************************************/
4596 BOOL
samr_io_r_query_aliasmem(const char *desc
, SAMR_R_QUERY_ALIASMEM
* r_u
,
4597 prs_struct
*ps
, int depth
)
4604 prs_debug(ps
, depth
, desc
, "samr_io_r_query_aliasmem");
4610 if(!prs_uint32("num_sids ", ps
, depth
, &r_u
->num_sids
))
4612 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
4615 if (r_u
->ptr
!= 0 && r_u
->num_sids
!= 0) {
4616 uint32
*ptr_sid
= NULL
;
4618 if(!prs_uint32("num_sids1", ps
, depth
, &r_u
->num_sids1
))
4621 ptr_sid
= talloc(ps
->mem_ctx
, sizeof(uint32
) * r_u
->num_sids1
);
4626 for (i
= 0; i
< r_u
->num_sids1
; i
++) {
4628 if(!prs_uint32("ptr_sid", ps
, depth
, &ptr_sid
[i
]))
4632 if (UNMARSHALLING(ps
)) {
4633 r_u
->sid
= talloc(ps
->mem_ctx
, r_u
->num_sids1
* sizeof(DOM_SID2
));
4636 for (i
= 0; i
< r_u
->num_sids1
; i
++) {
4637 if (ptr_sid
[i
] != 0) {
4638 if(!smb_io_dom_sid2("sid", &r_u
->sid
[i
], ps
, depth
))
4646 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4652 /*******************************************************************
4653 inits a SAMR_Q_LOOKUP_NAMES structure.
4654 ********************************************************************/
4656 NTSTATUS
init_samr_q_lookup_names(TALLOC_CTX
*ctx
, SAMR_Q_LOOKUP_NAMES
* q_u
,
4657 POLICY_HND
*pol
, uint32 flags
,
4658 uint32 num_names
, const char **name
)
4662 DEBUG(5, ("init_samr_q_lookup_names\n"));
4666 q_u
->num_names1
= num_names
;
4669 q_u
->num_names2
= num_names
;
4671 if (!(q_u
->hdr_name
= (UNIHDR
*)talloc_zero(ctx
, num_names
* sizeof(UNIHDR
))))
4672 return NT_STATUS_NO_MEMORY
;
4674 if (!(q_u
->uni_name
= (UNISTR2
*)talloc_zero(ctx
, num_names
* sizeof(UNISTR2
))))
4675 return NT_STATUS_NO_MEMORY
;
4677 for (i
= 0; i
< num_names
; i
++) {
4678 int len_name
= name
[i
] != NULL
? strlen(name
[i
]) : 0;
4679 init_uni_hdr(&q_u
->hdr_name
[i
], len_name
); /* unicode header for user_name */
4680 init_unistr2(&q_u
->uni_name
[i
], name
[i
], len_name
); /* unicode string for machine account */
4683 return NT_STATUS_OK
;
4686 /*******************************************************************
4687 reads or writes a structure.
4688 ********************************************************************/
4690 BOOL
samr_io_q_lookup_names(const char *desc
, SAMR_Q_LOOKUP_NAMES
* q_u
,
4691 prs_struct
*ps
, int depth
)
4698 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_names");
4701 if (UNMARSHALLING(ps
))
4707 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
4710 if(!prs_uint32("num_names1", ps
, depth
, &q_u
->num_names1
))
4712 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
4714 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
4716 if(!prs_uint32("num_names2", ps
, depth
, &q_u
->num_names2
))
4719 if (UNMARSHALLING(ps
) && (q_u
->num_names2
!= 0)) {
4720 q_u
->hdr_name
= (UNIHDR
*)prs_alloc_mem(ps
, sizeof(UNIHDR
) *
4722 q_u
->uni_name
= (UNISTR2
*)prs_alloc_mem(ps
, sizeof(UNISTR2
) *
4724 if (!q_u
->hdr_name
|| !q_u
->uni_name
)
4728 for (i
= 0; i
< q_u
->num_names2
; i
++) {
4729 if(!smb_io_unihdr("", &q_u
->hdr_name
[i
], ps
, depth
))
4733 for (i
= 0; i
< q_u
->num_names2
; i
++) {
4734 if(!smb_io_unistr2("", &q_u
->uni_name
[i
], q_u
->hdr_name
[i
].buffer
, ps
, depth
))
4741 /*******************************************************************
4742 inits a SAMR_R_LOOKUP_NAMES structure.
4743 ********************************************************************/
4745 NTSTATUS
init_samr_r_lookup_names(TALLOC_CTX
*ctx
, SAMR_R_LOOKUP_NAMES
* r_u
,
4747 uint32
*rid
, uint32
*type
,
4750 DEBUG(5, ("init_samr_r_lookup_names\n"));
4752 if (NT_STATUS_IS_OK(status
) && (num_rids
!= 0)) {
4755 r_u
->num_types1
= num_rids
;
4757 r_u
->num_types2
= num_rids
;
4759 r_u
->num_rids1
= num_rids
;
4761 r_u
->num_rids2
= num_rids
;
4763 if (!(r_u
->rids
= (uint32
*)talloc_zero(ctx
, sizeof(uint32
)*num_rids
)))
4764 return NT_STATUS_NO_MEMORY
;
4765 if (!(r_u
->types
= (uint32
*)talloc_zero(ctx
, sizeof(uint32
)*num_rids
)))
4766 return NT_STATUS_NO_MEMORY
;
4768 if (!r_u
->rids
|| !r_u
->types
)
4771 for (i
= 0; i
< num_rids
; i
++) {
4772 r_u
->rids
[i
] = rid
[i
];
4773 r_u
->types
[i
] = type
[i
];
4778 r_u
->num_types1
= 0;
4780 r_u
->num_types2
= 0;
4790 r_u
->status
= status
;
4792 return NT_STATUS_OK
;
4795 /*******************************************************************
4796 reads or writes a structure.
4797 ********************************************************************/
4799 BOOL
samr_io_r_lookup_names(const char *desc
, SAMR_R_LOOKUP_NAMES
* r_u
,
4800 prs_struct
*ps
, int depth
)
4808 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_names");
4811 if (UNMARSHALLING(ps
))
4817 if(!prs_uint32("num_rids1", ps
, depth
, &r_u
->num_rids1
))
4819 if(!prs_uint32("ptr_rids ", ps
, depth
, &r_u
->ptr_rids
))
4822 if (r_u
->ptr_rids
!= 0) {
4823 if(!prs_uint32("num_rids2", ps
, depth
, &r_u
->num_rids2
))
4826 if (r_u
->num_rids2
!= r_u
->num_rids1
) {
4831 if (UNMARSHALLING(ps
))
4832 r_u
->rids
= (uint32
*)prs_alloc_mem(ps
, sizeof(uint32
)*r_u
->num_rids2
);
4835 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4839 for (i
= 0; i
< r_u
->num_rids2
; i
++) {
4840 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
4841 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->rids
[i
]))
4846 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
4848 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
4851 if (r_u
->ptr_types
!= 0) {
4852 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
4855 if (r_u
->num_types2
!= r_u
->num_types1
) {
4860 if (UNMARSHALLING(ps
))
4861 r_u
->types
= (uint32
*)prs_alloc_mem(ps
, sizeof(uint32
)*r_u
->num_types2
);
4864 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4868 for (i
= 0; i
< r_u
->num_types2
; i
++) {
4869 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
4870 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->types
[i
]))
4875 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4881 /*******************************************************************
4882 inits a SAMR_Q_DELETE_DOM_USER structure.
4883 ********************************************************************/
4885 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER
* q_c
,
4888 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4890 q_c
->user_pol
= *hnd
;
4893 /*******************************************************************
4894 reads or writes a structure.
4895 ********************************************************************/
4897 BOOL
samr_io_q_delete_dom_user(const char *desc
, SAMR_Q_DELETE_DOM_USER
* q_u
,
4898 prs_struct
*ps
, int depth
)
4903 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_user");
4909 if(!smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
))
4915 /*******************************************************************
4916 reads or writes a structure.
4917 ********************************************************************/
4919 BOOL
samr_io_r_delete_dom_user(const char *desc
, SAMR_R_DELETE_DOM_USER
* r_u
,
4920 prs_struct
*ps
, int depth
)
4925 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_user");
4931 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4933 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4939 /*******************************************************************
4940 reads or writes a structure.
4941 ********************************************************************/
4943 void init_samr_q_open_user(SAMR_Q_OPEN_USER
* q_u
,
4945 uint32 access_mask
, uint32 rid
)
4947 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4949 q_u
->domain_pol
= *pol
;
4950 q_u
->access_mask
= access_mask
;
4951 q_u
->user_rid
= rid
;
4954 /*******************************************************************
4955 reads or writes a structure.
4956 ********************************************************************/
4958 BOOL
samr_io_q_open_user(const char *desc
, SAMR_Q_OPEN_USER
* q_u
,
4959 prs_struct
*ps
, int depth
)
4964 prs_debug(ps
, depth
, desc
, "samr_io_q_open_user");
4970 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
4973 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
4975 if(!prs_uint32("user_rid ", ps
, depth
, &q_u
->user_rid
))
4981 /*******************************************************************
4982 reads or writes a structure.
4983 ********************************************************************/
4985 BOOL
samr_io_r_open_user(const char *desc
, SAMR_R_OPEN_USER
* r_u
,
4986 prs_struct
*ps
, int depth
)
4991 prs_debug(ps
, depth
, desc
, "samr_io_r_open_user");
4997 if(!smb_io_pol_hnd("user_pol", &r_u
->user_pol
, ps
, depth
))
5000 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
5007 /*******************************************************************
5008 reads or writes a structure.
5009 ********************************************************************/
5011 void init_samr_q_create_user(SAMR_Q_CREATE_USER
* q_u
,
5014 uint32 acb_info
, uint32 access_mask
)
5017 len_name
= strlen(name
);
5019 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5021 q_u
->domain_pol
= *pol
;
5023 init_uni_hdr(&q_u
->hdr_name
, len_name
);
5024 init_unistr2(&q_u
->uni_name
, name
, len_name
);
5026 q_u
->acb_info
= acb_info
;
5027 q_u
->access_mask
= access_mask
;
5030 /*******************************************************************
5031 reads or writes a structure.
5032 ********************************************************************/
5034 BOOL
samr_io_q_create_user(const char *desc
, SAMR_Q_CREATE_USER
* q_u
,
5035 prs_struct
*ps
, int depth
)
5040 prs_debug(ps
, depth
, desc
, "samr_io_q_create_user");
5046 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
5049 if(!smb_io_unihdr("hdr_name", &q_u
->hdr_name
, ps
, depth
))
5051 if(!smb_io_unistr2("uni_name", &q_u
->uni_name
, q_u
->hdr_name
.buffer
, ps
, depth
))
5056 if(!prs_uint32("acb_info ", ps
, depth
, &q_u
->acb_info
))
5058 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
5064 /*******************************************************************
5065 reads or writes a structure.
5066 ********************************************************************/
5068 BOOL
samr_io_r_create_user(const char *desc
, SAMR_R_CREATE_USER
* r_u
,
5069 prs_struct
*ps
, int depth
)
5074 prs_debug(ps
, depth
, desc
, "samr_io_r_create_user");
5080 if(!smb_io_pol_hnd("user_pol", &r_u
->user_pol
, ps
, depth
))
5083 if(!prs_uint32("access_granted", ps
, depth
, &r_u
->access_granted
))
5085 if(!prs_uint32("user_rid ", ps
, depth
, &r_u
->user_rid
))
5087 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
5093 /*******************************************************************
5094 inits a SAMR_Q_QUERY_USERINFO structure.
5095 ********************************************************************/
5097 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO
* q_u
,
5098 POLICY_HND
*hnd
, uint16 switch_value
)
5100 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5103 q_u
->switch_value
= switch_value
;
5106 /*******************************************************************
5107 reads or writes a structure.
5108 ********************************************************************/
5110 BOOL
samr_io_q_query_userinfo(const char *desc
, SAMR_Q_QUERY_USERINFO
* q_u
,
5111 prs_struct
*ps
, int depth
)
5116 prs_debug(ps
, depth
, desc
, "samr_io_q_query_userinfo");
5122 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
5125 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
)) /* 0x0015 or 0x0011 */
5131 /*******************************************************************
5132 reads or writes a LOGON_HRS structure.
5133 ********************************************************************/
5135 static BOOL
sam_io_logon_hrs(const char *desc
, LOGON_HRS
* hrs
,
5136 prs_struct
*ps
, int depth
)
5141 prs_debug(ps
, depth
, desc
, "sam_io_logon_hrs");
5147 if(!prs_uint32("len ", ps
, depth
, &hrs
->len
))
5150 if (hrs
->len
> sizeof(hrs
->hours
)) {
5151 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs
->len
));
5152 hrs
->len
= sizeof(hrs
->hours
);
5155 if(!prs_uint8s(False
, "hours", ps
, depth
, hrs
->hours
, hrs
->len
))
5161 /*******************************************************************
5162 inits a SAM_USER_INFO_12 structure.
5163 ********************************************************************/
5165 void init_sam_user_info12(SAM_USER_INFO_12
* usr
,
5166 const uint8 lm_pwd
[16], const uint8 nt_pwd
[16])
5168 DEBUG(5, ("init_sam_user_info12\n"));
5170 usr
->lm_pwd_active
=
5171 memcpy(usr
->lm_pwd
, lm_pwd
, sizeof(usr
->lm_pwd
)) ? 1 : 0;
5172 usr
->nt_pwd_active
=
5173 memcpy(usr
->nt_pwd
, nt_pwd
, sizeof(usr
->nt_pwd
)) ? 1 : 0;
5176 /*******************************************************************
5177 reads or writes a structure.
5178 ********************************************************************/
5180 static BOOL
sam_io_user_info12(const char *desc
, SAM_USER_INFO_12
* u
,
5181 prs_struct
*ps
, int depth
)
5186 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info12");
5192 if(!prs_uint8s(False
, "lm_pwd", ps
, depth
, u
->lm_pwd
, sizeof(u
->lm_pwd
)))
5194 if(!prs_uint8s(False
, "nt_pwd", ps
, depth
, u
->nt_pwd
, sizeof(u
->nt_pwd
)))
5197 if(!prs_uint8("lm_pwd_active", ps
, depth
, &u
->lm_pwd_active
))
5199 if(!prs_uint8("nt_pwd_active", ps
, depth
, &u
->nt_pwd_active
))
5205 /*******************************************************************
5206 inits a SAM_USER_INFO_10 structure.
5207 ********************************************************************/
5209 void init_sam_user_info10(SAM_USER_INFO_10
* usr
, uint32 acb_info
)
5211 DEBUG(5, ("init_sam_user_info10\n"));
5213 usr
->acb_info
= acb_info
;
5216 /*******************************************************************
5217 reads or writes a structure.
5218 ********************************************************************/
5220 static BOOL
sam_io_user_info10(const char *desc
, SAM_USER_INFO_10
* usr
,
5221 prs_struct
*ps
, int depth
)
5226 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info10");
5232 if(!prs_uint32("acb_info", ps
, depth
, &usr
->acb_info
))
5238 /*******************************************************************
5239 inits a SAM_USER_INFO_11 structure.
5240 ********************************************************************/
5242 void init_sam_user_info11(SAM_USER_INFO_11
* usr
,
5245 uint32 rid_user
, uint32 rid_group
, uint16 acct_ctrl
)
5249 DEBUG(5, ("init_sam_user_info11\n"));
5251 len_mach_acct
= strlen(mach_acct
);
5253 memcpy(&(usr
->expiry
), expiry
, sizeof(usr
->expiry
)); /* expiry time or something? */
5254 ZERO_STRUCT(usr
->padding_1
); /* 0 - padding 24 bytes */
5256 init_uni_hdr(&usr
->hdr_mach_acct
, len_mach_acct
); /* unicode header for machine account */
5257 usr
->padding_2
= 0; /* 0 - padding 4 bytes */
5259 usr
->ptr_1
= 1; /* pointer */
5260 ZERO_STRUCT(usr
->padding_3
); /* 0 - padding 32 bytes */
5261 usr
->padding_4
= 0; /* 0 - padding 4 bytes */
5263 usr
->ptr_2
= 1; /* pointer */
5264 usr
->padding_5
= 0; /* 0 - padding 4 bytes */
5266 usr
->ptr_3
= 1; /* pointer */
5267 ZERO_STRUCT(usr
->padding_6
); /* 0 - padding 32 bytes */
5269 usr
->rid_user
= rid_user
;
5270 usr
->rid_group
= rid_group
;
5272 usr
->acct_ctrl
= acct_ctrl
;
5273 usr
->unknown_3
= 0x0000;
5275 usr
->unknown_4
= 0x003f; /* 0x003f - 16 bit unknown */
5276 usr
->unknown_5
= 0x003c; /* 0x003c - 16 bit unknown */
5278 ZERO_STRUCT(usr
->padding_7
); /* 0 - padding 16 bytes */
5279 usr
->padding_8
= 0; /* 0 - padding 4 bytes */
5281 init_unistr2(&usr
->uni_mach_acct
, mach_acct
, len_mach_acct
); /* unicode string for machine account */
5284 /*******************************************************************
5285 reads or writes a structure.
5286 ********************************************************************/
5288 static BOOL
sam_io_user_info11(const char *desc
, SAM_USER_INFO_11
* usr
,
5289 prs_struct
*ps
, int depth
)
5294 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_11");
5300 if(!prs_uint8s(False
, "padding_0", ps
, depth
, usr
->padding_0
, sizeof(usr
->padding_0
)))
5303 if(!smb_io_time("time", &usr
->expiry
, ps
, depth
))
5306 if(!prs_uint8s(False
, "padding_1", ps
, depth
, usr
->padding_1
, sizeof(usr
->padding_1
)))
5309 if(!smb_io_unihdr("unihdr", &usr
->hdr_mach_acct
, ps
, depth
))
5312 if(!prs_uint32("padding_2", ps
, depth
, &usr
->padding_2
))
5315 if(!prs_uint32("ptr_1 ", ps
, depth
, &usr
->ptr_1
))
5317 if(!prs_uint8s(False
, "padding_3", ps
, depth
, usr
->padding_3
, sizeof(usr
->padding_3
)))
5320 if(!prs_uint32("padding_4", ps
, depth
, &usr
->padding_4
))
5323 if(!prs_uint32("ptr_2 ", ps
, depth
, &usr
->ptr_2
))
5325 if(!prs_uint32("padding_5", ps
, depth
, &usr
->padding_5
))
5328 if(!prs_uint32("ptr_3 ", ps
, depth
, &usr
->ptr_3
))
5330 if(!prs_uint8s(False
, "padding_6", ps
, depth
, usr
->padding_6
,sizeof(usr
->padding_6
)))
5333 if(!prs_uint32("rid_user ", ps
, depth
, &usr
->rid_user
))
5335 if(!prs_uint32("rid_group", ps
, depth
, &usr
->rid_group
))
5337 if(!prs_uint16("acct_ctrl", ps
, depth
, &usr
->acct_ctrl
))
5339 if(!prs_uint16("unknown_3", ps
, depth
, &usr
->unknown_3
))
5341 if(!prs_uint16("unknown_4", ps
, depth
, &usr
->unknown_4
))
5343 if(!prs_uint16("unknown_5", ps
, depth
, &usr
->unknown_5
))
5346 if(!prs_uint8s(False
, "padding_7", ps
, depth
, usr
->padding_7
, sizeof(usr
->padding_7
)))
5349 if(!prs_uint32("padding_8", ps
, depth
, &(usr
->padding_8
)))
5352 if(!smb_io_unistr2("unistr2", &usr
->uni_mach_acct
, True
, ps
, depth
))
5358 if(!prs_uint8s(False
, "padding_9", ps
, depth
, usr
->padding_9
, sizeof(usr
->padding_9
)))
5364 /*************************************************************************
5367 unknown_3 = 0x09f8 27fa
5368 unknown_5 = 0x0001 0000
5369 unknown_6 = 0x0000 04ec
5371 *************************************************************************/
5373 void init_sam_user_info24(SAM_USER_INFO_24
* usr
, char newpass
[516], uint16 pw_len
)
5375 DEBUG(10, ("init_sam_user_info24:\n"));
5376 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5377 usr
->pw_len
= pw_len
;
5380 /*******************************************************************
5381 reads or writes a structure.
5382 ********************************************************************/
5384 static BOOL
sam_io_user_info24(const char *desc
, SAM_USER_INFO_24
* usr
,
5385 prs_struct
*ps
, int depth
)
5390 prs_debug(ps
, depth
, desc
, "sam_io_user_info24");
5396 if(!prs_uint8s(False
, "password", ps
, depth
, usr
->pass
,
5400 if (MARSHALLING(ps
) && (usr
->pw_len
!= 0)) {
5401 if (!prs_uint16("pw_len", ps
, depth
, &usr
->pw_len
))
5410 /*************************************************************************
5411 init_sam_user_info23
5413 unknown_3 = 0x09f8 27fa
5414 unknown_5 = 0x0001 0000
5415 unknown_6 = 0x0000 04ec
5417 *************************************************************************/
5419 void init_sam_user_info23W(SAM_USER_INFO_23
* usr
, NTTIME
* logon_time
, /* all zeros */
5420 NTTIME
* logoff_time
, /* all zeros */
5421 NTTIME
* kickoff_time
, /* all zeros */
5422 NTTIME
* pass_last_set_time
, /* all zeros */
5423 NTTIME
* pass_can_change_time
, /* all zeros */
5424 NTTIME
* pass_must_change_time
, /* all zeros */
5435 uint32 user_rid
, /* 0x0000 0000 */
5442 char newpass
[516], uint32 unknown_6
)
5444 int len_user_name
= user_name
!= NULL
? user_name
->uni_str_len
: 0;
5445 int len_full_name
= full_name
!= NULL
? full_name
->uni_str_len
: 0;
5446 int len_home_dir
= home_dir
!= NULL
? home_dir
->uni_str_len
: 0;
5447 int len_dir_drive
= dir_drive
!= NULL
? dir_drive
->uni_str_len
: 0;
5448 int len_logon_script
= log_scr
!= NULL
? log_scr
->uni_str_len
: 0;
5449 int len_profile_path
= prof_path
!= NULL
? prof_path
->uni_str_len
: 0;
5450 int len_description
= desc
!= NULL
? desc
->uni_str_len
: 0;
5451 int len_workstations
= wkstas
!= NULL
? wkstas
->uni_str_len
: 0;
5452 int len_unknown_str
= unk_str
!= NULL
? unk_str
->uni_str_len
: 0;
5453 int len_munged_dial
= mung_dial
!= NULL
? mung_dial
->uni_str_len
: 0;
5455 usr
->logon_time
= *logon_time
; /* all zeros */
5456 usr
->logoff_time
= *logoff_time
; /* all zeros */
5457 usr
->kickoff_time
= *kickoff_time
; /* all zeros */
5458 usr
->pass_last_set_time
= *pass_last_set_time
; /* all zeros */
5459 usr
->pass_can_change_time
= *pass_can_change_time
; /* all zeros */
5460 usr
->pass_must_change_time
= *pass_must_change_time
; /* all zeros */
5462 init_uni_hdr(&usr
->hdr_user_name
, len_user_name
); /* NULL */
5463 init_uni_hdr(&usr
->hdr_full_name
, len_full_name
);
5464 init_uni_hdr(&usr
->hdr_home_dir
, len_home_dir
);
5465 init_uni_hdr(&usr
->hdr_dir_drive
, len_dir_drive
);
5466 init_uni_hdr(&usr
->hdr_logon_script
, len_logon_script
);
5467 init_uni_hdr(&usr
->hdr_profile_path
, len_profile_path
);
5468 init_uni_hdr(&usr
->hdr_acct_desc
, len_description
);
5469 init_uni_hdr(&usr
->hdr_workstations
, len_workstations
);
5470 init_uni_hdr(&usr
->hdr_unknown_str
, len_unknown_str
);
5471 init_uni_hdr(&usr
->hdr_munged_dial
, len_munged_dial
);
5473 ZERO_STRUCT(usr
->nt_pwd
);
5474 ZERO_STRUCT(usr
->lm_pwd
);
5476 usr
->user_rid
= user_rid
; /* 0x0000 0000 */
5477 usr
->group_rid
= group_rid
;
5478 usr
->acb_info
= acb_info
;
5479 usr
->unknown_3
= unknown_3
; /* 09f8 27fa */
5481 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5482 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5484 if (nt_time_is_zero(pass_must_change_time
)) {
5485 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5487 usr
->passmustchange
=0;
5491 ZERO_STRUCT(usr
->padding1
);
5492 ZERO_STRUCT(usr
->padding2
);
5494 usr
->unknown_5
= unknown_5
; /* 0x0001 0000 */
5496 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5498 copy_unistr2(&usr
->uni_user_name
, user_name
);
5499 copy_unistr2(&usr
->uni_full_name
, full_name
);
5500 copy_unistr2(&usr
->uni_home_dir
, home_dir
);
5501 copy_unistr2(&usr
->uni_dir_drive
, dir_drive
);
5502 copy_unistr2(&usr
->uni_logon_script
, log_scr
);
5503 copy_unistr2(&usr
->uni_profile_path
, prof_path
);
5504 copy_unistr2(&usr
->uni_acct_desc
, desc
);
5505 copy_unistr2(&usr
->uni_workstations
, wkstas
);
5506 copy_unistr2(&usr
->uni_unknown_str
, unk_str
);
5507 copy_unistr2(&usr
->uni_munged_dial
, mung_dial
);
5509 usr
->unknown_6
= unknown_6
; /* 0x0000 04ec */
5512 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5515 /*************************************************************************
5516 init_sam_user_info23
5518 unknown_3 = 0x09f8 27fa
5519 unknown_5 = 0x0001 0000
5520 unknown_6 = 0x0000 04ec
5522 *************************************************************************/
5524 void init_sam_user_info23A(SAM_USER_INFO_23
* usr
, NTTIME
* logon_time
, /* all zeros */
5525 NTTIME
* logoff_time
, /* all zeros */
5526 NTTIME
* kickoff_time
, /* all zeros */
5527 NTTIME
* pass_last_set_time
, /* all zeros */
5528 NTTIME
* pass_can_change_time
, /* all zeros */
5529 NTTIME
* pass_must_change_time
, /* all zeros */
5530 char *user_name
, /* NULL */
5532 char *home_dir
, char *dir_drive
, char *log_scr
,
5533 char *prof_path
, const char *desc
, char *wkstas
,
5534 char *unk_str
, char *mung_dial
, uint32 user_rid
, /* 0x0000 0000 */
5535 uint32 group_rid
, uint32 acb_info
,
5536 uint32 unknown_3
, uint16 logon_divs
,
5537 LOGON_HRS
* hrs
, uint32 unknown_5
,
5538 char newpass
[516], uint32 unknown_6
)
5540 int len_user_name
= user_name
!= NULL
? strlen(user_name
) : 0;
5541 int len_full_name
= full_name
!= NULL
? strlen(full_name
) : 0;
5542 int len_home_dir
= home_dir
!= NULL
? strlen(home_dir
) : 0;
5543 int len_dir_drive
= dir_drive
!= NULL
? strlen(dir_drive
) : 0;
5544 int len_logon_script
= log_scr
!= NULL
? strlen(log_scr
) : 0;
5545 int len_profile_path
= prof_path
!= NULL
? strlen(prof_path
) : 0;
5546 int len_description
= desc
!= NULL
? strlen(desc
) : 0;
5547 int len_workstations
= wkstas
!= NULL
? strlen(wkstas
) : 0;
5548 int len_unknown_str
= unk_str
!= NULL
? strlen(unk_str
) : 0;
5549 int len_munged_dial
= mung_dial
!= NULL
? strlen(mung_dial
) : 0;
5551 usr
->logon_time
= *logon_time
; /* all zeros */
5552 usr
->logoff_time
= *logoff_time
; /* all zeros */
5553 usr
->kickoff_time
= *kickoff_time
; /* all zeros */
5554 usr
->pass_last_set_time
= *pass_last_set_time
; /* all zeros */
5555 usr
->pass_can_change_time
= *pass_can_change_time
; /* all zeros */
5556 usr
->pass_must_change_time
= *pass_must_change_time
; /* all zeros */
5558 init_uni_hdr(&usr
->hdr_user_name
, len_user_name
); /* NULL */
5559 init_uni_hdr(&usr
->hdr_full_name
, len_full_name
);
5560 init_uni_hdr(&usr
->hdr_home_dir
, len_home_dir
);
5561 init_uni_hdr(&usr
->hdr_dir_drive
, len_dir_drive
);
5562 init_uni_hdr(&usr
->hdr_logon_script
, len_logon_script
);
5563 init_uni_hdr(&usr
->hdr_profile_path
, len_profile_path
);
5564 init_uni_hdr(&usr
->hdr_acct_desc
, len_description
);
5565 init_uni_hdr(&usr
->hdr_workstations
, len_workstations
);
5566 init_uni_hdr(&usr
->hdr_unknown_str
, len_unknown_str
);
5567 init_uni_hdr(&usr
->hdr_munged_dial
, len_munged_dial
);
5569 ZERO_STRUCT(usr
->nt_pwd
);
5570 ZERO_STRUCT(usr
->lm_pwd
);
5572 usr
->user_rid
= user_rid
; /* 0x0000 0000 */
5573 usr
->group_rid
= group_rid
;
5574 usr
->acb_info
= acb_info
;
5575 usr
->unknown_3
= unknown_3
; /* 09f8 27fa */
5577 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5578 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5580 if (nt_time_is_zero(pass_must_change_time
)) {
5581 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5583 usr
->passmustchange
=0;
5586 ZERO_STRUCT(usr
->padding1
);
5587 ZERO_STRUCT(usr
->padding2
);
5589 usr
->unknown_5
= unknown_5
; /* 0x0001 0000 */
5591 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5593 init_unistr2(&usr
->uni_user_name
, user_name
, len_user_name
); /* NULL */
5594 init_unistr2(&usr
->uni_full_name
, full_name
, len_full_name
);
5595 init_unistr2(&usr
->uni_home_dir
, home_dir
, len_home_dir
);
5596 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, len_dir_drive
);
5597 init_unistr2(&usr
->uni_logon_script
, log_scr
, len_logon_script
);
5598 init_unistr2(&usr
->uni_profile_path
, prof_path
, len_profile_path
);
5599 init_unistr2(&usr
->uni_acct_desc
, desc
, len_description
);
5600 init_unistr2(&usr
->uni_workstations
, wkstas
, len_workstations
);
5601 init_unistr2(&usr
->uni_unknown_str
, unk_str
, len_unknown_str
);
5602 init_unistr2(&usr
->uni_munged_dial
, mung_dial
, len_munged_dial
);
5604 usr
->unknown_6
= unknown_6
; /* 0x0000 04ec */
5607 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5610 /*******************************************************************
5611 reads or writes a structure.
5612 ********************************************************************/
5614 static BOOL
sam_io_user_info23(const char *desc
, SAM_USER_INFO_23
* usr
,
5615 prs_struct
*ps
, int depth
)
5620 prs_debug(ps
, depth
, desc
, "sam_io_user_info23");
5626 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
5628 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
5630 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
5632 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
5634 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
5636 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
5639 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
5641 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
5643 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
5645 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
5647 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
5649 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
5651 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
5653 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
5655 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
5657 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
5660 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
5662 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
5665 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
5667 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
5669 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
5672 if(!prs_uint32("unknown_3 ", ps
, depth
, &usr
->unknown_3
))
5674 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
5678 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
5681 if(!prs_uint32("unknown_5 ", ps
, depth
, &usr
->unknown_5
))
5684 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
5686 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
5688 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
5692 if(!prs_uint8s(False
, "password ", ps
, depth
, usr
->pass
, sizeof(usr
->pass
)))
5695 /* here begins pointed-to data */
5697 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
5700 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
5703 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
5706 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
5709 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
5712 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
5715 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
5718 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
5721 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
5724 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
))
5727 /* ok, this is only guess-work (as usual) */
5728 if (usr
->ptr_logon_hrs
) {
5729 if(!prs_uint32("unknown_6 ", ps
, depth
, &usr
->unknown_6
))
5731 if(!prs_uint32("padding4 ", ps
, depth
, &usr
->padding4
))
5733 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
5735 } else if (UNMARSHALLING(ps
)) {
5743 /*******************************************************************
5744 reads or writes a structure.
5745 NB. This structure is *definately* incorrect. It's my best guess
5746 currently for W2K SP2. The password field is encrypted in a different
5747 way than normal... And there are definately other problems. JRA.
5748 ********************************************************************/
5750 static BOOL
sam_io_user_info25(const char *desc
, SAM_USER_INFO_25
* usr
, prs_struct
*ps
, int depth
)
5755 prs_debug(ps
, depth
, desc
, "sam_io_user_info25");
5761 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
5763 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
5765 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
5767 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
5769 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
5771 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
5774 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
5776 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
5778 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
5780 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
5782 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
5784 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
5786 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
5788 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
5790 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
5792 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
5795 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
5797 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
5800 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
5802 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
5804 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
5807 if(!prs_uint32s(False
, "unknown_6 ", ps
, depth
, usr
->unknown_6
, 6))
5810 if(!prs_uint8s(False
, "password ", ps
, depth
, usr
->pass
, sizeof(usr
->pass
)))
5813 /* here begins pointed-to data */
5815 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
5818 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
5821 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
5824 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
5827 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
5830 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
5833 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
5836 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
5839 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
5842 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
))
5845 #if 0 /* JRA - unknown... */
5846 /* ok, this is only guess-work (as usual) */
5847 if (usr
->ptr_logon_hrs
) {
5848 if(!prs_uint32("unknown_6 ", ps
, depth
, &usr
->unknown_6
))
5850 if(!prs_uint32("padding4 ", ps
, depth
, &usr
->padding4
))
5852 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
5854 } else if (UNMARSHALLING(ps
)) {
5864 /*************************************************************************
5865 init_sam_user_info21W
5867 unknown_3 = 0x00ff ffff
5868 unknown_5 = 0x0002 0000
5869 unknown_6 = 0x0000 04ec
5871 *************************************************************************/
5873 void init_sam_user_info21W(SAM_USER_INFO_21
* usr
,
5874 NTTIME
* logon_time
,
5875 NTTIME
* logoff_time
,
5876 NTTIME
* kickoff_time
,
5877 NTTIME
* pass_last_set_time
,
5878 NTTIME
* pass_can_change_time
,
5879 NTTIME
* pass_must_change_time
,
5898 uint32 unknown_5
, uint32 unknown_6
)
5900 int len_user_name
= user_name
!= NULL
? user_name
->uni_str_len
: 0;
5901 int len_full_name
= full_name
!= NULL
? full_name
->uni_str_len
: 0;
5902 int len_home_dir
= home_dir
!= NULL
? home_dir
->uni_str_len
: 0;
5903 int len_dir_drive
= dir_drive
!= NULL
? dir_drive
->uni_str_len
: 0;
5904 int len_logon_script
= log_scr
!= NULL
? log_scr
->uni_str_len
: 0;
5905 int len_profile_path
= prof_path
!= NULL
? prof_path
->uni_str_len
: 0;
5906 int len_description
= desc
!= NULL
? desc
->uni_str_len
: 0;
5907 int len_workstations
= wkstas
!= NULL
? wkstas
->uni_str_len
: 0;
5908 int len_unknown_str
= unk_str
!= NULL
? unk_str
->uni_str_len
: 0;
5909 int len_munged_dial
= mung_dial
!= NULL
? mung_dial
->uni_str_len
: 0;
5911 usr
->logon_time
= *logon_time
;
5912 usr
->logoff_time
= *logoff_time
;
5913 usr
->kickoff_time
= *kickoff_time
;
5914 usr
->pass_last_set_time
= *pass_last_set_time
;
5915 usr
->pass_can_change_time
= *pass_can_change_time
;
5916 usr
->pass_must_change_time
= *pass_must_change_time
;
5918 init_uni_hdr(&usr
->hdr_user_name
, len_user_name
);
5919 init_uni_hdr(&usr
->hdr_full_name
, len_full_name
);
5920 init_uni_hdr(&usr
->hdr_home_dir
, len_home_dir
);
5921 init_uni_hdr(&usr
->hdr_dir_drive
, len_dir_drive
);
5922 init_uni_hdr(&usr
->hdr_logon_script
, len_logon_script
);
5923 init_uni_hdr(&usr
->hdr_profile_path
, len_profile_path
);
5924 init_uni_hdr(&usr
->hdr_acct_desc
, len_description
);
5925 init_uni_hdr(&usr
->hdr_workstations
, len_workstations
);
5926 init_uni_hdr(&usr
->hdr_unknown_str
, len_unknown_str
);
5927 init_uni_hdr(&usr
->hdr_munged_dial
, len_munged_dial
);
5929 memcpy(usr
->lm_pwd
, lm_pwd
, sizeof(usr
->lm_pwd
));
5930 memcpy(usr
->nt_pwd
, nt_pwd
, sizeof(usr
->nt_pwd
));
5932 usr
->user_rid
= user_rid
;
5933 usr
->group_rid
= group_rid
;
5934 usr
->acb_info
= acb_info
;
5935 usr
->unknown_3
= unknown_3
; /* 0x00ff ffff */
5937 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5938 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5939 usr
->unknown_5
= unknown_5
; /* 0x0002 0000 */
5941 if (nt_time_is_zero(pass_must_change_time
)) {
5942 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5944 usr
->passmustchange
=0;
5948 ZERO_STRUCT(usr
->padding1
);
5949 ZERO_STRUCT(usr
->padding2
);
5951 copy_unistr2(&usr
->uni_user_name
, user_name
);
5952 copy_unistr2(&usr
->uni_full_name
, full_name
);
5953 copy_unistr2(&usr
->uni_home_dir
, home_dir
);
5954 copy_unistr2(&usr
->uni_dir_drive
, dir_drive
);
5955 copy_unistr2(&usr
->uni_logon_script
, log_scr
);
5956 copy_unistr2(&usr
->uni_profile_path
, prof_path
);
5957 copy_unistr2(&usr
->uni_acct_desc
, desc
);
5958 copy_unistr2(&usr
->uni_workstations
, wkstas
);
5959 copy_unistr2(&usr
->uni_unknown_str
, unk_str
);
5960 copy_unistr2(&usr
->uni_munged_dial
, mung_dial
);
5962 usr
->unknown_6
= unknown_6
; /* 0x0000 04ec */
5965 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5968 /*************************************************************************
5969 init_sam_user_info21
5971 unknown_3 = 0x00ff ffff
5972 unknown_5 = 0x0002 0000
5973 unknown_6 = 0x0000 04ec
5975 *************************************************************************/
5977 NTSTATUS
init_sam_user_info21A(SAM_USER_INFO_21
*usr
, SAM_ACCOUNT
*pw
, DOM_SID
*domain_sid
)
5979 NTTIME logon_time
, logoff_time
, kickoff_time
,
5980 pass_last_set_time
, pass_can_change_time
,
5981 pass_must_change_time
;
5983 int len_user_name
, len_full_name
, len_home_dir
,
5984 len_dir_drive
, len_logon_script
, len_profile_path
,
5985 len_description
, len_workstations
, len_unknown_str
,
5988 const char* user_name
= pdb_get_username(pw
);
5989 const char* full_name
= pdb_get_fullname(pw
);
5990 const char* home_dir
= pdb_get_homedir(pw
);
5991 const char* dir_drive
= pdb_get_dir_drive(pw
);
5992 const char* logon_script
= pdb_get_logon_script(pw
);
5993 const char* profile_path
= pdb_get_profile_path(pw
);
5994 const char* description
= pdb_get_acct_desc(pw
);
5995 const char* workstations
= pdb_get_workstations(pw
);
5996 const char* munged_dial
= pdb_get_munged_dial(pw
);
5999 const DOM_SID
*user_sid
;
6002 const DOM_SID
*group_sid
;
6004 len_user_name
= user_name
!= NULL
? strlen(user_name
)+1 : 0;
6005 len_full_name
= full_name
!= NULL
? strlen(full_name
)+1 : 0;
6006 len_home_dir
= home_dir
!= NULL
? strlen(home_dir
)+1 : 0;
6007 len_dir_drive
= dir_drive
!= NULL
? strlen(dir_drive
)+1 : 0;
6008 len_logon_script
= logon_script
!= NULL
? strlen(logon_script
)+1 : 0;
6009 len_profile_path
= profile_path
!= NULL
? strlen(profile_path
)+1 : 0;
6010 len_description
= description
!= NULL
? strlen(description
)+1 : 0;
6011 len_workstations
= workstations
!= NULL
? strlen(workstations
)+1 : 0;
6012 len_unknown_str
= 0;
6013 len_munged_dial
= munged_dial
!= NULL
? strlen(munged_dial
)+1 : 0;
6016 /* Create NTTIME structs */
6017 unix_to_nt_time (&logon_time
, pdb_get_logon_time(pw
));
6018 unix_to_nt_time (&logoff_time
, pdb_get_logoff_time(pw
));
6019 unix_to_nt_time (&kickoff_time
, pdb_get_kickoff_time(pw
));
6020 unix_to_nt_time (&pass_last_set_time
, pdb_get_pass_last_set_time(pw
));
6021 unix_to_nt_time (&pass_can_change_time
, pdb_get_pass_can_change_time(pw
));
6022 unix_to_nt_time (&pass_must_change_time
,pdb_get_pass_must_change_time(pw
));
6024 /* structure assignment */
6025 usr
->logon_time
= logon_time
;
6026 usr
->logoff_time
= logoff_time
;
6027 usr
->kickoff_time
= kickoff_time
;
6028 usr
->pass_last_set_time
= pass_last_set_time
;
6029 usr
->pass_can_change_time
= pass_can_change_time
;
6030 usr
->pass_must_change_time
= pass_must_change_time
;
6032 init_uni_hdr(&usr
->hdr_user_name
, len_user_name
);
6033 init_uni_hdr(&usr
->hdr_full_name
, len_full_name
);
6034 init_uni_hdr(&usr
->hdr_home_dir
, len_home_dir
);
6035 init_uni_hdr(&usr
->hdr_dir_drive
, len_dir_drive
);
6036 init_uni_hdr(&usr
->hdr_logon_script
, len_logon_script
);
6037 init_uni_hdr(&usr
->hdr_profile_path
, len_profile_path
);
6038 init_uni_hdr(&usr
->hdr_acct_desc
, len_description
);
6039 init_uni_hdr(&usr
->hdr_workstations
, len_workstations
);
6040 init_uni_hdr(&usr
->hdr_unknown_str
, len_unknown_str
);
6041 init_uni_hdr(&usr
->hdr_munged_dial
, len_munged_dial
);
6043 ZERO_STRUCT(usr
->nt_pwd
);
6044 ZERO_STRUCT(usr
->lm_pwd
);
6046 user_sid
= pdb_get_user_sid(pw
);
6048 if (!sid_peek_check_rid(domain_sid
, user_sid
, &user_rid
)) {
6049 fstring user_sid_string
;
6050 fstring domain_sid_string
;
6051 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6052 "the domain sid %s. Failing operation.\n",
6054 sid_to_string(user_sid_string
, user_sid
),
6055 sid_to_string(domain_sid_string
, domain_sid
)));
6056 return NT_STATUS_UNSUCCESSFUL
;
6059 group_sid
= pdb_get_group_sid(pw
);
6061 if (!sid_peek_check_rid(domain_sid
, group_sid
, &group_rid
)) {
6062 fstring group_sid_string
;
6063 fstring domain_sid_string
;
6064 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6065 "which conflicts with the domain sid %s. Failing operation.\n",
6067 sid_to_string(group_sid_string
, group_sid
),
6068 sid_to_string(domain_sid_string
, domain_sid
)));
6069 return NT_STATUS_UNSUCCESSFUL
;
6072 usr
->user_rid
= user_rid
;
6073 usr
->group_rid
= group_rid
;
6074 usr
->acb_info
= pdb_get_acct_ctrl(pw
);
6077 Look at a user on a real NT4 PDC with usrmgr, press
6078 'ok'. Then you will see that unknown_3 is set to
6079 0x08f827fa. Look at the user immediately after that again,
6080 and you will see that 0x00fffff is returned. This solves
6081 the problem that you get access denied after having looked
6085 usr
->unknown_3
= 0x00ffffff;
6087 usr
->logon_divs
= pdb_get_logon_divs(pw
);
6088 usr
->ptr_logon_hrs
= pdb_get_hours(pw
) ? 1 : 0;
6089 usr
->unknown_5
= pdb_get_unknown_5(pw
); /* 0x0002 0000 */
6091 if (pdb_get_pass_must_change_time(pw
) == 0) {
6092 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
6094 usr
->passmustchange
=0;
6098 ZERO_STRUCT(usr
->padding1
);
6099 ZERO_STRUCT(usr
->padding2
);
6101 init_unistr2(&usr
->uni_user_name
, user_name
, len_user_name
);
6102 init_unistr2(&usr
->uni_full_name
, full_name
, len_full_name
);
6103 init_unistr2(&usr
->uni_home_dir
, home_dir
, len_home_dir
);
6104 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, len_dir_drive
);
6105 init_unistr2(&usr
->uni_logon_script
, logon_script
, len_logon_script
);
6106 init_unistr2(&usr
->uni_profile_path
, profile_path
, len_profile_path
);
6107 init_unistr2(&usr
->uni_acct_desc
, description
, len_description
);
6108 init_unistr2(&usr
->uni_workstations
, workstations
, len_workstations
);
6109 init_unistr2(&usr
->uni_unknown_str
, NULL
, len_unknown_str
);
6110 init_unistr2(&usr
->uni_munged_dial
, munged_dial
, len_munged_dial
);
6112 usr
->unknown_6
= pdb_get_unknown_6(pw
);
6115 if (pdb_get_hours(pw
)) {
6116 usr
->logon_hrs
.len
= pdb_get_hours_len(pw
);
6117 memcpy(&usr
->logon_hrs
.hours
, pdb_get_hours(pw
), MAX_HOURS_LEN
);
6119 memset(&usr
->logon_hrs
, 0xff, sizeof(usr
->logon_hrs
));
6121 return NT_STATUS_OK
;
6124 /*******************************************************************
6125 reads or writes a structure.
6126 ********************************************************************/
6128 static BOOL
sam_io_user_info21(const char *desc
, SAM_USER_INFO_21
* usr
,
6129 prs_struct
*ps
, int depth
)
6134 prs_debug(ps
, depth
, desc
, "sam_io_user_info21");
6140 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
6142 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
6144 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
,depth
))
6146 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
6148 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
,depth
))
6150 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
6153 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
6155 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
6157 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
6159 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
6161 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
6163 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
6165 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
6167 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
6169 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
6171 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
6174 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
6176 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
6179 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
6181 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
6183 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
6186 if(!prs_uint32("unknown_3 ", ps
, depth
, &usr
->unknown_3
))
6188 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
6192 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
6195 if(!prs_uint32("unknown_5 ", ps
, depth
, &usr
->unknown_5
))
6198 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
6200 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
6202 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
6205 /* here begins pointed-to data */
6207 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
,usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
6209 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
6211 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
6213 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
6215 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
6217 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
6219 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
6221 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
6223 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
6225 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
,usr
->hdr_munged_dial
.buffer
, ps
, depth
)) /* worksations user can log on from */
6228 /* ok, this is only guess-work (as usual) */
6229 if (usr
->ptr_logon_hrs
) {
6232 if(!prs_uint32("unknown_6 ", ps
, depth
, &usr
->unknown_6
))
6234 if(!prs_uint32("padding4 ", ps
, depth
, &usr
->padding4
))
6236 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
6238 } else if (UNMARSHALLING(ps
)) {
6246 void init_sam_user_info20A(SAM_USER_INFO_20
*usr
, SAM_ACCOUNT
*pw
)
6248 int len_munged_dial
;
6249 const char* munged_dial
= pdb_get_munged_dial(pw
);
6251 len_munged_dial
= munged_dial
!= NULL
? strlen(munged_dial
)+1 : 0;
6252 init_uni_hdr(&usr
->hdr_munged_dial
, len_munged_dial
);
6253 init_unistr2(&usr
->uni_munged_dial
, munged_dial
, len_munged_dial
);
6257 /*******************************************************************
6258 reads or writes a structure.
6259 ********************************************************************/
6261 static BOOL
sam_io_user_info20(const char *desc
, SAM_USER_INFO_20
*usr
,
6262 prs_struct
*ps
, int depth
)
6267 prs_debug(ps
, depth
, desc
, "sam_io_user_info20");
6273 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
6276 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
,usr
->hdr_munged_dial
.buffer
, ps
, depth
)) /* worksations user can log on from */
6282 /*******************************************************************
6283 inits a SAM_USERINFO_CTR structure.
6284 ********************************************************************/
6286 NTSTATUS
make_samr_userinfo_ctr_usr21(TALLOC_CTX
*ctx
, SAM_USERINFO_CTR
* ctr
,
6287 uint16 switch_value
,
6288 SAM_USER_INFO_21
* usr
)
6290 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6292 ctr
->switch_value
= switch_value
;
6293 ctr
->info
.id
= NULL
;
6295 switch (switch_value
) {
6297 ctr
->info
.id10
= (SAM_USER_INFO_10
*)talloc_zero(ctx
,sizeof(SAM_USER_INFO_10
));
6298 if (ctr
->info
.id10
== NULL
)
6299 return NT_STATUS_NO_MEMORY
;
6301 init_sam_user_info10(ctr
->info
.id10
, usr
->acb_info
);
6304 /* whoops - got this wrong. i think. or don't understand what's happening. */
6308 info
= (void *)&id11
;
6310 expire
.low
= 0xffffffff;
6311 expire
.high
= 0x7fffffff;
6313 ctr
->info
.id
= (SAM_USER_INFO_11
*) talloc_zero(ctx
,sizeof(*ctr
->info
.id11
));
6314 init_sam_user_info11(ctr
->info
.id11
, &expire
,
6315 "BROOKFIELDS$", /* name */
6316 0x03ef, /* user rid */
6317 0x201, /* group rid */
6318 0x0080); /* acb info */
6324 ctr
->info
.id12
= (SAM_USER_INFO_12
*)talloc_zero(ctx
,sizeof(SAM_USER_INFO_12
));
6325 if (ctr
->info
.id12
== NULL
)
6326 return NT_STATUS_NO_MEMORY
;
6328 init_sam_user_info12(ctr
->info
.id12
, usr
->lm_pwd
, usr
->nt_pwd
);
6332 SAM_USER_INFO_21
*cusr
;
6333 cusr
= (SAM_USER_INFO_21
*)talloc_zero(ctx
,sizeof(SAM_USER_INFO_21
));
6334 ctr
->info
.id21
= cusr
;
6335 if (ctr
->info
.id21
== NULL
)
6336 return NT_STATUS_NO_MEMORY
;
6337 memcpy(cusr
, usr
, sizeof(*usr
));
6338 memset(cusr
->lm_pwd
, 0, sizeof(cusr
->lm_pwd
));
6339 memset(cusr
->nt_pwd
, 0, sizeof(cusr
->nt_pwd
));
6343 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6344 return NT_STATUS_INVALID_INFO_CLASS
;
6347 return NT_STATUS_OK
;
6350 /*******************************************************************
6351 inits a SAM_USERINFO_CTR structure.
6352 ********************************************************************/
6354 void init_samr_userinfo_ctr(SAM_USERINFO_CTR
* ctr
, uchar
* sess_key
,
6355 uint16 switch_value
, void *info
)
6357 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6359 ctr
->switch_value
= switch_value
;
6360 ctr
->info
.id
= info
;
6362 switch (switch_value
) {
6364 SamOEMhash(ctr
->info
.id24
->pass
, sess_key
, 516);
6365 dump_data(100, (char *)sess_key
, 16);
6366 dump_data(100, (char *)ctr
->info
.id24
->pass
, 516);
6369 SamOEMhash(ctr
->info
.id23
->pass
, sess_key
, 516);
6370 dump_data(100, (char *)sess_key
, 16);
6371 dump_data(100, (char *)ctr
->info
.id23
->pass
, 516);
6374 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6378 /*******************************************************************
6379 reads or writes a structure.
6380 ********************************************************************/
6382 static BOOL
samr_io_userinfo_ctr(const char *desc
, SAM_USERINFO_CTR
**ppctr
,
6383 prs_struct
*ps
, int depth
)
6386 SAM_USERINFO_CTR
*ctr
;
6388 prs_debug(ps
, depth
, desc
, "samr_io_userinfo_ctr");
6391 if (UNMARSHALLING(ps
)) {
6392 ctr
= (SAM_USERINFO_CTR
*)prs_alloc_mem(ps
,sizeof(SAM_USERINFO_CTR
));
6400 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6402 if(!prs_uint16("switch_value", ps
, depth
, &ctr
->switch_value
))
6409 switch (ctr
->switch_value
) {
6411 if (UNMARSHALLING(ps
))
6412 ctr
->info
.id10
= (SAM_USER_INFO_10
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_10
));
6413 if (ctr
->info
.id10
== NULL
) {
6414 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6417 ret
= sam_io_user_info10("", ctr
->info
.id10
, ps
, depth
);
6420 if (UNMARSHALLING(ps
))
6421 ctr
->info
.id11
= (SAM_USER_INFO_11
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_11
));
6423 if (ctr
->info
.id11
== NULL
) {
6424 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6427 ret
= sam_io_user_info11("", ctr
->info
.id11
, ps
, depth
);
6430 if (UNMARSHALLING(ps
))
6431 ctr
->info
.id12
= (SAM_USER_INFO_12
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_12
));
6433 if (ctr
->info
.id12
== NULL
) {
6434 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6437 ret
= sam_io_user_info12("", ctr
->info
.id12
, ps
, depth
);
6440 if (UNMARSHALLING(ps
))
6441 ctr
->info
.id20
= (SAM_USER_INFO_20
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_20
));
6443 if (ctr
->info
.id20
== NULL
) {
6444 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6447 ret
= sam_io_user_info20("", ctr
->info
.id20
, ps
, depth
);
6450 if (UNMARSHALLING(ps
))
6451 ctr
->info
.id21
= (SAM_USER_INFO_21
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_21
));
6453 if (ctr
->info
.id21
== NULL
) {
6454 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6457 ret
= sam_io_user_info21("", ctr
->info
.id21
, ps
, depth
);
6460 if (UNMARSHALLING(ps
))
6461 ctr
->info
.id23
= (SAM_USER_INFO_23
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_23
));
6463 if (ctr
->info
.id23
== NULL
) {
6464 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6467 ret
= sam_io_user_info23("", ctr
->info
.id23
, ps
, depth
);
6470 if (UNMARSHALLING(ps
))
6471 ctr
->info
.id24
= (SAM_USER_INFO_24
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_24
));
6473 if (ctr
->info
.id24
== NULL
) {
6474 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6477 ret
= sam_io_user_info24("", ctr
->info
.id24
, ps
, depth
);
6480 if (UNMARSHALLING(ps
))
6481 ctr
->info
.id25
= (SAM_USER_INFO_25
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_25
));
6483 if (ctr
->info
.id25
== NULL
) {
6484 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6487 ret
= sam_io_user_info25("", ctr
->info
.id25
, ps
, depth
);
6490 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr
->switch_value
));
6498 /*******************************************************************
6499 inits a SAMR_R_QUERY_USERINFO structure.
6500 ********************************************************************/
6502 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO
* r_u
,
6503 SAM_USERINFO_CTR
* ctr
, NTSTATUS status
)
6505 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6510 if (NT_STATUS_IS_OK(status
)) {
6515 r_u
->status
= status
; /* return status */
6518 /*******************************************************************
6519 reads or writes a structure.
6520 ********************************************************************/
6522 BOOL
samr_io_r_query_userinfo(const char *desc
, SAMR_R_QUERY_USERINFO
* r_u
,
6523 prs_struct
*ps
, int depth
)
6528 prs_debug(ps
, depth
, desc
, "samr_io_r_query_userinfo");
6534 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
6537 if (r_u
->ptr
!= 0) {
6538 if(!samr_io_userinfo_ctr("ctr", &r_u
->ctr
, ps
, depth
))
6544 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6550 /*******************************************************************
6551 inits a SAMR_Q_SET_USERINFO structure.
6552 ********************************************************************/
6554 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO
* q_u
,
6555 POLICY_HND
*hnd
, unsigned char sess_key
[16],
6556 uint16 switch_value
, void *info
)
6558 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6561 q_u
->switch_value
= switch_value
;
6562 init_samr_userinfo_ctr(q_u
->ctr
, sess_key
, switch_value
, info
);
6565 /*******************************************************************
6566 reads or writes a structure.
6567 ********************************************************************/
6569 BOOL
samr_io_q_set_userinfo(const char *desc
, SAMR_Q_SET_USERINFO
* q_u
,
6570 prs_struct
*ps
, int depth
)
6575 prs_debug(ps
, depth
, desc
, "samr_io_q_set_userinfo");
6581 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
6583 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
6585 if(!samr_io_userinfo_ctr("ctr", &q_u
->ctr
, ps
, depth
))
6591 /*******************************************************************
6592 inits a SAMR_R_SET_USERINFO structure.
6593 ********************************************************************/
6595 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO
* r_u
, NTSTATUS status
)
6597 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6599 r_u
->status
= status
; /* return status */
6602 /*******************************************************************
6603 reads or writes a structure.
6604 ********************************************************************/
6606 BOOL
samr_io_r_set_userinfo(const char *desc
, SAMR_R_SET_USERINFO
* r_u
,
6607 prs_struct
*ps
, int depth
)
6612 prs_debug(ps
, depth
, desc
, "samr_io_r_set_userinfo");
6618 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6624 /*******************************************************************
6625 inits a SAMR_Q_SET_USERINFO2 structure.
6626 ********************************************************************/
6628 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2
* q_u
,
6629 POLICY_HND
*hnd
, unsigned char sess_key
[16],
6630 uint16 switch_value
, SAM_USERINFO_CTR
* ctr
)
6632 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6635 q_u
->switch_value
= switch_value
;
6638 if (q_u
->ctr
!= NULL
)
6639 q_u
->ctr
->switch_value
= switch_value
;
6641 switch (switch_value
) {
6643 SamOEMhash(ctr
->info
.id12
->lm_pwd
, sess_key
, 16);
6644 SamOEMhash(ctr
->info
.id12
->nt_pwd
, sess_key
, 16);
6645 dump_data(100, (char *)sess_key
, 16);
6646 dump_data(100, (char *)ctr
->info
.id12
->lm_pwd
, 16);
6647 dump_data(100, (char *)ctr
->info
.id12
->nt_pwd
, 16);
6652 /*******************************************************************
6653 reads or writes a structure.
6654 ********************************************************************/
6656 BOOL
samr_io_q_set_userinfo2(const char *desc
, SAMR_Q_SET_USERINFO2
* q_u
,
6657 prs_struct
*ps
, int depth
)
6662 prs_debug(ps
, depth
, desc
, "samr_io_q_set_userinfo2");
6668 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
6671 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
6673 if(!samr_io_userinfo_ctr("ctr", &q_u
->ctr
, ps
, depth
))
6679 /*******************************************************************
6680 inits a SAMR_R_SET_USERINFO2 structure.
6681 ********************************************************************/
6683 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2
* r_u
, NTSTATUS status
)
6685 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6687 r_u
->status
= status
; /* return status */
6690 /*******************************************************************
6691 reads or writes a structure.
6692 ********************************************************************/
6694 BOOL
samr_io_r_set_userinfo2(const char *desc
, SAMR_R_SET_USERINFO2
* r_u
,
6695 prs_struct
*ps
, int depth
)
6700 prs_debug(ps
, depth
, desc
, "samr_io_r_set_userinfo2");
6706 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6712 /*******************************************************************
6713 inits a SAMR_Q_CONNECT structure.
6714 ********************************************************************/
6716 void init_samr_q_connect(SAMR_Q_CONNECT
* q_u
,
6717 char *srv_name
, uint32 access_mask
)
6719 int len_srv_name
= strlen(srv_name
);
6721 DEBUG(5, ("init_samr_q_connect\n"));
6723 /* make PDC server name \\server */
6724 q_u
->ptr_srv_name
= len_srv_name
> 0 ? 1 : 0;
6725 init_unistr2(&q_u
->uni_srv_name
, srv_name
, len_srv_name
+ 1);
6727 /* example values: 0x0000 0002 */
6728 q_u
->access_mask
= access_mask
;
6731 /*******************************************************************
6732 reads or writes a structure.
6733 ********************************************************************/
6735 BOOL
samr_io_q_connect(const char *desc
, SAMR_Q_CONNECT
* q_u
,
6736 prs_struct
*ps
, int depth
)
6741 prs_debug(ps
, depth
, desc
, "samr_io_q_connect");
6747 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
6749 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
6754 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6760 /*******************************************************************
6761 reads or writes a structure.
6762 ********************************************************************/
6764 BOOL
samr_io_r_connect(const char *desc
, SAMR_R_CONNECT
* r_u
,
6765 prs_struct
*ps
, int depth
)
6770 prs_debug(ps
, depth
, desc
, "samr_io_r_connect");
6776 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6779 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6785 /*******************************************************************
6786 inits a SAMR_Q_CONNECT4 structure.
6787 ********************************************************************/
6789 void init_samr_q_connect4(SAMR_Q_CONNECT4
* q_u
,
6790 char *srv_name
, uint32 access_mask
)
6792 int len_srv_name
= strlen(srv_name
);
6794 DEBUG(5, ("init_samr_q_connect\n"));
6796 /* make PDC server name \\server */
6797 q_u
->ptr_srv_name
= len_srv_name
> 0 ? 1 : 0;
6798 init_unistr2(&q_u
->uni_srv_name
, srv_name
, len_srv_name
+ 1);
6800 /* Only value we've seen, possibly an address type ? */
6803 /* example values: 0x0000 0002 */
6804 q_u
->access_mask
= access_mask
;
6807 /*******************************************************************
6808 reads or writes a structure.
6809 ********************************************************************/
6811 BOOL
samr_io_q_connect4(const char *desc
, SAMR_Q_CONNECT4
* q_u
,
6812 prs_struct
*ps
, int depth
)
6817 prs_debug(ps
, depth
, desc
, "samr_io_q_connect4");
6823 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
6825 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
6830 if(!prs_uint32("unk_0", ps
, depth
, &q_u
->unk_0
))
6832 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6838 /*******************************************************************
6839 reads or writes a structure.
6840 ********************************************************************/
6842 BOOL
samr_io_r_connect4(const char *desc
, SAMR_R_CONNECT4
* r_u
,
6843 prs_struct
*ps
, int depth
)
6848 prs_debug(ps
, depth
, desc
, "samr_io_r_connect4");
6854 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6857 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6863 /*******************************************************************
6864 inits a SAMR_Q_CONNECT_ANON structure.
6865 ********************************************************************/
6867 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON
* q_u
)
6869 DEBUG(5, ("init_samr_q_connect_anon\n"));
6872 q_u
->unknown_0
= 0x5c; /* server name (?!!) */
6873 q_u
->unknown_1
= 0x01;
6874 q_u
->access_mask
= 0x20;
6877 /*******************************************************************
6878 reads or writes a structure.
6879 ********************************************************************/
6881 BOOL
samr_io_q_connect_anon(const char *desc
, SAMR_Q_CONNECT_ANON
* q_u
,
6882 prs_struct
*ps
, int depth
)
6887 prs_debug(ps
, depth
, desc
, "samr_io_q_connect_anon");
6893 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
6895 if(!prs_uint16("unknown_0", ps
, depth
, &q_u
->unknown_0
))
6897 if(!prs_uint16("unknown_1", ps
, depth
, &q_u
->unknown_1
))
6899 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6905 /*******************************************************************
6906 reads or writes a structure.
6907 ********************************************************************/
6909 BOOL
samr_io_r_connect_anon(const char *desc
, SAMR_R_CONNECT_ANON
* r_u
,
6910 prs_struct
*ps
, int depth
)
6915 prs_debug(ps
, depth
, desc
, "samr_io_r_connect_anon");
6921 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6924 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6930 /*******************************************************************
6931 inits a SAMR_Q_GET_DOM_PWINFO structure.
6932 ********************************************************************/
6934 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO
* q_u
,
6937 int len_srv_name
= strlen(srv_name
);
6939 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6942 init_uni_hdr(&q_u
->hdr_srv_name
, len_srv_name
);
6943 init_unistr2(&q_u
->uni_srv_name
, srv_name
, len_srv_name
);
6946 /*******************************************************************
6947 reads or writes a structure.
6948 ********************************************************************/
6950 BOOL
samr_io_q_get_dom_pwinfo(const char *desc
, SAMR_Q_GET_DOM_PWINFO
* q_u
,
6951 prs_struct
*ps
, int depth
)
6956 prs_debug(ps
, depth
, desc
, "samr_io_q_get_dom_pwinfo");
6962 if(!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
6964 if (q_u
->ptr
!= 0) {
6965 if(!smb_io_unihdr("", &q_u
->hdr_srv_name
, ps
, depth
))
6967 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->hdr_srv_name
.buffer
, ps
, depth
))
6974 /*******************************************************************
6975 reads or writes a structure.
6976 ********************************************************************/
6978 BOOL
samr_io_r_get_dom_pwinfo(const char *desc
, SAMR_R_GET_DOM_PWINFO
* r_u
,
6979 prs_struct
*ps
, int depth
)
6984 prs_debug(ps
, depth
, desc
, "samr_io_r_get_dom_pwinfo");
6991 * We need 16 bytes here according to tests. Don't know
6992 * what they are, but the length is important for the singing
6995 if(!prs_uint32("unk_0", ps
, depth
, &r_u
->unk_0
))
6997 if(!prs_uint32("unk_1", ps
, depth
, &r_u
->unk_1
))
6999 if(!prs_uint32("unk_2", ps
, depth
, &r_u
->unk_2
))
7002 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7008 /*******************************************************************
7009 make a SAMR_ENC_PASSWD structure.
7010 ********************************************************************/
7012 void init_enc_passwd(SAMR_ENC_PASSWD
* pwd
, char pass
[512])
7020 memcpy(pwd
->pass
, pass
, sizeof(pwd
->pass
));
7024 /*******************************************************************
7025 reads or writes a SAMR_ENC_PASSWD structure.
7026 ********************************************************************/
7028 BOOL
samr_io_enc_passwd(const char *desc
, SAMR_ENC_PASSWD
* pwd
,
7029 prs_struct
*ps
, int depth
)
7034 prs_debug(ps
, depth
, desc
, "samr_io_enc_passwd");
7040 if(!prs_uint32("ptr", ps
, depth
, &pwd
->ptr
))
7043 if (pwd
->ptr
!= 0) {
7044 if(!prs_uint8s(False
, "pwd", ps
, depth
, pwd
->pass
, sizeof(pwd
->pass
)))
7051 /*******************************************************************
7052 inits a SAMR_ENC_HASH structure.
7053 ********************************************************************/
7055 void init_enc_hash(SAMR_ENC_HASH
* hsh
, uchar hash
[16])
7063 memcpy(hsh
->hash
, hash
, sizeof(hsh
->hash
));
7067 /*******************************************************************
7068 reads or writes a SAMR_ENC_HASH structure.
7069 ********************************************************************/
7071 BOOL
samr_io_enc_hash(const char *desc
, SAMR_ENC_HASH
* hsh
,
7072 prs_struct
*ps
, int depth
)
7077 prs_debug(ps
, depth
, desc
, "samr_io_enc_hash");
7083 if(!prs_uint32("ptr ", ps
, depth
, &hsh
->ptr
))
7085 if (hsh
->ptr
!= 0) {
7086 if(!prs_uint8s(False
, "hash", ps
, depth
, hsh
->hash
,sizeof(hsh
->hash
)))
7093 /*******************************************************************
7094 inits a SAMR_R_GET_DOM_PWINFO structure.
7095 ********************************************************************/
7097 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER
* q_u
,
7098 char *dest_host
, char *user_name
,
7099 char nt_newpass
[516],
7100 uchar nt_oldhash
[16],
7101 char lm_newpass
[516],
7102 uchar lm_oldhash
[16])
7104 int len_dest_host
= strlen(dest_host
);
7105 int len_user_name
= strlen(user_name
);
7107 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7110 init_uni_hdr(&q_u
->hdr_dest_host
, len_dest_host
);
7111 init_unistr2(&q_u
->uni_dest_host
, dest_host
, len_dest_host
);
7112 init_uni_hdr(&q_u
->hdr_user_name
, len_user_name
);
7113 init_unistr2(&q_u
->uni_user_name
, user_name
, len_user_name
);
7115 init_enc_passwd(&q_u
->nt_newpass
, nt_newpass
);
7116 init_enc_hash(&q_u
->nt_oldhash
, nt_oldhash
);
7118 q_u
->unknown
= 0x01;
7120 init_enc_passwd(&q_u
->lm_newpass
, lm_newpass
);
7121 init_enc_hash(&q_u
->lm_oldhash
, lm_oldhash
);
7124 /*******************************************************************
7125 reads or writes a structure.
7126 ********************************************************************/
7128 BOOL
samr_io_q_chgpasswd_user(const char *desc
, SAMR_Q_CHGPASSWD_USER
* q_u
,
7129 prs_struct
*ps
, int depth
)
7134 prs_debug(ps
, depth
, desc
, "samr_io_q_chgpasswd_user");
7140 if(!prs_uint32("ptr_0", ps
, depth
, &q_u
->ptr_0
))
7143 if(!smb_io_unihdr("", &q_u
->hdr_dest_host
, ps
, depth
))
7145 if(!smb_io_unistr2("", &q_u
->uni_dest_host
, q_u
->hdr_dest_host
.buffer
, ps
, depth
))
7150 if(!smb_io_unihdr("", &q_u
->hdr_user_name
, ps
, depth
))
7152 if(!smb_io_unistr2("", &q_u
->uni_user_name
, q_u
->hdr_user_name
.buffer
,ps
, depth
))
7155 if(!samr_io_enc_passwd("nt_newpass", &q_u
->nt_newpass
, ps
, depth
))
7157 if(!samr_io_enc_hash("nt_oldhash", &q_u
->nt_oldhash
, ps
, depth
))
7160 if(!prs_uint32("unknown", ps
, depth
, &q_u
->unknown
))
7163 if(!samr_io_enc_passwd("lm_newpass", &q_u
->lm_newpass
, ps
, depth
))
7165 if(!samr_io_enc_hash("lm_oldhash", &q_u
->lm_oldhash
, ps
, depth
))
7171 /*******************************************************************
7172 inits a SAMR_R_CHGPASSWD_USER structure.
7173 ********************************************************************/
7175 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER
* r_u
, NTSTATUS status
)
7177 DEBUG(5, ("init_r_chgpasswd_user\n"));
7179 r_u
->status
= status
;
7182 /*******************************************************************
7183 reads or writes a structure.
7184 ********************************************************************/
7186 BOOL
samr_io_r_chgpasswd_user(const char *desc
, SAMR_R_CHGPASSWD_USER
* r_u
,
7187 prs_struct
*ps
, int depth
)
7192 prs_debug(ps
, depth
, desc
, "samr_io_r_chgpasswd_user");
7198 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7204 /*******************************************************************
7205 reads or writes a structure.
7206 ********************************************************************/
7208 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E
*q_u
,
7209 POLICY_HND
*domain_pol
, uint16 switch_value
)
7211 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7213 q_u
->domain_pol
= *domain_pol
;
7214 q_u
->switch_value
= switch_value
;
7217 /*******************************************************************
7218 reads or writes a structure.
7219 ********************************************************************/
7221 BOOL
samr_io_q_unknown_2e(const char *desc
, SAMR_Q_UNKNOWN_2E
*q_u
,
7222 prs_struct
*ps
, int depth
)
7227 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_2e");
7233 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
7236 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
7242 /*******************************************************************
7243 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7244 ********************************************************************/
7246 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E
* r_u
,
7247 uint16 switch_value
, SAM_UNK_CTR
* ctr
,
7250 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7253 r_u
->switch_value
= 0;
7254 r_u
->status
= status
; /* return status */
7256 if (NT_STATUS_IS_OK(status
)) {
7257 r_u
->switch_value
= switch_value
;
7263 /*******************************************************************
7264 reads or writes a structure.
7265 ********************************************************************/
7267 BOOL
samr_io_r_samr_unknown_2e(const char *desc
, SAMR_R_UNKNOWN_2E
* r_u
,
7268 prs_struct
*ps
, int depth
)
7273 prs_debug(ps
, depth
, desc
, "samr_io_r_samr_unknown_2e");
7279 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
7282 if (r_u
->ptr_0
!= 0 && r_u
->ctr
!= NULL
) {
7283 if(!prs_uint16("switch_value", ps
, depth
, &r_u
->switch_value
))
7288 switch (r_u
->switch_value
) {
7290 if(!sam_io_unk_info12("unk_inf12", &r_u
->ctr
->info
.inf12
, ps
, depth
))
7294 if(!sam_io_unk_info7("unk_inf7",&r_u
->ctr
->info
.inf7
, ps
,depth
))
7298 if(!sam_io_unk_info6("unk_inf6",&r_u
->ctr
->info
.inf6
, ps
,depth
))
7302 if(!sam_io_unk_info5("unk_inf5",&r_u
->ctr
->info
.inf5
, ps
,depth
))
7306 if(!sam_io_unk_info3("unk_inf3",&r_u
->ctr
->info
.inf3
, ps
,depth
))
7310 if(!sam_io_unk_info2("unk_inf2",&r_u
->ctr
->info
.inf2
, ps
,depth
))
7314 if(!sam_io_unk_info1("unk_inf1",&r_u
->ctr
->info
.inf1
, ps
,depth
))
7318 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7319 r_u
->switch_value
));
7320 r_u
->status
= NT_STATUS_INVALID_INFO_CLASS
;
7328 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7335 /*******************************************************************
7336 reads or writes a structure.
7337 ********************************************************************/
7339 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO
*q_u
,
7340 POLICY_HND
*domain_pol
, uint16 switch_value
, SAM_UNK_CTR
*ctr
)
7342 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7344 q_u
->domain_pol
= *domain_pol
;
7345 q_u
->switch_value0
= switch_value
;
7347 q_u
->switch_value
= switch_value
;
7352 /*******************************************************************
7353 reads or writes a structure.
7354 ********************************************************************/
7356 BOOL
samr_io_q_set_domain_info(const char *desc
, SAMR_Q_SET_DOMAIN_INFO
*q_u
,
7357 prs_struct
*ps
, int depth
)
7362 prs_debug(ps
, depth
, desc
, "samr_io_q_set_domain_info");
7368 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
7371 if(!prs_uint16("switch_value0", ps
, depth
, &q_u
->switch_value0
))
7374 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
7380 if ((q_u
->ctr
= (SAM_UNK_CTR
*)prs_alloc_mem(ps
, sizeof(SAM_UNK_CTR
))) == NULL
)
7383 switch (q_u
->switch_value
) {
7386 if(!sam_io_unk_info12("unk_inf12", &q_u
->ctr
->info
.inf12
, ps
, depth
))
7390 if(!sam_io_unk_info7("unk_inf7",&q_u
->ctr
->info
.inf7
, ps
,depth
))
7394 if(!sam_io_unk_info6("unk_inf6",&q_u
->ctr
->info
.inf6
, ps
,depth
))
7398 if(!sam_io_unk_info5("unk_inf5",&q_u
->ctr
->info
.inf5
, ps
,depth
))
7402 if(!sam_io_unk_info3("unk_inf3",&q_u
->ctr
->info
.inf3
, ps
,depth
))
7406 if(!sam_io_unk_info2("unk_inf2",&q_u
->ctr
->info
.inf2
, ps
,depth
))
7410 if(!sam_io_unk_info1("unk_inf1",&q_u
->ctr
->info
.inf1
, ps
,depth
))
7414 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7415 q_u
->switch_value
));
7422 /*******************************************************************
7423 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7424 ********************************************************************/
7426 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO
* r_u
, NTSTATUS status
)
7428 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7430 r_u
->status
= status
; /* return status */
7433 /*******************************************************************
7434 reads or writes a structure.
7435 ********************************************************************/
7437 BOOL
samr_io_r_set_domain_info(const char *desc
, SAMR_R_SET_DOMAIN_INFO
* r_u
,
7438 prs_struct
*ps
, int depth
)
7443 prs_debug(ps
, depth
, desc
, "samr_io_r_samr_unknown_2e");
7449 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))