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 3 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, see <http://www.gnu.org/licenses/>.
29 #define DBGC_CLASS DBGC_RPC_PARSE
31 /*******************************************************************
33 ********************************************************************/
35 static void init_lsa_String(struct lsa_String
*name
, const char *s
)
40 /*******************************************************************
42 ********************************************************************/
44 void init_samr_DomInfo1(struct samr_DomInfo1
*r
,
45 uint16_t min_password_length
,
46 uint16_t password_history_length
,
47 uint32_t password_properties
,
48 int64_t max_password_age
,
49 int64_t min_password_age
)
51 r
->min_password_length
= min_password_length
;
52 r
->password_history_length
= password_history_length
;
53 r
->password_properties
= password_properties
;
54 r
->max_password_age
= max_password_age
;
55 r
->min_password_age
= min_password_age
;
58 /*******************************************************************
60 ********************************************************************/
62 void init_samr_DomInfo2(struct samr_DomInfo2
*r
,
63 NTTIME force_logoff_time
,
65 const char *domain_name
,
67 uint64_t sequence_num
,
75 r
->force_logoff_time
= force_logoff_time
;
76 init_lsa_String(&r
->comment
, comment
);
77 init_lsa_String(&r
->domain_name
, domain_name
);
78 init_lsa_String(&r
->primary
, primary
);
79 r
->sequence_num
= sequence_num
;
80 r
->unknown2
= unknown2
;
82 r
->unknown3
= unknown3
;
83 r
->num_users
= num_users
;
84 r
->num_groups
= num_groups
;
85 r
->num_aliases
= num_aliases
;
88 /*******************************************************************
90 ********************************************************************/
92 void init_samr_DomInfo3(struct samr_DomInfo3
*r
,
93 NTTIME force_logoff_time
)
95 r
->force_logoff_time
= force_logoff_time
;
98 /*******************************************************************
100 ********************************************************************/
102 void init_samr_DomInfo4(struct samr_DomInfo4
*r
,
105 init_lsa_String(&r
->comment
, comment
);
108 /*******************************************************************
110 ********************************************************************/
112 void init_samr_DomInfo5(struct samr_DomInfo5
*r
,
113 const char *domain_name
)
115 init_lsa_String(&r
->domain_name
, domain_name
);
118 /*******************************************************************
120 ********************************************************************/
122 void init_samr_DomInfo6(struct samr_DomInfo6
*r
,
125 init_lsa_String(&r
->primary
, primary
);
128 /*******************************************************************
130 ********************************************************************/
132 void init_samr_DomInfo7(struct samr_DomInfo7
*r
,
138 /*******************************************************************
140 ********************************************************************/
142 void init_samr_DomInfo8(struct samr_DomInfo8
*r
,
143 uint64_t sequence_num
,
144 NTTIME domain_create_time
)
146 r
->sequence_num
= sequence_num
;
147 r
->domain_create_time
= domain_create_time
;
150 /*******************************************************************
152 ********************************************************************/
154 void init_samr_DomInfo9(struct samr_DomInfo9
*r
,
157 r
->unknown
= unknown
;
160 /*******************************************************************
162 ********************************************************************/
164 void init_samr_DomInfo12(struct samr_DomInfo12
*r
,
165 uint64_t lockout_duration
,
166 uint64_t lockout_window
,
167 uint16_t lockout_threshold
)
169 r
->lockout_duration
= lockout_duration
;
170 r
->lockout_window
= lockout_window
;
171 r
->lockout_threshold
= lockout_threshold
;
174 /*******************************************************************
175 reads or writes a SAM_STR1 structure.
176 ********************************************************************/
178 static bool sam_io_sam_str1(const char *desc
, SAM_STR1
* sam
, uint32 acct_buf
,
179 uint32 name_buf
, uint32 desc_buf
,
180 prs_struct
*ps
, int depth
)
185 prs_debug(ps
, depth
, desc
, "sam_io_sam_str1");
190 if (!smb_io_unistr2("name", &sam
->uni_acct_name
, acct_buf
, ps
, depth
))
193 if (!smb_io_unistr2("desc", &sam
->uni_acct_desc
, desc_buf
, ps
, depth
))
196 if (!smb_io_unistr2("full", &sam
->uni_full_name
, name_buf
, ps
, depth
))
202 /*******************************************************************
203 inits a SAM_ENTRY1 structure.
204 ********************************************************************/
206 static void init_sam_entry1(SAM_ENTRY1
*sam
, uint32 user_idx
,
207 UNISTR2
*sam_name
, UNISTR2
*sam_full
,
208 UNISTR2
*sam_desc
, uint32 rid_user
,
211 DEBUG(5, ("init_sam_entry1\n"));
215 sam
->user_idx
= user_idx
;
216 sam
->rid_user
= rid_user
;
217 sam
->acb_info
= acb_info
;
219 init_uni_hdr(&sam
->hdr_acct_name
, sam_name
);
220 init_uni_hdr(&sam
->hdr_user_name
, sam_full
);
221 init_uni_hdr(&sam
->hdr_user_desc
, sam_desc
);
224 /*******************************************************************
225 reads or writes a SAM_ENTRY1 structure.
226 ********************************************************************/
228 static bool sam_io_sam_entry1(const char *desc
, SAM_ENTRY1
* sam
,
229 prs_struct
*ps
, int depth
)
234 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry1");
240 if(!prs_uint32("user_idx ", ps
, depth
, &sam
->user_idx
))
243 if(!prs_uint32("rid_user ", ps
, depth
, &sam
->rid_user
))
245 if(!prs_uint32("acb_info ", ps
, depth
, &sam
->acb_info
))
248 if (!smb_io_unihdr("hdr_acct_name", &sam
->hdr_acct_name
, ps
, depth
))
250 if (!smb_io_unihdr("hdr_user_desc", &sam
->hdr_user_desc
, ps
, depth
))
252 if (!smb_io_unihdr("hdr_user_name", &sam
->hdr_user_name
, ps
, depth
))
258 /*******************************************************************
259 reads or writes a SAM_STR2 structure.
260 ********************************************************************/
262 static bool sam_io_sam_str2(const char *desc
, SAM_STR2
* sam
, uint32 acct_buf
,
263 uint32 desc_buf
, prs_struct
*ps
, int depth
)
268 prs_debug(ps
, depth
, desc
, "sam_io_sam_str2");
274 if(!smb_io_unistr2("uni_srv_name", &sam
->uni_srv_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
276 if(!smb_io_unistr2("uni_srv_desc", &sam
->uni_srv_desc
, desc_buf
, ps
, depth
)) /* account desc unicode string */
282 /*******************************************************************
283 inits a SAM_ENTRY2 structure.
284 ********************************************************************/
285 static void init_sam_entry2(SAM_ENTRY2
* sam
, uint32 user_idx
,
286 UNISTR2
*sam_name
, UNISTR2
*sam_desc
,
287 uint32 rid_user
, uint32 acb_info
)
289 DEBUG(5, ("init_sam_entry2\n"));
291 sam
->user_idx
= user_idx
;
292 sam
->rid_user
= rid_user
;
293 sam
->acb_info
= acb_info
;
295 init_uni_hdr(&sam
->hdr_srv_name
, sam_name
);
296 init_uni_hdr(&sam
->hdr_srv_desc
, sam_desc
);
299 /*******************************************************************
300 reads or writes a SAM_ENTRY2 structure.
301 ********************************************************************/
303 static bool sam_io_sam_entry2(const char *desc
, SAM_ENTRY2
* sam
,
304 prs_struct
*ps
, int depth
)
309 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry2");
315 if(!prs_uint32("user_idx ", ps
, depth
, &sam
->user_idx
))
318 if(!prs_uint32("rid_user ", ps
, depth
, &sam
->rid_user
))
320 if(!prs_uint32("acb_info ", ps
, depth
, &sam
->acb_info
))
323 if(!smb_io_unihdr("unihdr", &sam
->hdr_srv_name
, ps
, depth
)) /* account name unicode string header */
325 if(!smb_io_unihdr("unihdr", &sam
->hdr_srv_desc
, ps
, depth
)) /* account name unicode string header */
331 /*******************************************************************
332 reads or writes a SAM_STR3 structure.
333 ********************************************************************/
335 static bool sam_io_sam_str3(const char *desc
, SAM_STR3
* sam
, uint32 acct_buf
,
336 uint32 desc_buf
, prs_struct
*ps
, int depth
)
341 prs_debug(ps
, depth
, desc
, "sam_io_sam_str3");
347 if(!smb_io_unistr2("uni_grp_name", &sam
->uni_grp_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
349 if(!smb_io_unistr2("uni_grp_desc", &sam
->uni_grp_desc
, desc_buf
, ps
, depth
)) /* account desc unicode string */
355 /*******************************************************************
356 inits a SAM_ENTRY3 structure.
357 ********************************************************************/
359 static void init_sam_entry3(SAM_ENTRY3
* sam
, uint32 grp_idx
,
360 UNISTR2
*grp_name
, UNISTR2
*grp_desc
,
363 DEBUG(5, ("init_sam_entry3\n"));
365 sam
->grp_idx
= grp_idx
;
366 sam
->rid_grp
= rid_grp
;
367 sam
->attr
= 0x07; /* group rid attributes - gets ignored by nt 4.0 */
369 init_uni_hdr(&sam
->hdr_grp_name
, grp_name
);
370 init_uni_hdr(&sam
->hdr_grp_desc
, grp_desc
);
373 /*******************************************************************
374 reads or writes a SAM_ENTRY3 structure.
375 ********************************************************************/
377 static bool sam_io_sam_entry3(const char *desc
, SAM_ENTRY3
* sam
,
378 prs_struct
*ps
, int depth
)
383 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry3");
389 if(!prs_uint32("grp_idx", ps
, depth
, &sam
->grp_idx
))
392 if(!prs_uint32("rid_grp", ps
, depth
, &sam
->rid_grp
))
394 if(!prs_uint32("attr ", ps
, depth
, &sam
->attr
))
397 if(!smb_io_unihdr("unihdr", &sam
->hdr_grp_name
, ps
, depth
)) /* account name unicode string header */
399 if(!smb_io_unihdr("unihdr", &sam
->hdr_grp_desc
, ps
, depth
)) /* account name unicode string header */
405 /*******************************************************************
406 inits a SAM_ENTRY4 structure.
407 ********************************************************************/
409 static void init_sam_entry4(SAM_ENTRY4
* sam
, uint32 user_idx
,
410 uint32 len_acct_name
)
412 DEBUG(5, ("init_sam_entry4\n"));
414 sam
->user_idx
= user_idx
;
415 init_str_hdr(&sam
->hdr_acct_name
, len_acct_name
+1, len_acct_name
, len_acct_name
!= 0);
418 /*******************************************************************
419 reads or writes a SAM_ENTRY4 structure.
420 ********************************************************************/
422 static bool sam_io_sam_entry4(const char *desc
, SAM_ENTRY4
* sam
,
423 prs_struct
*ps
, int depth
)
428 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry4");
434 if(!prs_uint32("user_idx", ps
, depth
, &sam
->user_idx
))
436 if(!smb_io_strhdr("strhdr", &sam
->hdr_acct_name
, ps
, depth
))
442 /*******************************************************************
443 inits a SAM_ENTRY5 structure.
444 ********************************************************************/
446 static void init_sam_entry5(SAM_ENTRY5
* sam
, uint32 grp_idx
,
449 DEBUG(5, ("init_sam_entry5\n"));
451 sam
->grp_idx
= grp_idx
;
452 init_str_hdr(&sam
->hdr_grp_name
, len_grp_name
, len_grp_name
,
456 /*******************************************************************
457 reads or writes a SAM_ENTRY5 structure.
458 ********************************************************************/
460 static bool sam_io_sam_entry5(const char *desc
, SAM_ENTRY5
* sam
,
461 prs_struct
*ps
, int depth
)
466 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry5");
472 if(!prs_uint32("grp_idx", ps
, depth
, &sam
->grp_idx
))
474 if(!smb_io_strhdr("strhdr", &sam
->hdr_grp_name
, ps
, depth
))
480 /*******************************************************************
481 inits a SAM_ENTRY structure.
482 ********************************************************************/
484 void init_sam_entry(SAM_ENTRY
*sam
, UNISTR2
*uni2
, uint32 rid
)
486 DEBUG(10, ("init_sam_entry: %d\n", rid
));
489 init_uni_hdr(&sam
->hdr_name
, uni2
);
492 /*******************************************************************
493 reads or writes a SAM_ENTRY structure.
494 ********************************************************************/
496 static bool sam_io_sam_entry(const char *desc
, SAM_ENTRY
* sam
,
497 prs_struct
*ps
, int depth
)
502 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry");
507 if(!prs_uint32("rid", ps
, depth
, &sam
->rid
))
509 if(!smb_io_unihdr("unihdr", &sam
->hdr_name
, ps
, depth
)) /* account name unicode string header */
515 /*******************************************************************
516 inits a SAMR_Q_ENUM_DOM_USERS structure.
517 ********************************************************************/
519 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS
* q_e
, POLICY_HND
*pol
,
521 uint32 acb_mask
, uint32 size
)
523 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
527 q_e
->start_idx
= start_idx
; /* zero indicates lots */
528 q_e
->acb_mask
= acb_mask
;
529 q_e
->max_size
= size
;
532 /*******************************************************************
533 reads or writes a structure.
534 ********************************************************************/
536 bool samr_io_q_enum_dom_users(const char *desc
, SAMR_Q_ENUM_DOM_USERS
* q_e
,
537 prs_struct
*ps
, int depth
)
542 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_users");
548 if(!smb_io_pol_hnd("domain_pol", &q_e
->pol
, ps
, depth
))
551 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
553 if(!prs_uint32("acb_mask ", ps
, depth
, &q_e
->acb_mask
))
556 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
563 /*******************************************************************
564 inits a SAMR_R_ENUM_DOM_USERS structure.
565 ********************************************************************/
567 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS
* r_u
,
568 uint32 next_idx
, uint32 num_sam_entries
)
570 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
572 r_u
->next_idx
= next_idx
;
574 if (num_sam_entries
!= 0) {
575 r_u
->ptr_entries1
= 1;
576 r_u
->ptr_entries2
= 1;
577 r_u
->num_entries2
= num_sam_entries
;
578 r_u
->num_entries3
= num_sam_entries
;
580 r_u
->num_entries4
= num_sam_entries
;
582 r_u
->ptr_entries1
= 0;
583 r_u
->num_entries2
= num_sam_entries
;
584 r_u
->ptr_entries2
= 1;
588 /*******************************************************************
589 reads or writes a structure.
590 ********************************************************************/
592 bool samr_io_r_enum_dom_users(const char *desc
, SAMR_R_ENUM_DOM_USERS
* r_u
,
593 prs_struct
*ps
, int depth
)
600 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_users");
606 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
608 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
611 if (r_u
->ptr_entries1
!= 0) {
612 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
614 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
616 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
619 if (UNMARSHALLING(ps
) && (r_u
->num_entries2
!= 0)) {
620 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
, r_u
->num_entries2
);
621 r_u
->uni_acct_name
= PRS_ALLOC_MEM(ps
,UNISTR2
, r_u
->num_entries2
);
624 if ((r_u
->sam
== NULL
|| r_u
->uni_acct_name
== NULL
) && r_u
->num_entries2
!= 0) {
625 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
626 r_u
->num_entries4
= 0;
627 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
631 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
632 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
636 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
637 if(!smb_io_unistr2("", &r_u
->uni_acct_name
[i
],r_u
->sam
[i
].hdr_name
.buffer
, ps
,depth
))
646 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
648 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
654 /*******************************************************************
655 inits a SAMR_Q_QUERY_DISPINFO structure.
656 ********************************************************************/
658 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO
* q_e
, POLICY_HND
*pol
,
659 uint16 switch_level
, uint32 start_idx
,
660 uint32 max_entries
, uint32 max_size
)
662 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
664 q_e
->domain_pol
= *pol
;
666 q_e
->switch_level
= switch_level
;
668 q_e
->start_idx
= start_idx
;
669 q_e
->max_entries
= max_entries
;
670 q_e
->max_size
= max_size
;
673 /*******************************************************************
674 reads or writes a structure.
675 ********************************************************************/
677 bool samr_io_q_query_dispinfo(const char *desc
, SAMR_Q_QUERY_DISPINFO
* q_e
,
678 prs_struct
*ps
, int depth
)
683 prs_debug(ps
, depth
, desc
, "samr_io_q_query_dispinfo");
689 if(!smb_io_pol_hnd("domain_pol", &q_e
->domain_pol
, ps
, depth
))
692 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
697 if(!prs_uint32("start_idx ", ps
, depth
, &q_e
->start_idx
))
699 if(!prs_uint32("max_entries ", ps
, depth
, &q_e
->max_entries
))
701 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
707 /*******************************************************************
708 inits a SAM_DISPINFO_1 structure.
709 ********************************************************************/
711 NTSTATUS
init_sam_dispinfo_1(TALLOC_CTX
*ctx
, SAM_DISPINFO_1
**sam
,
712 uint32 num_entries
, uint32 start_idx
,
713 struct samr_displayentry
*entries
)
717 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries
));
722 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_1
, num_entries
);
724 return NT_STATUS_NO_MEMORY
;
726 (*sam
)->sam
=TALLOC_ARRAY(ctx
, SAM_ENTRY1
, num_entries
);
727 if ((*sam
)->sam
== NULL
)
728 return NT_STATUS_NO_MEMORY
;
730 (*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR1
, num_entries
);
731 if ((*sam
)->str
== NULL
)
732 return NT_STATUS_NO_MEMORY
;
734 for (i
= 0; i
< num_entries
; i
++) {
735 init_unistr2(&(*sam
)->str
[i
].uni_acct_name
,
736 entries
[i
].account_name
, UNI_FLAGS_NONE
);
737 init_unistr2(&(*sam
)->str
[i
].uni_full_name
,
738 entries
[i
].fullname
, UNI_FLAGS_NONE
);
739 init_unistr2(&(*sam
)->str
[i
].uni_acct_desc
,
740 entries
[i
].description
, UNI_FLAGS_NONE
);
742 init_sam_entry1(&(*sam
)->sam
[i
], start_idx
+i
+1,
743 &(*sam
)->str
[i
].uni_acct_name
,
744 &(*sam
)->str
[i
].uni_full_name
,
745 &(*sam
)->str
[i
].uni_acct_desc
,
746 entries
[i
].rid
, entries
[i
].acct_flags
);
752 /*******************************************************************
753 reads or writes a structure.
754 ********************************************************************/
756 static bool sam_io_sam_dispinfo_1(const char *desc
, SAM_DISPINFO_1
* sam
,
758 prs_struct
*ps
, int depth
)
762 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_1");
768 if (UNMARSHALLING(ps
) && num_entries
> 0) {
770 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY1
, num_entries
)) == NULL
) {
771 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
775 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR1
, num_entries
)) == NULL
) {
776 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
781 for (i
= 0; i
< num_entries
; i
++) {
782 if(!sam_io_sam_entry1("", &sam
->sam
[i
], ps
, depth
))
786 for (i
= 0; i
< num_entries
; i
++) {
787 if(!sam_io_sam_str1("", &sam
->str
[i
],
788 sam
->sam
[i
].hdr_acct_name
.buffer
,
789 sam
->sam
[i
].hdr_user_name
.buffer
,
790 sam
->sam
[i
].hdr_user_desc
.buffer
, ps
, depth
))
797 /*******************************************************************
798 inits a SAM_DISPINFO_2 structure.
799 ********************************************************************/
801 NTSTATUS
init_sam_dispinfo_2(TALLOC_CTX
*ctx
, SAM_DISPINFO_2
**sam
,
802 uint32 num_entries
, uint32 start_idx
,
803 struct samr_displayentry
*entries
)
807 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries
));
812 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_2
, num_entries
);
814 return NT_STATUS_NO_MEMORY
;
816 (*sam
)->sam
= TALLOC_ARRAY(ctx
, SAM_ENTRY2
, num_entries
);
817 if ((*sam
)->sam
== NULL
)
818 return NT_STATUS_NO_MEMORY
;
820 (*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR2
, num_entries
);
821 if ((*sam
)->str
== NULL
)
822 return NT_STATUS_NO_MEMORY
;
824 for (i
= 0; i
< num_entries
; i
++) {
825 init_unistr2(&(*sam
)->str
[i
].uni_srv_name
,
826 entries
[i
].account_name
, UNI_FLAGS_NONE
);
827 init_unistr2(&(*sam
)->str
[i
].uni_srv_desc
,
828 entries
[i
].description
, UNI_FLAGS_NONE
);
830 init_sam_entry2(&(*sam
)->sam
[i
], start_idx
+ i
+ 1,
831 &(*sam
)->str
[i
].uni_srv_name
,
832 &(*sam
)->str
[i
].uni_srv_desc
,
833 entries
[i
].rid
, entries
[i
].acct_flags
);
839 /*******************************************************************
840 reads or writes a structure.
841 ********************************************************************/
843 static bool sam_io_sam_dispinfo_2(const char *desc
, SAM_DISPINFO_2
* sam
,
845 prs_struct
*ps
, int depth
)
852 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_2");
858 if (UNMARSHALLING(ps
) && num_entries
> 0) {
860 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY2
, num_entries
)) == NULL
) {
861 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
865 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR2
, num_entries
)) == NULL
) {
866 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
871 for (i
= 0; i
< num_entries
; i
++) {
872 if(!sam_io_sam_entry2("", &sam
->sam
[i
], ps
, depth
))
876 for (i
= 0; i
< num_entries
; i
++) {
877 if(!sam_io_sam_str2("", &sam
->str
[i
],
878 sam
->sam
[i
].hdr_srv_name
.buffer
,
879 sam
->sam
[i
].hdr_srv_desc
.buffer
, ps
, depth
))
886 /*******************************************************************
887 inits a SAM_DISPINFO_3 structure.
888 ********************************************************************/
890 NTSTATUS
init_sam_dispinfo_3(TALLOC_CTX
*ctx
, SAM_DISPINFO_3
**sam
,
891 uint32 num_entries
, uint32 start_idx
,
892 struct samr_displayentry
*entries
)
896 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries
));
901 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_3
, num_entries
);
903 return NT_STATUS_NO_MEMORY
;
905 if (!((*sam
)->sam
=TALLOC_ARRAY(ctx
, SAM_ENTRY3
, num_entries
)))
906 return NT_STATUS_NO_MEMORY
;
908 if (!((*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR3
, num_entries
)))
909 return NT_STATUS_NO_MEMORY
;
911 for (i
= 0; i
< num_entries
; i
++) {
912 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i
));
914 init_unistr2(&(*sam
)->str
[i
].uni_grp_name
,
915 entries
[i
].account_name
, UNI_FLAGS_NONE
);
916 init_unistr2(&(*sam
)->str
[i
].uni_grp_desc
,
917 entries
[i
].description
, UNI_FLAGS_NONE
);
919 init_sam_entry3(&(*sam
)->sam
[i
], start_idx
+i
+1,
920 &(*sam
)->str
[i
].uni_grp_name
,
921 &(*sam
)->str
[i
].uni_grp_desc
,
928 /*******************************************************************
929 reads or writes a structure.
930 ********************************************************************/
932 static bool sam_io_sam_dispinfo_3(const char *desc
, SAM_DISPINFO_3
* sam
,
934 prs_struct
*ps
, int depth
)
941 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_3");
947 if (UNMARSHALLING(ps
) && num_entries
> 0) {
949 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY3
, num_entries
)) == NULL
) {
950 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
954 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR3
, num_entries
)) == NULL
) {
955 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
960 for (i
= 0; i
< num_entries
; i
++) {
961 if(!sam_io_sam_entry3("", &sam
->sam
[i
], ps
, depth
))
965 for (i
= 0; i
< num_entries
; i
++) {
966 if(!sam_io_sam_str3("", &sam
->str
[i
],
967 sam
->sam
[i
].hdr_grp_name
.buffer
,
968 sam
->sam
[i
].hdr_grp_desc
.buffer
, ps
, depth
))
975 /*******************************************************************
976 inits a SAM_DISPINFO_4 structure.
977 ********************************************************************/
979 NTSTATUS
init_sam_dispinfo_4(TALLOC_CTX
*ctx
, SAM_DISPINFO_4
**sam
,
980 uint32 num_entries
, uint32 start_idx
,
981 struct samr_displayentry
*entries
)
985 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries
));
990 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_4
, num_entries
);
992 return NT_STATUS_NO_MEMORY
;
994 (*sam
)->sam
= TALLOC_ARRAY(ctx
, SAM_ENTRY4
, num_entries
);
995 if ((*sam
)->sam
== NULL
)
996 return NT_STATUS_NO_MEMORY
;
998 (*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR4
, num_entries
);
999 if ((*sam
)->str
== NULL
)
1000 return NT_STATUS_NO_MEMORY
;
1002 for (i
= 0; i
< num_entries
; i
++) {
1003 size_t len_sam_name
= strlen(entries
[i
].account_name
);
1005 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i
));
1007 init_sam_entry4(&(*sam
)->sam
[i
], start_idx
+ i
+ 1,
1010 init_string2(&(*sam
)->str
[i
].acct_name
,
1011 entries
[i
].account_name
, len_sam_name
+1,
1015 return NT_STATUS_OK
;
1018 /*******************************************************************
1019 reads or writes a structure.
1020 ********************************************************************/
1022 static bool sam_io_sam_dispinfo_4(const char *desc
, SAM_DISPINFO_4
* sam
,
1024 prs_struct
*ps
, int depth
)
1031 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_4");
1037 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1039 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY4
, num_entries
)) == NULL
) {
1040 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1044 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR4
, num_entries
)) == NULL
) {
1045 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1050 for (i
= 0; i
< num_entries
; i
++) {
1051 if(!sam_io_sam_entry4("", &sam
->sam
[i
], ps
, depth
))
1055 for (i
= 0; i
< num_entries
; i
++) {
1056 if(!smb_io_string2("acct_name", &sam
->str
[i
].acct_name
,
1057 sam
->sam
[i
].hdr_acct_name
.buffer
, ps
, depth
))
1064 /*******************************************************************
1065 inits a SAM_DISPINFO_5 structure.
1066 ********************************************************************/
1068 NTSTATUS
init_sam_dispinfo_5(TALLOC_CTX
*ctx
, SAM_DISPINFO_5
**sam
,
1069 uint32 num_entries
, uint32 start_idx
,
1070 struct samr_displayentry
*entries
)
1072 uint32 len_sam_name
;
1075 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries
));
1078 return NT_STATUS_OK
;
1080 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_5
, num_entries
);
1082 return NT_STATUS_NO_MEMORY
;
1084 if (!((*sam
)->sam
=TALLOC_ARRAY(ctx
, SAM_ENTRY5
, num_entries
)))
1085 return NT_STATUS_NO_MEMORY
;
1087 if (!((*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR5
, num_entries
)))
1088 return NT_STATUS_NO_MEMORY
;
1090 for (i
= 0; i
< num_entries
; i
++) {
1091 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i
));
1093 len_sam_name
= strlen(entries
[i
].account_name
);
1095 init_sam_entry5(&(*sam
)->sam
[i
], start_idx
+i
+1, len_sam_name
);
1096 init_string2(&(*sam
)->str
[i
].grp_name
, entries
[i
].account_name
,
1097 len_sam_name
+1, len_sam_name
);
1100 return NT_STATUS_OK
;
1103 /*******************************************************************
1104 reads or writes a structure.
1105 ********************************************************************/
1107 static bool sam_io_sam_dispinfo_5(const char *desc
, SAM_DISPINFO_5
* sam
,
1109 prs_struct
*ps
, int depth
)
1116 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_5");
1122 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1124 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY5
, num_entries
)) == NULL
) {
1125 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1129 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR5
, num_entries
)) == NULL
) {
1130 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1135 for (i
= 0; i
< num_entries
; i
++) {
1136 if(!sam_io_sam_entry5("", &sam
->sam
[i
], ps
, depth
))
1140 for (i
= 0; i
< num_entries
; i
++) {
1141 if(!smb_io_string2("grp_name", &sam
->str
[i
].grp_name
,
1142 sam
->sam
[i
].hdr_grp_name
.buffer
, ps
, depth
))
1149 /*******************************************************************
1150 inits a SAMR_R_QUERY_DISPINFO structure.
1151 ********************************************************************/
1153 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO
* r_u
,
1154 uint32 num_entries
, uint32 total_size
, uint32 data_size
,
1155 uint16 switch_level
, SAM_DISPINFO_CTR
* ctr
,
1158 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level
));
1160 r_u
->total_size
= total_size
;
1162 r_u
->data_size
= data_size
;
1164 r_u
->switch_level
= switch_level
;
1165 r_u
->num_entries
= num_entries
;
1168 r_u
->ptr_entries
= 0;
1170 r_u
->ptr_entries
= 1;
1172 r_u
->num_entries2
= num_entries
;
1175 r_u
->status
= status
;
1178 /*******************************************************************
1179 reads or writes a structure.
1180 ********************************************************************/
1182 bool samr_io_r_query_dispinfo(const char *desc
, SAMR_R_QUERY_DISPINFO
* r_u
,
1183 prs_struct
*ps
, int depth
)
1188 prs_debug(ps
, depth
, desc
, "samr_io_r_query_dispinfo");
1194 if(!prs_uint32("total_size ", ps
, depth
, &r_u
->total_size
))
1196 if(!prs_uint32("data_size ", ps
, depth
, &r_u
->data_size
))
1198 if(!prs_uint16("switch_level", ps
, depth
, &r_u
->switch_level
))
1203 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
1205 if(!prs_uint32("ptr_entries ", ps
, depth
, &r_u
->ptr_entries
))
1208 if (r_u
->ptr_entries
==0) {
1211 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
1217 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
1220 switch (r_u
->switch_level
) {
1222 if(!sam_io_sam_dispinfo_1("users", r_u
->ctr
->sam
.info1
,
1223 r_u
->num_entries
, ps
, depth
))
1227 if(!sam_io_sam_dispinfo_2("servers", r_u
->ctr
->sam
.info2
,
1228 r_u
->num_entries
, ps
, depth
))
1232 if(!sam_io_sam_dispinfo_3("groups", r_u
->ctr
->sam
.info3
,
1233 r_u
->num_entries
, ps
, depth
))
1237 if(!sam_io_sam_dispinfo_4("user list",
1238 r_u
->ctr
->sam
.info4
,
1239 r_u
->num_entries
, ps
, depth
))
1243 if(!sam_io_sam_dispinfo_5("group list",
1244 r_u
->ctr
->sam
.info5
,
1245 r_u
->num_entries
, ps
, depth
))
1249 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
1255 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
1261 /*******************************************************************
1262 inits a GROUP_INFO1 structure.
1263 ********************************************************************/
1265 void init_samr_group_info1(GROUP_INFO1
* gr1
,
1266 char *acct_name
, char *acct_desc
,
1269 DEBUG(5, ("init_samr_group_info1\n"));
1271 gr1
->group_attr
= (SE_GROUP_MANDATORY
|SE_GROUP_ENABLED_BY_DEFAULT
); /* why not | SE_GROUP_ENABLED ? */
1272 gr1
->num_members
= num_members
;
1274 init_unistr2(&gr1
->uni_acct_name
, acct_name
, UNI_FLAGS_NONE
);
1275 init_uni_hdr(&gr1
->hdr_acct_name
, &gr1
->uni_acct_name
);
1276 init_unistr2(&gr1
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
1277 init_uni_hdr(&gr1
->hdr_acct_desc
, &gr1
->uni_acct_desc
);
1280 /*******************************************************************
1281 reads or writes a structure.
1282 ********************************************************************/
1284 bool samr_io_group_info1(const char *desc
, GROUP_INFO1
* gr1
,
1285 prs_struct
*ps
, int depth
)
1292 prs_debug(ps
, depth
, desc
, "samr_io_group_info1");
1295 if(!prs_uint16("level", ps
, depth
, &dummy
))
1301 if(!smb_io_unihdr("hdr_acct_name", &gr1
->hdr_acct_name
, ps
, depth
))
1304 if(!prs_uint32("group_attr", ps
, depth
, &gr1
->group_attr
))
1306 if(!prs_uint32("num_members", ps
, depth
, &gr1
->num_members
))
1309 if(!smb_io_unihdr("hdr_acct_desc", &gr1
->hdr_acct_desc
, ps
, depth
))
1312 if(!smb_io_unistr2("uni_acct_name", &gr1
->uni_acct_name
,
1313 gr1
->hdr_acct_name
.buffer
, ps
, depth
))
1316 if(!smb_io_unistr2("uni_acct_desc", &gr1
->uni_acct_desc
,
1317 gr1
->hdr_acct_desc
.buffer
, ps
, depth
))
1323 /*******************************************************************
1324 inits a GROUP_INFO2 structure.
1325 ********************************************************************/
1327 void init_samr_group_info2(GROUP_INFO2
* gr2
, const char *acct_name
)
1329 DEBUG(5, ("init_samr_group_info2\n"));
1332 init_unistr2(&gr2
->uni_acct_name
, acct_name
, UNI_FLAGS_NONE
);
1333 init_uni_hdr(&gr2
->hdr_acct_name
, &gr2
->uni_acct_name
);
1336 /*******************************************************************
1337 reads or writes a structure.
1338 ********************************************************************/
1340 bool samr_io_group_info2(const char *desc
, GROUP_INFO2
*gr2
, prs_struct
*ps
, int depth
)
1345 prs_debug(ps
, depth
, desc
, "samr_io_group_info2");
1348 if(!prs_uint16("hdr_level", ps
, depth
, &gr2
->level
))
1351 if(!smb_io_unihdr("hdr_acct_name", &gr2
->hdr_acct_name
, ps
, depth
))
1353 if(!smb_io_unistr2("uni_acct_name", &gr2
->uni_acct_name
,
1354 gr2
->hdr_acct_name
.buffer
, ps
, depth
))
1360 /*******************************************************************
1361 inits a GROUP_INFO3 structure.
1362 ********************************************************************/
1364 void init_samr_group_info3(GROUP_INFO3
*gr3
)
1366 DEBUG(5, ("init_samr_group_info3\n"));
1368 gr3
->group_attr
= (SE_GROUP_MANDATORY
|SE_GROUP_ENABLED_BY_DEFAULT
); /* why not | SE_GROUP_ENABLED ? */
1371 /*******************************************************************
1372 reads or writes a structure.
1373 ********************************************************************/
1375 bool samr_io_group_info3(const char *desc
, GROUP_INFO3
*gr3
, prs_struct
*ps
, int depth
)
1380 prs_debug(ps
, depth
, desc
, "samr_io_group_info3");
1386 if(!prs_uint32("group_attr", ps
, depth
, &gr3
->group_attr
))
1392 /*******************************************************************
1393 inits a GROUP_INFO4 structure.
1394 ********************************************************************/
1396 void init_samr_group_info4(GROUP_INFO4
* gr4
, const char *acct_desc
)
1398 DEBUG(5, ("init_samr_group_info4\n"));
1401 init_unistr2(&gr4
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
1402 init_uni_hdr(&gr4
->hdr_acct_desc
, &gr4
->uni_acct_desc
);
1405 /*******************************************************************
1406 reads or writes a structure.
1407 ********************************************************************/
1409 bool samr_io_group_info4(const char *desc
, GROUP_INFO4
* gr4
,
1410 prs_struct
*ps
, int depth
)
1415 prs_debug(ps
, depth
, desc
, "samr_io_group_info4");
1418 if(!prs_uint16("hdr_level", ps
, depth
, &gr4
->level
))
1420 if(!smb_io_unihdr("hdr_acct_desc", &gr4
->hdr_acct_desc
, ps
, depth
))
1422 if(!smb_io_unistr2("uni_acct_desc", &gr4
->uni_acct_desc
,
1423 gr4
->hdr_acct_desc
.buffer
, ps
, depth
))
1429 /*******************************************************************
1430 inits a GROUP_INFO5 structure.
1431 ********************************************************************/
1433 void init_samr_group_info5(GROUP_INFO5
* gr5
,
1434 char *acct_name
, char *acct_desc
,
1437 DEBUG(5, ("init_samr_group_info5\n"));
1439 gr5
->group_attr
= (SE_GROUP_MANDATORY
|SE_GROUP_ENABLED_BY_DEFAULT
); /* why not | SE_GROUP_ENABLED ? */
1440 gr5
->num_members
= num_members
;
1442 init_unistr2(&gr5
->uni_acct_name
, acct_name
, UNI_FLAGS_NONE
);
1443 init_uni_hdr(&gr5
->hdr_acct_name
, &gr5
->uni_acct_name
);
1444 init_unistr2(&gr5
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
1445 init_uni_hdr(&gr5
->hdr_acct_desc
, &gr5
->uni_acct_desc
);
1448 /*******************************************************************
1449 reads or writes a structure.
1450 ********************************************************************/
1452 bool samr_io_group_info5(const char *desc
, GROUP_INFO5
* gr5
,
1453 prs_struct
*ps
, int depth
)
1460 prs_debug(ps
, depth
, desc
, "samr_io_group_info5");
1463 if(!prs_uint16("level", ps
, depth
, &dummy
))
1469 if(!smb_io_unihdr("hdr_acct_name", &gr5
->hdr_acct_name
, ps
, depth
))
1472 if(!prs_uint32("group_attr", ps
, depth
, &gr5
->group_attr
))
1474 if(!prs_uint32("num_members", ps
, depth
, &gr5
->num_members
))
1477 if(!smb_io_unihdr("hdr_acct_desc", &gr5
->hdr_acct_desc
, ps
, depth
))
1480 if(!smb_io_unistr2("uni_acct_name", &gr5
->uni_acct_name
,
1481 gr5
->hdr_acct_name
.buffer
, ps
, depth
))
1484 if(!smb_io_unistr2("uni_acct_desc", &gr5
->uni_acct_desc
,
1485 gr5
->hdr_acct_desc
.buffer
, ps
, depth
))
1492 /*******************************************************************
1493 reads or writes a structure.
1494 ********************************************************************/
1496 static bool samr_group_info_ctr(const char *desc
, GROUP_INFO_CTR
**ctr
,
1497 prs_struct
*ps
, int depth
)
1499 if (UNMARSHALLING(ps
))
1500 *ctr
= PRS_ALLOC_MEM(ps
,GROUP_INFO_CTR
,1);
1505 prs_debug(ps
, depth
, desc
, "samr_group_info_ctr");
1508 if(!prs_uint16("switch_value1", ps
, depth
, &(*ctr
)->switch_value1
))
1511 switch ((*ctr
)->switch_value1
) {
1513 if(!samr_io_group_info1("group_info1", &(*ctr
)->group
.info1
, ps
, depth
))
1517 if(!samr_io_group_info2("group_info2", &(*ctr
)->group
.info2
, ps
, depth
))
1521 if(!samr_io_group_info3("group_info3", &(*ctr
)->group
.info3
, ps
, depth
))
1525 if(!samr_io_group_info4("group_info4", &(*ctr
)->group
.info4
, ps
, depth
))
1529 if(!samr_io_group_info5("group_info5", &(*ctr
)->group
.info5
, ps
, depth
))
1533 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
1540 /*******************************************************************
1541 inits a SAMR_Q_QUERY_GROUPINFO structure.
1542 ********************************************************************/
1544 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO
* q_e
,
1545 POLICY_HND
*pol
, uint16 switch_level
)
1547 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
1551 q_e
->switch_level
= switch_level
;
1554 /*******************************************************************
1555 reads or writes a structure.
1556 ********************************************************************/
1558 bool samr_io_q_query_groupinfo(const char *desc
, SAMR_Q_QUERY_GROUPINFO
* q_e
,
1559 prs_struct
*ps
, int depth
)
1564 prs_debug(ps
, depth
, desc
, "samr_io_q_query_groupinfo");
1570 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
1573 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
1579 /*******************************************************************
1580 inits a SAMR_R_QUERY_GROUPINFO structure.
1581 ********************************************************************/
1583 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO
* r_u
,
1584 GROUP_INFO_CTR
* ctr
, NTSTATUS status
)
1586 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
1588 r_u
->ptr
= (NT_STATUS_IS_OK(status
) && ctr
!= NULL
) ? 1 : 0;
1590 r_u
->status
= status
;
1593 /*******************************************************************
1594 reads or writes a structure.
1595 ********************************************************************/
1597 bool samr_io_r_query_groupinfo(const char *desc
, SAMR_R_QUERY_GROUPINFO
* r_u
,
1598 prs_struct
*ps
, int depth
)
1603 prs_debug(ps
, depth
, desc
, "samr_io_r_query_groupinfo");
1609 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
1612 if (r_u
->ptr
!= 0) {
1613 if(!samr_group_info_ctr("ctr", &r_u
->ctr
, ps
, depth
))
1619 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
1625 /*******************************************************************
1626 inits a SAMR_Q_QUERY_USERGROUPS structure.
1627 ********************************************************************/
1629 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS
* q_u
,
1632 DEBUG(5, ("init_samr_q_query_usergroups\n"));
1637 /*******************************************************************
1638 reads or writes a structure.
1639 ********************************************************************/
1641 bool samr_io_q_query_usergroups(const char *desc
, SAMR_Q_QUERY_USERGROUPS
* q_u
,
1642 prs_struct
*ps
, int depth
)
1647 prs_debug(ps
, depth
, desc
, "samr_io_q_query_usergroups");
1653 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
1659 /*******************************************************************
1660 inits a SAMR_R_QUERY_USERGROUPS structure.
1661 ********************************************************************/
1663 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS
* r_u
,
1664 uint32 num_gids
, DOM_GID
* gid
,
1667 DEBUG(5, ("init_samr_r_query_usergroups\n"));
1669 if (NT_STATUS_IS_OK(status
)) {
1671 r_u
->num_entries
= num_gids
;
1672 r_u
->ptr_1
= (num_gids
!= 0) ? 1 : 0;
1673 r_u
->num_entries2
= num_gids
;
1678 r_u
->num_entries
= 0;
1683 r_u
->status
= status
;
1686 /*******************************************************************
1687 reads or writes a structure.
1688 ********************************************************************/
1690 bool samr_io_gids(const char *desc
, uint32
*num_gids
, DOM_GID
** gid
,
1691 prs_struct
*ps
, int depth
)
1697 prs_debug(ps
, depth
, desc
, "samr_io_gids");
1703 if(!prs_uint32("num_gids", ps
, depth
, num_gids
))
1706 if ((*num_gids
) != 0) {
1707 if (UNMARSHALLING(ps
)) {
1708 (*gid
) = PRS_ALLOC_MEM(ps
,DOM_GID
,*num_gids
);
1711 if ((*gid
) == NULL
) {
1715 for (i
= 0; i
< (*num_gids
); i
++) {
1716 if(!smb_io_gid("gids", &(*gid
)[i
], ps
, depth
))
1724 /*******************************************************************
1725 reads or writes a structure.
1726 ********************************************************************/
1728 bool samr_io_r_query_usergroups(const char *desc
, SAMR_R_QUERY_USERGROUPS
* r_u
,
1729 prs_struct
*ps
, int depth
)
1734 prs_debug(ps
, depth
, desc
, "samr_io_r_query_usergroups");
1740 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
1743 if (r_u
->ptr_0
!= 0) {
1744 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
1746 if(!prs_uint32("ptr_1 ", ps
, depth
, &r_u
->ptr_1
))
1749 if (r_u
->num_entries
!= 0 && r_u
->ptr_1
!= 0) {
1750 if(!samr_io_gids("gids", &r_u
->num_entries2
, &r_u
->gid
, ps
, depth
))
1757 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
1763 /*******************************************************************
1764 inits a SAMR_Q_ENUM_DOMAINS structure.
1765 ********************************************************************/
1767 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS
* q_e
,
1769 uint32 start_idx
, uint32 size
)
1771 DEBUG(5, ("init_samr_q_enum_domains\n"));
1775 q_e
->start_idx
= start_idx
;
1776 q_e
->max_size
= size
;
1779 /*******************************************************************
1780 reads or writes a structure.
1781 ********************************************************************/
1783 bool samr_io_q_enum_domains(const char *desc
, SAMR_Q_ENUM_DOMAINS
* q_e
,
1784 prs_struct
*ps
, int depth
)
1789 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_domains");
1795 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
1798 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
1800 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1806 /*******************************************************************
1807 inits a SAMR_R_ENUM_DOMAINS structure.
1808 ********************************************************************/
1810 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS
* r_u
,
1811 uint32 next_idx
, uint32 num_sam_entries
)
1813 DEBUG(5, ("init_samr_r_enum_domains\n"));
1815 r_u
->next_idx
= next_idx
;
1817 if (num_sam_entries
!= 0) {
1818 r_u
->ptr_entries1
= 1;
1819 r_u
->ptr_entries2
= 1;
1820 r_u
->num_entries2
= num_sam_entries
;
1821 r_u
->num_entries3
= num_sam_entries
;
1823 r_u
->num_entries4
= num_sam_entries
;
1825 r_u
->ptr_entries1
= 0;
1826 r_u
->num_entries2
= num_sam_entries
;
1827 r_u
->ptr_entries2
= 1;
1831 /*******************************************************************
1832 reads or writes a structure.
1833 ********************************************************************/
1835 bool samr_io_r_enum_domains(const char *desc
, SAMR_R_ENUM_DOMAINS
* r_u
,
1836 prs_struct
*ps
, int depth
)
1843 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_domains");
1849 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
1851 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
1854 if (r_u
->ptr_entries1
!= 0) {
1855 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
1857 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
1859 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
1862 if (UNMARSHALLING(ps
) && r_u
->num_entries2
) {
1863 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
,r_u
->num_entries2
);
1864 r_u
->uni_dom_name
= PRS_ALLOC_MEM(ps
,UNISTR2
,r_u
->num_entries2
);
1867 if ((r_u
->sam
== NULL
|| r_u
->uni_dom_name
== NULL
) && r_u
->num_entries2
!= 0) {
1868 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
1869 r_u
->num_entries4
= 0;
1870 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
1874 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1876 slprintf(tmp
, sizeof(tmp
) - 1, "dom[%d]", i
);
1877 if(!sam_io_sam_entry(tmp
, &r_u
->sam
[i
], ps
, depth
))
1881 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1883 slprintf(tmp
, sizeof(tmp
) - 1, "dom[%d]", i
);
1884 if(!smb_io_unistr2(tmp
, &r_u
->uni_dom_name
[i
],
1885 r_u
->sam
[i
].hdr_name
.buffer
, ps
,
1894 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
1896 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
1902 /*******************************************************************
1903 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
1904 ********************************************************************/
1906 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS
* q_e
,
1908 uint32 start_idx
, uint32 size
)
1910 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
1914 q_e
->start_idx
= start_idx
;
1915 q_e
->max_size
= size
;
1918 /*******************************************************************
1919 reads or writes a structure.
1920 ********************************************************************/
1922 bool samr_io_q_enum_dom_groups(const char *desc
, SAMR_Q_ENUM_DOM_GROUPS
* q_e
,
1923 prs_struct
*ps
, int depth
)
1928 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_groups");
1934 if(!smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
))
1937 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
1939 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1945 /*******************************************************************
1946 inits a SAMR_R_ENUM_DOM_GROUPS structure.
1947 ********************************************************************/
1949 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS
* r_u
,
1950 uint32 next_idx
, uint32 num_sam_entries
)
1952 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
1954 r_u
->next_idx
= next_idx
;
1956 if (num_sam_entries
!= 0) {
1957 r_u
->ptr_entries1
= 1;
1958 r_u
->ptr_entries2
= 1;
1959 r_u
->num_entries2
= num_sam_entries
;
1960 r_u
->num_entries3
= num_sam_entries
;
1962 r_u
->num_entries4
= num_sam_entries
;
1964 r_u
->ptr_entries1
= 0;
1965 r_u
->num_entries2
= num_sam_entries
;
1966 r_u
->ptr_entries2
= 1;
1970 /*******************************************************************
1971 reads or writes a structure.
1972 ********************************************************************/
1974 bool samr_io_r_enum_dom_groups(const char *desc
, SAMR_R_ENUM_DOM_GROUPS
* r_u
,
1975 prs_struct
*ps
, int depth
)
1982 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_groups");
1988 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
1990 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
1993 if (r_u
->ptr_entries1
!= 0) {
1994 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
1996 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
1998 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
2001 if (UNMARSHALLING(ps
) && r_u
->num_entries2
) {
2002 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
,r_u
->num_entries2
);
2003 r_u
->uni_grp_name
= PRS_ALLOC_MEM(ps
,UNISTR2
,r_u
->num_entries2
);
2006 if ((r_u
->sam
== NULL
|| r_u
->uni_grp_name
== NULL
) && r_u
->num_entries2
!= 0) {
2008 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
2009 r_u
->num_entries4
= 0;
2010 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
2014 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
2015 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
2019 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
2020 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
],
2021 r_u
->sam
[i
].hdr_name
.buffer
, ps
, depth
))
2028 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
2030 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2036 /*******************************************************************
2037 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
2038 ********************************************************************/
2040 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES
* q_e
,
2041 POLICY_HND
*pol
, uint32 start_idx
,
2044 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
2048 q_e
->start_idx
= start_idx
;
2049 q_e
->max_size
= size
;
2053 /*******************************************************************
2054 reads or writes a structure.
2055 ********************************************************************/
2057 bool samr_io_q_enum_dom_aliases(const char *desc
, SAMR_Q_ENUM_DOM_ALIASES
* q_e
,
2058 prs_struct
*ps
, int depth
)
2063 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_aliases");
2069 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2072 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
2074 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
2080 /*******************************************************************
2081 inits a SAMR_R_ENUM_DOM_ALIASES structure.
2082 ********************************************************************/
2084 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES
*r_u
, uint32 next_idx
, uint32 num_sam_entries
)
2086 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
2088 r_u
->next_idx
= next_idx
;
2090 if (num_sam_entries
!= 0) {
2091 r_u
->ptr_entries1
= 1;
2092 r_u
->ptr_entries2
= 1;
2093 r_u
->num_entries2
= num_sam_entries
;
2094 r_u
->num_entries3
= num_sam_entries
;
2096 r_u
->num_entries4
= num_sam_entries
;
2098 r_u
->ptr_entries1
= 0;
2099 r_u
->num_entries2
= num_sam_entries
;
2100 r_u
->ptr_entries2
= 1;
2104 /*******************************************************************
2105 reads or writes a structure.
2106 ********************************************************************/
2108 bool samr_io_r_enum_dom_aliases(const char *desc
, SAMR_R_ENUM_DOM_ALIASES
* r_u
,
2109 prs_struct
*ps
, int depth
)
2116 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_aliases");
2122 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
2124 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
2127 if (r_u
->ptr_entries1
!= 0) {
2128 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
2130 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
2132 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
2135 if (UNMARSHALLING(ps
) && (r_u
->num_entries2
> 0)) {
2136 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
,r_u
->num_entries2
);
2137 r_u
->uni_grp_name
= PRS_ALLOC_MEM(ps
,UNISTR2
,r_u
->num_entries2
);
2140 if (r_u
->num_entries2
!= 0 &&
2141 (r_u
->sam
== NULL
|| r_u
->uni_grp_name
== NULL
)) {
2142 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
2143 r_u
->num_entries4
= 0;
2144 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
2148 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
2149 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
2153 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
2154 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
],
2155 r_u
->sam
[i
].hdr_name
.buffer
, ps
,
2163 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
2165 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2171 /*******************************************************************
2172 inits a samr_AliasInfoAll structure.
2173 ********************************************************************/
2175 void init_samr_alias_info1(struct samr_AliasInfoAll
*r
,
2177 uint32_t num_members
,
2178 const char *description
)
2180 DEBUG(5, ("init_samr_alias_info1\n"));
2182 init_lsa_String(&r
->name
, name
);
2183 r
->num_members
= num_members
;
2184 init_lsa_String(&r
->description
, description
);
2187 /*******************************************************************
2188 inits a lsa_String structure.
2189 ********************************************************************/
2191 void init_samr_alias_info3(struct lsa_String
*r
,
2192 const char *description
)
2194 DEBUG(5, ("init_samr_alias_info3\n"));
2196 init_lsa_String(r
, description
);
2199 /*******************************************************************
2200 inits a SAMR_Q_LOOKUP_RIDS structure.
2201 ********************************************************************/
2203 void init_samr_q_lookup_rids(TALLOC_CTX
*ctx
, SAMR_Q_LOOKUP_RIDS
* q_u
,
2204 POLICY_HND
*pol
, uint32 flags
,
2205 uint32 num_rids
, uint32
*rid
)
2207 DEBUG(5, ("init_samr_q_lookup_rids\n"));
2211 q_u
->num_rids1
= num_rids
;
2214 q_u
->num_rids2
= num_rids
;
2216 q_u
->rid
= TALLOC_ZERO_ARRAY(ctx
, uint32
, num_rids
);
2220 if (q_u
->rid
== NULL
) {
2224 memcpy(q_u
->rid
, rid
, num_rids
* sizeof(q_u
->rid
[0]));
2228 /*******************************************************************
2229 reads or writes a structure.
2230 ********************************************************************/
2232 bool samr_io_q_lookup_rids(const char *desc
, SAMR_Q_LOOKUP_RIDS
* q_u
,
2233 prs_struct
*ps
, int depth
)
2241 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_rids");
2244 if (UNMARSHALLING(ps
))
2250 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
2253 if(!prs_uint32("num_rids1", ps
, depth
, &q_u
->num_rids1
))
2255 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
2257 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
2259 if(!prs_uint32("num_rids2", ps
, depth
, &q_u
->num_rids2
))
2262 if (UNMARSHALLING(ps
) && (q_u
->num_rids2
!= 0)) {
2263 q_u
->rid
= PRS_ALLOC_MEM(ps
, uint32
, q_u
->num_rids2
);
2264 if (q_u
->rid
== NULL
)
2268 for (i
= 0; i
< q_u
->num_rids2
; i
++) {
2269 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
2270 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->rid
[i
]))
2277 /*******************************************************************
2278 inits a SAMR_R_LOOKUP_RIDS structure.
2279 ********************************************************************/
2281 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS
* r_u
,
2282 uint32 num_names
, UNIHDR
* hdr_name
,
2283 UNISTR2
*uni_name
, uint32
*type
)
2285 DEBUG(5, ("init_samr_r_lookup_rids\n"));
2287 r_u
->hdr_name
= NULL
;
2288 r_u
->uni_name
= NULL
;
2291 if (num_names
!= 0) {
2292 r_u
->num_names1
= num_names
;
2294 r_u
->num_names2
= num_names
;
2296 r_u
->num_types1
= num_names
;
2298 r_u
->num_types2
= num_names
;
2300 r_u
->hdr_name
= hdr_name
;
2301 r_u
->uni_name
= uni_name
;
2304 r_u
->num_names1
= num_names
;
2306 r_u
->num_names2
= num_names
;
2308 r_u
->num_types1
= num_names
;
2310 r_u
->num_types2
= num_names
;
2314 /*******************************************************************
2315 reads or writes a structure.
2316 ********************************************************************/
2318 bool samr_io_r_lookup_rids(const char *desc
, SAMR_R_LOOKUP_RIDS
* r_u
,
2319 prs_struct
*ps
, int depth
)
2326 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_rids");
2332 if(!prs_uint32("num_names1", ps
, depth
, &r_u
->num_names1
))
2334 if(!prs_uint32("ptr_names ", ps
, depth
, &r_u
->ptr_names
))
2337 if (r_u
->ptr_names
!= 0) {
2339 if(!prs_uint32("num_names2", ps
, depth
, &r_u
->num_names2
))
2343 if (UNMARSHALLING(ps
) && (r_u
->num_names2
!= 0)) {
2344 r_u
->hdr_name
= PRS_ALLOC_MEM(ps
, UNIHDR
, r_u
->num_names2
);
2345 if (r_u
->hdr_name
== NULL
)
2348 r_u
->uni_name
= PRS_ALLOC_MEM(ps
, UNISTR2
, r_u
->num_names2
);
2349 if (r_u
->uni_name
== NULL
)
2353 for (i
= 0; i
< r_u
->num_names2
; i
++) {
2354 slprintf(tmp
, sizeof(tmp
) - 1, "hdr[%02d] ", i
);
2355 if(!smb_io_unihdr("", &r_u
->hdr_name
[i
], ps
, depth
))
2358 for (i
= 0; i
< r_u
->num_names2
; i
++) {
2359 slprintf(tmp
, sizeof(tmp
) - 1, "str[%02d] ", i
);
2360 if(!smb_io_unistr2("", &r_u
->uni_name
[i
], r_u
->hdr_name
[i
].buffer
, ps
, depth
))
2368 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
2370 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
2373 if (r_u
->ptr_types
!= 0) {
2375 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
2378 if (UNMARSHALLING(ps
) && (r_u
->num_types2
!= 0)) {
2379 r_u
->type
= PRS_ALLOC_MEM(ps
, uint32
, r_u
->num_types2
);
2380 if (r_u
->type
== NULL
)
2384 for (i
= 0; i
< r_u
->num_types2
; i
++) {
2385 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
2386 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->type
[i
]))
2391 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2397 /*******************************************************************
2398 inits a SAMR_Q_LOOKUP_NAMES structure.
2399 ********************************************************************/
2401 NTSTATUS
init_samr_q_lookup_names(TALLOC_CTX
*ctx
, SAMR_Q_LOOKUP_NAMES
* q_u
,
2402 POLICY_HND
*pol
, uint32 flags
,
2403 uint32 num_names
, const char **name
)
2407 DEBUG(5, ("init_samr_q_lookup_names\n"));
2411 q_u
->num_names1
= num_names
;
2414 q_u
->num_names2
= num_names
;
2417 if (!(q_u
->hdr_name
= TALLOC_ZERO_ARRAY(ctx
, UNIHDR
, num_names
)))
2418 return NT_STATUS_NO_MEMORY
;
2420 if (!(q_u
->uni_name
= TALLOC_ZERO_ARRAY(ctx
, UNISTR2
, num_names
)))
2421 return NT_STATUS_NO_MEMORY
;
2423 q_u
->hdr_name
= NULL
;
2424 q_u
->uni_name
= NULL
;
2427 for (i
= 0; i
< num_names
; i
++) {
2428 init_unistr2(&q_u
->uni_name
[i
], name
[i
], UNI_FLAGS_NONE
); /* unicode string for machine account */
2429 init_uni_hdr(&q_u
->hdr_name
[i
], &q_u
->uni_name
[i
]); /* unicode header for user_name */
2432 return NT_STATUS_OK
;
2435 /*******************************************************************
2436 reads or writes a structure.
2437 ********************************************************************/
2439 bool samr_io_q_lookup_names(const char *desc
, SAMR_Q_LOOKUP_NAMES
* q_u
,
2440 prs_struct
*ps
, int depth
)
2447 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_names");
2450 if (UNMARSHALLING(ps
))
2456 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
2459 if(!prs_uint32("num_names1", ps
, depth
, &q_u
->num_names1
))
2461 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
2463 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
2465 if(!prs_uint32("num_names2", ps
, depth
, &q_u
->num_names2
))
2468 if (UNMARSHALLING(ps
) && (q_u
->num_names2
!= 0)) {
2469 q_u
->hdr_name
= PRS_ALLOC_MEM(ps
, UNIHDR
, q_u
->num_names2
);
2470 q_u
->uni_name
= PRS_ALLOC_MEM(ps
, UNISTR2
, q_u
->num_names2
);
2471 if (!q_u
->hdr_name
|| !q_u
->uni_name
)
2475 for (i
= 0; i
< q_u
->num_names2
; i
++) {
2476 if(!smb_io_unihdr("", &q_u
->hdr_name
[i
], ps
, depth
))
2480 for (i
= 0; i
< q_u
->num_names2
; i
++) {
2481 if(!smb_io_unistr2("", &q_u
->uni_name
[i
], q_u
->hdr_name
[i
].buffer
, ps
, depth
))
2488 /*******************************************************************
2489 inits a SAMR_R_LOOKUP_NAMES structure.
2490 ********************************************************************/
2492 NTSTATUS
init_samr_r_lookup_names(TALLOC_CTX
*ctx
, SAMR_R_LOOKUP_NAMES
* r_u
,
2494 uint32
*rid
, enum lsa_SidType
*type
,
2497 DEBUG(5, ("init_samr_r_lookup_names\n"));
2499 if (NT_STATUS_IS_OK(status
) && (num_rids
!= 0)) {
2502 r_u
->num_types1
= num_rids
;
2504 r_u
->num_types2
= num_rids
;
2506 r_u
->num_rids1
= num_rids
;
2508 r_u
->num_rids2
= num_rids
;
2510 if (!(r_u
->rids
= TALLOC_ZERO_ARRAY(ctx
, uint32
, num_rids
)))
2511 return NT_STATUS_NO_MEMORY
;
2512 if (!(r_u
->types
= TALLOC_ZERO_ARRAY(ctx
, uint32
, num_rids
)))
2513 return NT_STATUS_NO_MEMORY
;
2515 for (i
= 0; i
< num_rids
; i
++) {
2516 r_u
->rids
[i
] = rid
[i
];
2517 r_u
->types
[i
] = type
[i
];
2521 r_u
->num_types1
= 0;
2523 r_u
->num_types2
= 0;
2533 r_u
->status
= status
;
2535 return NT_STATUS_OK
;
2538 /*******************************************************************
2539 reads or writes a structure.
2540 ********************************************************************/
2542 bool samr_io_r_lookup_names(const char *desc
, SAMR_R_LOOKUP_NAMES
* r_u
,
2543 prs_struct
*ps
, int depth
)
2551 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_names");
2554 if (UNMARSHALLING(ps
))
2560 if(!prs_uint32("num_rids1", ps
, depth
, &r_u
->num_rids1
))
2562 if(!prs_uint32("ptr_rids ", ps
, depth
, &r_u
->ptr_rids
))
2565 if (r_u
->ptr_rids
!= 0) {
2566 if(!prs_uint32("num_rids2", ps
, depth
, &r_u
->num_rids2
))
2569 if (r_u
->num_rids2
!= r_u
->num_rids1
) {
2574 if (UNMARSHALLING(ps
) && r_u
->num_rids2
) {
2575 r_u
->rids
= PRS_ALLOC_MEM(ps
, uint32
, r_u
->num_rids2
);
2578 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
2583 for (i
= 0; i
< r_u
->num_rids2
; i
++) {
2584 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
2585 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->rids
[i
]))
2590 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
2592 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
2595 if (r_u
->ptr_types
!= 0) {
2596 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
2599 if (r_u
->num_types2
!= r_u
->num_types1
) {
2604 if (UNMARSHALLING(ps
) && r_u
->num_types2
) {
2605 r_u
->types
= PRS_ALLOC_MEM(ps
, uint32
, r_u
->num_types2
);
2608 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
2613 for (i
= 0; i
< r_u
->num_types2
; i
++) {
2614 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
2615 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->types
[i
]))
2620 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2626 /*******************************************************************
2627 inits a SAMR_Q_QUERY_USERINFO structure.
2628 ********************************************************************/
2630 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO
* q_u
,
2631 const POLICY_HND
*hnd
, uint16 switch_value
)
2633 DEBUG(5, ("init_samr_q_query_userinfo\n"));
2636 q_u
->switch_value
= switch_value
;
2639 /*******************************************************************
2640 reads or writes a structure.
2641 ********************************************************************/
2643 bool samr_io_q_query_userinfo(const char *desc
, SAMR_Q_QUERY_USERINFO
* q_u
,
2644 prs_struct
*ps
, int depth
)
2649 prs_debug(ps
, depth
, desc
, "samr_io_q_query_userinfo");
2655 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
2658 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
)) /* 0x0015 or 0x0011 */
2664 /*******************************************************************
2665 reads or writes a LOGON_HRS structure.
2666 ********************************************************************/
2668 static bool sam_io_logon_hrs(const char *desc
, LOGON_HRS
* hrs
,
2669 prs_struct
*ps
, int depth
)
2674 prs_debug(ps
, depth
, desc
, "sam_io_logon_hrs");
2680 if(!prs_uint32("maxlen", ps
, depth
, &hrs
->max_len
))
2683 if(!prs_uint32("offset", ps
, depth
, &hrs
->offset
))
2686 if(!prs_uint32("len ", ps
, depth
, &hrs
->len
))
2689 if (hrs
->len
> sizeof(hrs
->hours
)) {
2690 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs
->len
));
2691 hrs
->len
= sizeof(hrs
->hours
);
2694 if(!prs_uint8s(False
, "hours", ps
, depth
, hrs
->hours
, hrs
->len
))
2700 /*******************************************************************
2701 inits a SAM_USER_INFO_18 structure.
2702 ********************************************************************/
2704 void init_sam_user_info18(SAM_USER_INFO_18
* usr
,
2705 const uint8 lm_pwd
[16], const uint8 nt_pwd
[16])
2707 DEBUG(5, ("init_sam_user_info18\n"));
2709 usr
->lm_pwd_active
=
2710 memcpy(usr
->lm_pwd
, lm_pwd
, sizeof(usr
->lm_pwd
)) ? 1 : 0;
2711 usr
->nt_pwd_active
=
2712 memcpy(usr
->nt_pwd
, nt_pwd
, sizeof(usr
->nt_pwd
)) ? 1 : 0;
2715 /*******************************************************************
2716 reads or writes a structure.
2717 ********************************************************************/
2719 static bool sam_io_user_info18(const char *desc
, SAM_USER_INFO_18
* u
,
2720 prs_struct
*ps
, int depth
)
2725 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info18");
2731 if(!prs_uint8s(False
, "lm_pwd", ps
, depth
, u
->lm_pwd
, sizeof(u
->lm_pwd
)))
2733 if(!prs_uint8s(False
, "nt_pwd", ps
, depth
, u
->nt_pwd
, sizeof(u
->nt_pwd
)))
2736 if(!prs_uint8("lm_pwd_active", ps
, depth
, &u
->lm_pwd_active
))
2738 if(!prs_uint8("nt_pwd_active", ps
, depth
, &u
->nt_pwd_active
))
2744 /*******************************************************************
2745 inits a SAM_USER_INFO_7 structure.
2746 ********************************************************************/
2748 void init_sam_user_info7(SAM_USER_INFO_7
* usr
, const char *name
)
2750 DEBUG(5, ("init_sam_user_info7\n"));
2752 init_unistr2(&usr
->uni_name
, name
, UNI_FLAGS_NONE
); /* unicode string for name */
2753 init_uni_hdr(&usr
->hdr_name
, &usr
->uni_name
); /* unicode header for name */
2757 /*******************************************************************
2758 reads or writes a structure.
2759 ********************************************************************/
2761 static bool sam_io_user_info7(const char *desc
, SAM_USER_INFO_7
* usr
,
2762 prs_struct
*ps
, int depth
)
2767 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info7");
2773 if(!smb_io_unihdr("unihdr", &usr
->hdr_name
, ps
, depth
))
2776 if(!smb_io_unistr2("unistr2", &usr
->uni_name
, True
, ps
, depth
))
2782 /*******************************************************************
2783 inits a SAM_USER_INFO_9 structure.
2784 ********************************************************************/
2786 void init_sam_user_info9(SAM_USER_INFO_9
* usr
, uint32 rid_group
)
2788 DEBUG(5, ("init_sam_user_info9\n"));
2790 usr
->rid_group
= rid_group
;
2793 /*******************************************************************
2794 reads or writes a structure.
2795 ********************************************************************/
2797 static bool sam_io_user_info9(const char *desc
, SAM_USER_INFO_9
* usr
,
2798 prs_struct
*ps
, int depth
)
2803 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info9");
2809 if(!prs_uint32("rid_group", ps
, depth
, &usr
->rid_group
))
2815 /*******************************************************************
2816 inits a SAM_USER_INFO_16 structure.
2817 ********************************************************************/
2819 void init_sam_user_info16(SAM_USER_INFO_16
* usr
, uint32 acb_info
)
2821 DEBUG(5, ("init_sam_user_info16\n"));
2823 usr
->acb_info
= acb_info
;
2826 /*******************************************************************
2827 reads or writes a structure.
2828 ********************************************************************/
2830 static bool sam_io_user_info16(const char *desc
, SAM_USER_INFO_16
* usr
,
2831 prs_struct
*ps
, int depth
)
2836 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info16");
2842 if(!prs_uint32("acb_info", ps
, depth
, &usr
->acb_info
))
2848 /*******************************************************************
2849 inits a SAM_USER_INFO_17 structure.
2850 ********************************************************************/
2852 void init_sam_user_info17(SAM_USER_INFO_17
* usr
,
2855 uint32 rid_user
, uint32 rid_group
, uint16 acct_ctrl
)
2857 DEBUG(5, ("init_sam_user_info17\n"));
2859 memcpy(&usr
->expiry
, expiry
, sizeof(usr
->expiry
)); /* expiry time or something? */
2860 ZERO_STRUCT(usr
->padding_1
); /* 0 - padding 24 bytes */
2862 usr
->padding_2
= 0; /* 0 - padding 4 bytes */
2864 usr
->ptr_1
= 1; /* pointer */
2865 ZERO_STRUCT(usr
->padding_3
); /* 0 - padding 32 bytes */
2866 usr
->padding_4
= 0; /* 0 - padding 4 bytes */
2868 usr
->ptr_2
= 1; /* pointer */
2869 usr
->padding_5
= 0; /* 0 - padding 4 bytes */
2871 usr
->ptr_3
= 1; /* pointer */
2872 ZERO_STRUCT(usr
->padding_6
); /* 0 - padding 32 bytes */
2874 usr
->rid_user
= rid_user
;
2875 usr
->rid_group
= rid_group
;
2877 usr
->acct_ctrl
= acct_ctrl
;
2878 usr
->unknown_3
= 0x0000;
2880 usr
->unknown_4
= 0x003f; /* 0x003f - 16 bit unknown */
2881 usr
->unknown_5
= 0x003c; /* 0x003c - 16 bit unknown */
2883 ZERO_STRUCT(usr
->padding_7
); /* 0 - padding 16 bytes */
2884 usr
->padding_8
= 0; /* 0 - padding 4 bytes */
2886 init_unistr2(&usr
->uni_mach_acct
, mach_acct
, UNI_FLAGS_NONE
); /* unicode string for machine account */
2887 init_uni_hdr(&usr
->hdr_mach_acct
, &usr
->uni_mach_acct
); /* unicode header for machine account */
2890 /*******************************************************************
2891 reads or writes a structure.
2892 ********************************************************************/
2894 static bool sam_io_user_info17(const char *desc
, SAM_USER_INFO_17
* usr
,
2895 prs_struct
*ps
, int depth
)
2900 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_17");
2906 if(!prs_uint8s(False
, "padding_0", ps
, depth
, usr
->padding_0
, sizeof(usr
->padding_0
)))
2909 if(!smb_io_time("time", &usr
->expiry
, ps
, depth
))
2912 if(!prs_uint8s(False
, "padding_1", ps
, depth
, usr
->padding_1
, sizeof(usr
->padding_1
)))
2915 if(!smb_io_unihdr("unihdr", &usr
->hdr_mach_acct
, ps
, depth
))
2918 if(!prs_uint32("padding_2", ps
, depth
, &usr
->padding_2
))
2921 if(!prs_uint32("ptr_1 ", ps
, depth
, &usr
->ptr_1
))
2923 if(!prs_uint8s(False
, "padding_3", ps
, depth
, usr
->padding_3
, sizeof(usr
->padding_3
)))
2926 if(!prs_uint32("padding_4", ps
, depth
, &usr
->padding_4
))
2929 if(!prs_uint32("ptr_2 ", ps
, depth
, &usr
->ptr_2
))
2931 if(!prs_uint32("padding_5", ps
, depth
, &usr
->padding_5
))
2934 if(!prs_uint32("ptr_3 ", ps
, depth
, &usr
->ptr_3
))
2936 if(!prs_uint8s(False
, "padding_6", ps
, depth
, usr
->padding_6
,sizeof(usr
->padding_6
)))
2939 if(!prs_uint32("rid_user ", ps
, depth
, &usr
->rid_user
))
2941 if(!prs_uint32("rid_group", ps
, depth
, &usr
->rid_group
))
2943 if(!prs_uint16("acct_ctrl", ps
, depth
, &usr
->acct_ctrl
))
2945 if(!prs_uint16("unknown_3", ps
, depth
, &usr
->unknown_3
))
2947 if(!prs_uint16("unknown_4", ps
, depth
, &usr
->unknown_4
))
2949 if(!prs_uint16("unknown_5", ps
, depth
, &usr
->unknown_5
))
2952 if(!prs_uint8s(False
, "padding_7", ps
, depth
, usr
->padding_7
, sizeof(usr
->padding_7
)))
2955 if(!prs_uint32("padding_8", ps
, depth
, &(usr
->padding_8
)))
2958 if(!smb_io_unistr2("unistr2", &usr
->uni_mach_acct
, True
, ps
, depth
))
2964 if(!prs_uint8s(False
, "padding_9", ps
, depth
, usr
->padding_9
, sizeof(usr
->padding_9
)))
2970 /*************************************************************************
2972 *************************************************************************/
2974 void init_sam_user_info24(SAM_USER_INFO_24
* usr
, char newpass
[516],
2977 DEBUG(10, ("init_sam_user_info24:\n"));
2978 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
2979 usr
->pw_len
= pw_len
;
2982 /*******************************************************************
2983 reads or writes a structure.
2984 ********************************************************************/
2986 static bool sam_io_user_info24(const char *desc
, SAM_USER_INFO_24
* usr
,
2987 prs_struct
*ps
, int depth
)
2992 prs_debug(ps
, depth
, desc
, "sam_io_user_info24");
2998 if(!prs_uint8s(False
, "password", ps
, depth
, usr
->pass
,
3002 if (MARSHALLING(ps
) && (usr
->pw_len
!= 0)) {
3003 if (!prs_uint8("pw_len", ps
, depth
, &usr
->pw_len
))
3005 } else if (UNMARSHALLING(ps
)) {
3006 if (!prs_uint8("pw_len", ps
, depth
, &usr
->pw_len
))
3013 /*******************************************************************
3014 reads or writes a structure.
3015 ********************************************************************/
3017 static bool sam_io_user_info26(const char *desc
, SAM_USER_INFO_26
* usr
,
3018 prs_struct
*ps
, int depth
)
3023 prs_debug(ps
, depth
, desc
, "sam_io_user_info26");
3029 if(!prs_uint8s(False
, "password", ps
, depth
, usr
->pass
,
3033 if (!prs_uint8("pw_len", ps
, depth
, &usr
->pw_len
))
3040 /*************************************************************************
3041 init_sam_user_info23
3043 unknown_6 = 0x0000 04ec
3045 *************************************************************************/
3047 void init_sam_user_info23W(SAM_USER_INFO_23
* usr
, NTTIME
* logon_time
, /* all zeros */
3048 NTTIME
* logoff_time
, /* all zeros */
3049 NTTIME
* kickoff_time
, /* all zeros */
3050 NTTIME
* pass_last_set_time
, /* all zeros */
3051 NTTIME
* pass_can_change_time
, /* all zeros */
3052 NTTIME
* pass_must_change_time
, /* all zeros */
3063 uint32 user_rid
, /* 0x0000 0000 */
3066 uint32 fields_present
,
3069 uint16 bad_password_count
,
3073 usr
->logon_time
= *logon_time
; /* all zeros */
3074 usr
->logoff_time
= *logoff_time
; /* all zeros */
3075 usr
->kickoff_time
= *kickoff_time
; /* all zeros */
3076 usr
->pass_last_set_time
= *pass_last_set_time
; /* all zeros */
3077 usr
->pass_can_change_time
= *pass_can_change_time
; /* all zeros */
3078 usr
->pass_must_change_time
= *pass_must_change_time
; /* all zeros */
3080 ZERO_STRUCT(usr
->nt_pwd
);
3081 ZERO_STRUCT(usr
->lm_pwd
);
3083 usr
->user_rid
= user_rid
; /* 0x0000 0000 */
3084 usr
->group_rid
= group_rid
;
3085 usr
->acb_info
= acb_info
;
3086 usr
->fields_present
= fields_present
; /* 09f8 27fa */
3088 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
3089 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
3091 if (nt_time_is_zero(pass_must_change_time
)) {
3092 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
3094 usr
->passmustchange
=0;
3097 ZERO_STRUCT(usr
->padding1
);
3098 ZERO_STRUCT(usr
->padding2
);
3100 usr
->bad_password_count
= bad_password_count
;
3101 usr
->logon_count
= logon_count
;
3103 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
3105 copy_unistr2(&usr
->uni_user_name
, user_name
);
3106 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
3108 copy_unistr2(&usr
->uni_full_name
, full_name
);
3109 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
3111 copy_unistr2(&usr
->uni_home_dir
, home_dir
);
3112 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
3114 copy_unistr2(&usr
->uni_dir_drive
, dir_drive
);
3115 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
3117 copy_unistr2(&usr
->uni_logon_script
, log_scr
);
3118 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
3120 copy_unistr2(&usr
->uni_profile_path
, prof_path
);
3121 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
3123 copy_unistr2(&usr
->uni_acct_desc
, desc
);
3124 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
3126 copy_unistr2(&usr
->uni_workstations
, wkstas
);
3127 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
3129 copy_unistr2(&usr
->uni_comment
, unk_str
);
3130 init_uni_hdr(&usr
->hdr_comment
, &usr
->uni_comment
);
3132 copy_unistr2(&usr
->uni_munged_dial
, mung_dial
);
3133 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
3136 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
3138 ZERO_STRUCT(usr
->logon_hrs
);
3142 /*************************************************************************
3143 init_sam_user_info23
3145 unknown_6 = 0x0000 04ec
3147 *************************************************************************/
3149 void init_sam_user_info23A(SAM_USER_INFO_23
* usr
, NTTIME
* logon_time
, /* all zeros */
3150 NTTIME
* logoff_time
, /* all zeros */
3151 NTTIME
* kickoff_time
, /* all zeros */
3152 NTTIME
* pass_last_set_time
, /* all zeros */
3153 NTTIME
* pass_can_change_time
, /* all zeros */
3154 NTTIME
* pass_must_change_time
, /* all zeros */
3155 char *user_name
, /* NULL */
3157 char *home_dir
, char *dir_drive
, char *log_scr
,
3158 char *prof_path
, const char *desc
, char *wkstas
,
3159 char *unk_str
, char *mung_dial
, uint32 user_rid
, /* 0x0000 0000 */
3160 uint32 group_rid
, uint32 acb_info
,
3161 uint32 fields_present
, uint16 logon_divs
,
3162 LOGON_HRS
* hrs
, uint16 bad_password_count
, uint16 logon_count
,
3165 DATA_BLOB blob
= base64_decode_data_blob(mung_dial
);
3167 usr
->logon_time
= *logon_time
; /* all zeros */
3168 usr
->logoff_time
= *logoff_time
; /* all zeros */
3169 usr
->kickoff_time
= *kickoff_time
; /* all zeros */
3170 usr
->pass_last_set_time
= *pass_last_set_time
; /* all zeros */
3171 usr
->pass_can_change_time
= *pass_can_change_time
; /* all zeros */
3172 usr
->pass_must_change_time
= *pass_must_change_time
; /* all zeros */
3174 ZERO_STRUCT(usr
->nt_pwd
);
3175 ZERO_STRUCT(usr
->lm_pwd
);
3177 usr
->user_rid
= user_rid
; /* 0x0000 0000 */
3178 usr
->group_rid
= group_rid
;
3179 usr
->acb_info
= acb_info
;
3180 usr
->fields_present
= fields_present
; /* 09f8 27fa */
3182 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
3183 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
3185 if (nt_time_is_zero(pass_must_change_time
)) {
3186 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
3188 usr
->passmustchange
=0;
3191 ZERO_STRUCT(usr
->padding1
);
3192 ZERO_STRUCT(usr
->padding2
);
3194 usr
->bad_password_count
= bad_password_count
;
3195 usr
->logon_count
= logon_count
;
3197 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
3199 init_unistr2(&usr
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
3200 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
3202 init_unistr2(&usr
->uni_full_name
, full_name
, UNI_FLAGS_NONE
);
3203 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
3205 init_unistr2(&usr
->uni_home_dir
, home_dir
, UNI_FLAGS_NONE
);
3206 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
3208 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, UNI_FLAGS_NONE
);
3209 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
3211 init_unistr2(&usr
->uni_logon_script
, log_scr
, UNI_FLAGS_NONE
);
3212 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
3214 init_unistr2(&usr
->uni_profile_path
, prof_path
, UNI_FLAGS_NONE
);
3215 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
3217 init_unistr2(&usr
->uni_acct_desc
, desc
, UNI_FLAGS_NONE
);
3218 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
3220 init_unistr2(&usr
->uni_workstations
, wkstas
, UNI_FLAGS_NONE
);
3221 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
3223 init_unistr2(&usr
->uni_comment
, unk_str
, UNI_FLAGS_NONE
);
3224 init_uni_hdr(&usr
->hdr_comment
, &usr
->uni_comment
);
3226 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &blob
);
3227 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
3229 data_blob_free(&blob
);
3232 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
3234 ZERO_STRUCT(usr
->logon_hrs
);
3239 /*************************************************************************
3240 init_samr_user_info25P
3241 fields_present = ACCT_NT_PWD_SET | ACCT_LM_PWD_SET | ACCT_FLAGS
3242 *************************************************************************/
3244 void init_sam_user_info25P(SAM_USER_INFO_25
* usr
,
3245 uint32 fields_present
, uint32 acb_info
,
3248 usr
->fields_present
= fields_present
;
3249 ZERO_STRUCT(usr
->padding1
);
3250 ZERO_STRUCT(usr
->padding2
);
3252 usr
->acb_info
= acb_info
;
3253 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
3257 /*******************************************************************
3258 reads or writes a structure.
3259 ********************************************************************/
3261 static bool sam_io_user_info23(const char *desc
, SAM_USER_INFO_23
* usr
,
3262 prs_struct
*ps
, int depth
)
3267 prs_debug(ps
, depth
, desc
, "sam_io_user_info23");
3273 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
3275 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
3277 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
3279 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
3281 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
3283 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
3286 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
3288 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
3290 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
3292 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
3294 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
3296 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
3298 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
3300 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
3302 if(!smb_io_unihdr("hdr_comment ", &usr
->hdr_comment
, ps
, depth
)) /* unknown string */
3304 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
3307 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
3309 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
3312 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
3314 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
3316 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
3319 if(!prs_uint32("fields_present ", ps
, depth
, &usr
->fields_present
))
3321 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
3325 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
3328 if(!prs_uint16("bad_password_count ", ps
, depth
, &usr
->bad_password_count
))
3330 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
))
3333 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
3335 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
3337 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
3341 if(!prs_uint8s(False
, "password ", ps
, depth
, usr
->pass
, sizeof(usr
->pass
)))
3344 /* here begins pointed-to data */
3346 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
3349 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
3352 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
3355 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
3358 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
3361 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
3364 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
3367 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
3370 if(!smb_io_unistr2("uni_comment ", &usr
->uni_comment
, usr
->hdr_comment
.buffer
, ps
, depth
)) /* unknown string */
3373 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
))
3376 /* ok, this is only guess-work (as usual) */
3377 if (usr
->ptr_logon_hrs
) {
3378 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
3385 /*******************************************************************
3386 reads or writes a structure.
3387 NB. This structure is *definately* incorrect. It's my best guess
3388 currently for W2K SP2. The password field is encrypted in a different
3389 way than normal... And there are definately other problems. JRA.
3390 ********************************************************************/
3392 static bool sam_io_user_info25(const char *desc
, SAM_USER_INFO_25
* usr
, prs_struct
*ps
, int depth
)
3397 prs_debug(ps
, depth
, desc
, "sam_io_user_info25");
3403 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
3405 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
3407 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
3409 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
3411 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
3413 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
3416 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
3418 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
3420 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
3422 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
3424 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
3426 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
3428 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
3430 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
3432 if(!smb_io_unihdr("hdr_comment ", &usr
->hdr_comment
, ps
, depth
)) /* unknown string */
3434 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
3437 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
3439 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
3442 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
3444 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
3446 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
3448 if(!prs_uint32("fields_present ", ps
, depth
, &usr
->fields_present
))
3451 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
3455 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
3458 if(!prs_uint16("bad_password_count ", ps
, depth
, &usr
->bad_password_count
))
3460 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
))
3463 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
3465 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
3467 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
3471 if(!prs_uint8s(False
, "password ", ps
, depth
, usr
->pass
, sizeof(usr
->pass
)))
3474 /* here begins pointed-to data */
3476 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
3479 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
3482 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
3485 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
3488 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
3491 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
3494 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
3497 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
3500 if(!smb_io_unistr2("uni_comment ", &usr
->uni_comment
, usr
->hdr_comment
.buffer
, ps
, depth
)) /* unknown string */
3503 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
))
3506 /* ok, this is only guess-work (as usual) */
3507 if (usr
->ptr_logon_hrs
) {
3508 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
3516 /*************************************************************************
3517 init_sam_user_info21W
3519 unknown_6 = 0x0000 04ec
3521 *************************************************************************/
3523 void init_sam_user_info21W(SAM_USER_INFO_21
* usr
,
3524 NTTIME
* logon_time
,
3525 NTTIME
* logoff_time
,
3526 NTTIME
* kickoff_time
,
3527 NTTIME
* pass_last_set_time
,
3528 NTTIME
* pass_can_change_time
,
3529 NTTIME
* pass_must_change_time
,
3545 uint32 fields_present
,
3548 uint16 bad_password_count
,
3551 usr
->logon_time
= *logon_time
;
3552 usr
->logoff_time
= *logoff_time
;
3553 usr
->kickoff_time
= *kickoff_time
;
3554 usr
->pass_last_set_time
= *pass_last_set_time
;
3555 usr
->pass_can_change_time
= *pass_can_change_time
;
3556 usr
->pass_must_change_time
= *pass_must_change_time
;
3558 memcpy(usr
->lm_pwd
, lm_pwd
, sizeof(usr
->lm_pwd
));
3559 memcpy(usr
->nt_pwd
, nt_pwd
, sizeof(usr
->nt_pwd
));
3561 usr
->user_rid
= user_rid
;
3562 usr
->group_rid
= group_rid
;
3563 usr
->acb_info
= acb_info
;
3564 usr
->fields_present
= fields_present
; /* 0x00ff ffff */
3566 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
3567 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
3568 usr
->bad_password_count
= bad_password_count
;
3569 usr
->logon_count
= logon_count
;
3571 if (nt_time_is_zero(pass_must_change_time
)) {
3572 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
3574 usr
->passmustchange
=0;
3577 ZERO_STRUCT(usr
->padding1
);
3578 ZERO_STRUCT(usr
->padding2
);
3580 copy_unistr2(&usr
->uni_user_name
, user_name
);
3581 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
3583 copy_unistr2(&usr
->uni_full_name
, full_name
);
3584 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
3586 copy_unistr2(&usr
->uni_home_dir
, home_dir
);
3587 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
3589 copy_unistr2(&usr
->uni_dir_drive
, dir_drive
);
3590 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
3592 copy_unistr2(&usr
->uni_logon_script
, log_scr
);
3593 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
3595 copy_unistr2(&usr
->uni_profile_path
, prof_path
);
3596 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
3598 copy_unistr2(&usr
->uni_acct_desc
, desc
);
3599 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
3601 copy_unistr2(&usr
->uni_workstations
, wkstas
);
3602 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
3604 copy_unistr2(&usr
->uni_comment
, unk_str
);
3605 init_uni_hdr(&usr
->hdr_comment
, &usr
->uni_comment
);
3607 copy_unistr2(&usr
->uni_munged_dial
, mung_dial
);
3608 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
3611 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
3613 ZERO_STRUCT(usr
->logon_hrs
);
3617 /*************************************************************************
3618 init_sam_user_info21
3620 unknown_6 = 0x0000 04ec
3622 *************************************************************************/
3624 NTSTATUS
init_sam_user_info21A(SAM_USER_INFO_21
*usr
, struct samu
*pw
, DOM_SID
*domain_sid
)
3626 NTTIME logon_time
, logoff_time
, kickoff_time
,
3627 pass_last_set_time
, pass_can_change_time
,
3628 pass_must_change_time
;
3630 time_t must_change_time
;
3631 const char* user_name
= pdb_get_username(pw
);
3632 const char* full_name
= pdb_get_fullname(pw
);
3633 const char* home_dir
= pdb_get_homedir(pw
);
3634 const char* dir_drive
= pdb_get_dir_drive(pw
);
3635 const char* logon_script
= pdb_get_logon_script(pw
);
3636 const char* profile_path
= pdb_get_profile_path(pw
);
3637 const char* description
= pdb_get_acct_desc(pw
);
3638 const char* workstations
= pdb_get_workstations(pw
);
3639 const char* munged_dial
= pdb_get_munged_dial(pw
);
3640 DATA_BLOB munged_dial_blob
;
3643 const DOM_SID
*user_sid
;
3646 const DOM_SID
*group_sid
;
3649 munged_dial_blob
= base64_decode_data_blob(munged_dial
);
3651 munged_dial_blob
= data_blob_null
;
3654 /* Create NTTIME structs */
3655 unix_to_nt_time (&logon_time
, pdb_get_logon_time(pw
));
3656 unix_to_nt_time (&logoff_time
, pdb_get_logoff_time(pw
));
3657 unix_to_nt_time (&kickoff_time
, pdb_get_kickoff_time(pw
));
3658 unix_to_nt_time (&pass_last_set_time
, pdb_get_pass_last_set_time(pw
));
3659 unix_to_nt_time (&pass_can_change_time
,pdb_get_pass_can_change_time(pw
));
3660 must_change_time
= pdb_get_pass_must_change_time(pw
);
3661 if (must_change_time
== get_time_t_max())
3662 unix_to_nt_time_abs(&pass_must_change_time
, must_change_time
);
3664 unix_to_nt_time(&pass_must_change_time
, must_change_time
);
3666 /* structure assignment */
3667 usr
->logon_time
= logon_time
;
3668 usr
->logoff_time
= logoff_time
;
3669 usr
->kickoff_time
= kickoff_time
;
3670 usr
->pass_last_set_time
= pass_last_set_time
;
3671 usr
->pass_can_change_time
= pass_can_change_time
;
3672 usr
->pass_must_change_time
= pass_must_change_time
;
3674 ZERO_STRUCT(usr
->nt_pwd
);
3675 ZERO_STRUCT(usr
->lm_pwd
);
3677 user_sid
= pdb_get_user_sid(pw
);
3679 if (!sid_peek_check_rid(domain_sid
, user_sid
, &user_rid
)) {
3680 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
3681 "the domain sid %s. Failing operation.\n",
3682 user_name
, sid_string_dbg(user_sid
),
3683 sid_string_dbg(domain_sid
)));
3684 data_blob_free(&munged_dial_blob
);
3685 return NT_STATUS_UNSUCCESSFUL
;
3689 group_sid
= pdb_get_group_sid(pw
);
3692 if (!sid_peek_check_rid(domain_sid
, group_sid
, &group_rid
)) {
3693 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
3694 "which conflicts with the domain sid %s. Failing operation.\n",
3695 user_name
, sid_string_dbg(group_sid
),
3696 sid_string_dbg(domain_sid
)));
3697 data_blob_free(&munged_dial_blob
);
3698 return NT_STATUS_UNSUCCESSFUL
;
3701 usr
->user_rid
= user_rid
;
3702 usr
->group_rid
= group_rid
;
3703 usr
->acb_info
= pdb_get_acct_ctrl(pw
);
3706 Look at a user on a real NT4 PDC with usrmgr, press
3707 'ok'. Then you will see that fields_present is set to
3708 0x08f827fa. Look at the user immediately after that again,
3709 and you will see that 0x00fffff is returned. This solves
3710 the problem that you get access denied after having looked
3714 usr
->fields_present
= pdb_build_fields_present(pw
);
3716 usr
->logon_divs
= pdb_get_logon_divs(pw
);
3717 usr
->ptr_logon_hrs
= pdb_get_hours(pw
) ? 1 : 0;
3718 usr
->bad_password_count
= pdb_get_bad_password_count(pw
);
3719 usr
->logon_count
= pdb_get_logon_count(pw
);
3721 if (pdb_get_pass_must_change_time(pw
) == 0) {
3722 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
3724 usr
->passmustchange
=0;
3727 ZERO_STRUCT(usr
->padding1
);
3728 ZERO_STRUCT(usr
->padding2
);
3730 init_unistr2(&usr
->uni_user_name
, user_name
, UNI_STR_TERMINATE
);
3731 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
3733 init_unistr2(&usr
->uni_full_name
, full_name
, UNI_STR_TERMINATE
);
3734 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
3736 init_unistr2(&usr
->uni_home_dir
, home_dir
, UNI_STR_TERMINATE
);
3737 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
3739 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, UNI_STR_TERMINATE
);
3740 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
3742 init_unistr2(&usr
->uni_logon_script
, logon_script
, UNI_STR_TERMINATE
);
3743 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
3745 init_unistr2(&usr
->uni_profile_path
, profile_path
, UNI_STR_TERMINATE
);
3746 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
3748 init_unistr2(&usr
->uni_acct_desc
, description
, UNI_STR_TERMINATE
);
3749 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
3751 init_unistr2(&usr
->uni_workstations
, workstations
, UNI_STR_TERMINATE
);
3752 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
3754 init_unistr2(&usr
->uni_comment
, NULL
, UNI_STR_TERMINATE
);
3755 init_uni_hdr(&usr
->hdr_comment
, &usr
->uni_comment
);
3757 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &munged_dial_blob
);
3758 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
3759 data_blob_free(&munged_dial_blob
);
3761 if (pdb_get_hours(pw
)) {
3762 usr
->logon_hrs
.max_len
= 1260;
3763 usr
->logon_hrs
.offset
= 0;
3764 usr
->logon_hrs
.len
= pdb_get_hours_len(pw
);
3765 memcpy(&usr
->logon_hrs
.hours
, pdb_get_hours(pw
), MAX_HOURS_LEN
);
3767 usr
->logon_hrs
.max_len
= 1260;
3768 usr
->logon_hrs
.offset
= 0;
3769 usr
->logon_hrs
.len
= 0;
3770 memset(&usr
->logon_hrs
, 0xff, sizeof(usr
->logon_hrs
));
3773 return NT_STATUS_OK
;
3776 /*******************************************************************
3777 reads or writes a structure.
3778 ********************************************************************/
3780 static bool sam_io_user_info21(const char *desc
, SAM_USER_INFO_21
* usr
,
3781 prs_struct
*ps
, int depth
)
3786 prs_debug(ps
, depth
, desc
, "sam_io_user_info21");
3792 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
3794 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
3796 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
,depth
))
3798 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
3800 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
,depth
))
3802 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
3805 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
3807 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
3809 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
3811 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
3813 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
3815 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
3817 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
3819 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
3821 if(!smb_io_unihdr("hdr_comment ", &usr
->hdr_comment
, ps
, depth
)) /* unknown string */
3823 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
3826 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
3828 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
3831 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
3833 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
3835 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
3838 if(!prs_uint32("fields_present ", ps
, depth
, &usr
->fields_present
))
3840 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
3844 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
3847 if(!prs_uint16("bad_password_count ", ps
, depth
, &usr
->bad_password_count
))
3849 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
))
3852 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
3854 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
3856 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
3859 /* here begins pointed-to data */
3861 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
,usr
->hdr_user_name
.buffer
, ps
, depth
))
3863 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
))
3865 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
))
3867 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
))
3869 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
))
3871 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
))
3873 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
))
3875 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
))
3877 if(!smb_io_unistr2("uni_comment", &usr
->uni_comment
, usr
->hdr_comment
.buffer
, ps
, depth
))
3879 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
,usr
->hdr_munged_dial
.buffer
, ps
, depth
))
3882 /* ok, this is only guess-work (as usual) */
3883 if (usr
->ptr_logon_hrs
) {
3884 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
3891 void init_sam_user_info20A(SAM_USER_INFO_20
*usr
, struct samu
*pw
)
3893 const char *munged_dial
= pdb_get_munged_dial(pw
);
3897 blob
= base64_decode_data_blob(munged_dial
);
3899 blob
= data_blob_null
;
3902 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &blob
);
3903 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
3904 data_blob_free(&blob
);
3907 /*******************************************************************
3908 reads or writes a structure.
3909 ********************************************************************/
3911 static bool sam_io_user_info20(const char *desc
, SAM_USER_INFO_20
*usr
,
3912 prs_struct
*ps
, int depth
)
3917 prs_debug(ps
, depth
, desc
, "sam_io_user_info20");
3923 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
3926 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
,usr
->hdr_munged_dial
.buffer
, ps
, depth
)) /* worksations user can log on from */
3932 /*******************************************************************
3933 inits a SAM_USERINFO_CTR structure.
3934 ********************************************************************/
3936 NTSTATUS
make_samr_userinfo_ctr_usr21(TALLOC_CTX
*ctx
, SAM_USERINFO_CTR
* ctr
,
3937 uint16 switch_value
,
3938 SAM_USER_INFO_21
* usr
)
3940 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
3942 ctr
->switch_value
= switch_value
;
3943 ctr
->info
.id
= NULL
;
3945 switch (switch_value
) {
3947 ctr
->info
.id16
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_16
);
3948 if (ctr
->info
.id16
== NULL
)
3949 return NT_STATUS_NO_MEMORY
;
3951 init_sam_user_info16(ctr
->info
.id16
, usr
->acb_info
);
3954 /* whoops - got this wrong. i think. or don't understand what's happening. */
3958 info
= (void *)&id11
;
3960 expire
.low
= 0xffffffff;
3961 expire
.high
= 0x7fffffff;
3963 ctr
->info
.id
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_17
);
3964 init_sam_user_info11(ctr
->info
.id17
, &expire
,
3965 "BROOKFIELDS$", /* name */
3966 0x03ef, /* user rid */
3967 0x201, /* group rid */
3968 0x0080); /* acb info */
3974 ctr
->info
.id18
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_18
);
3975 if (ctr
->info
.id18
== NULL
)
3976 return NT_STATUS_NO_MEMORY
;
3978 init_sam_user_info18(ctr
->info
.id18
, usr
->lm_pwd
, usr
->nt_pwd
);
3982 SAM_USER_INFO_21
*cusr
;
3983 cusr
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_21
);
3984 ctr
->info
.id21
= cusr
;
3985 if (ctr
->info
.id21
== NULL
)
3986 return NT_STATUS_NO_MEMORY
;
3987 memcpy(cusr
, usr
, sizeof(*usr
));
3988 memset(cusr
->lm_pwd
, 0, sizeof(cusr
->lm_pwd
));
3989 memset(cusr
->nt_pwd
, 0, sizeof(cusr
->nt_pwd
));
3993 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
3994 return NT_STATUS_INVALID_INFO_CLASS
;
3997 return NT_STATUS_OK
;
4000 /*******************************************************************
4001 inits a SAM_USERINFO_CTR structure.
4002 ********************************************************************/
4004 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR
* ctr
, DATA_BLOB
*sess_key
,
4005 uint16 switch_value
, void *info
)
4007 DEBUG(5, ("init_samr_userinfo_ctr\n"));
4009 ctr
->switch_value
= switch_value
;
4010 ctr
->info
.id
= info
;
4012 switch (switch_value
) {
4014 SamOEMhashBlob(ctr
->info
.id24
->pass
, 516, sess_key
);
4015 dump_data(100, sess_key
->data
, sess_key
->length
);
4016 dump_data(100, ctr
->info
.id24
->pass
, 516);
4019 SamOEMhashBlob(ctr
->info
.id23
->pass
, 516, sess_key
);
4020 dump_data(100, sess_key
->data
, sess_key
->length
);
4021 dump_data(100, ctr
->info
.id23
->pass
, 516);
4026 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value
));
4030 /*******************************************************************
4031 reads or writes a structure.
4032 ********************************************************************/
4034 static bool samr_io_userinfo_ctr(const char *desc
, SAM_USERINFO_CTR
**ppctr
,
4035 prs_struct
*ps
, int depth
)
4038 SAM_USERINFO_CTR
*ctr
;
4040 prs_debug(ps
, depth
, desc
, "samr_io_userinfo_ctr");
4043 if (UNMARSHALLING(ps
)) {
4044 ctr
= PRS_ALLOC_MEM(ps
,SAM_USERINFO_CTR
,1);
4052 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
4054 if(!prs_uint16("switch_value", ps
, depth
, &ctr
->switch_value
))
4061 switch (ctr
->switch_value
) {
4063 if (UNMARSHALLING(ps
))
4064 ctr
->info
.id7
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_7
,1);
4065 if (ctr
->info
.id7
== NULL
) {
4066 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
4069 ret
= sam_io_user_info7("", ctr
->info
.id7
, ps
, depth
);
4072 if (UNMARSHALLING(ps
))
4073 ctr
->info
.id9
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_9
,1);
4074 if (ctr
->info
.id9
== NULL
) {
4075 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
4078 ret
= sam_io_user_info9("", ctr
->info
.id9
, ps
, depth
);
4081 if (UNMARSHALLING(ps
))
4082 ctr
->info
.id16
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_16
,1);
4083 if (ctr
->info
.id16
== NULL
) {
4084 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
4087 ret
= sam_io_user_info16("", ctr
->info
.id16
, ps
, depth
);
4090 if (UNMARSHALLING(ps
))
4091 ctr
->info
.id17
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_17
,1);
4093 if (ctr
->info
.id17
== NULL
) {
4094 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
4097 ret
= sam_io_user_info17("", ctr
->info
.id17
, ps
, depth
);
4100 if (UNMARSHALLING(ps
))
4101 ctr
->info
.id18
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_18
,1);
4103 if (ctr
->info
.id18
== NULL
) {
4104 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
4107 ret
= sam_io_user_info18("", ctr
->info
.id18
, ps
, depth
);
4110 if (UNMARSHALLING(ps
))
4111 ctr
->info
.id20
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_20
,1);
4113 if (ctr
->info
.id20
== NULL
) {
4114 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
4117 ret
= sam_io_user_info20("", ctr
->info
.id20
, ps
, depth
);
4120 if (UNMARSHALLING(ps
))
4121 ctr
->info
.id21
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_21
,1);
4123 if (ctr
->info
.id21
== NULL
) {
4124 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
4127 ret
= sam_io_user_info21("", ctr
->info
.id21
, ps
, depth
);
4130 if (UNMARSHALLING(ps
))
4131 ctr
->info
.id23
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_23
,1);
4133 if (ctr
->info
.id23
== NULL
) {
4134 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
4137 ret
= sam_io_user_info23("", ctr
->info
.id23
, ps
, depth
);
4140 if (UNMARSHALLING(ps
))
4141 ctr
->info
.id24
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_24
,1);
4143 if (ctr
->info
.id24
== NULL
) {
4144 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
4147 ret
= sam_io_user_info24("", ctr
->info
.id24
, ps
, depth
);
4150 if (UNMARSHALLING(ps
))
4151 ctr
->info
.id25
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_25
,1);
4153 if (ctr
->info
.id25
== NULL
) {
4154 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
4157 ret
= sam_io_user_info25("", ctr
->info
.id25
, ps
, depth
);
4160 if (UNMARSHALLING(ps
))
4161 ctr
->info
.id26
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_26
,1);
4163 if (ctr
->info
.id26
== NULL
) {
4164 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
4167 ret
= sam_io_user_info26("", ctr
->info
.id26
, ps
, depth
);
4170 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr
->switch_value
));
4178 /*******************************************************************
4179 inits a SAMR_R_QUERY_USERINFO structure.
4180 ********************************************************************/
4182 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO
* r_u
,
4183 SAM_USERINFO_CTR
* ctr
, NTSTATUS status
)
4185 DEBUG(5, ("init_samr_r_query_userinfo\n"));
4190 if (NT_STATUS_IS_OK(status
)) {
4195 r_u
->status
= status
; /* return status */
4198 /*******************************************************************
4199 reads or writes a structure.
4200 ********************************************************************/
4202 bool samr_io_r_query_userinfo(const char *desc
, SAMR_R_QUERY_USERINFO
* r_u
,
4203 prs_struct
*ps
, int depth
)
4208 prs_debug(ps
, depth
, desc
, "samr_io_r_query_userinfo");
4214 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
4217 if (r_u
->ptr
!= 0) {
4218 if(!samr_io_userinfo_ctr("ctr", &r_u
->ctr
, ps
, depth
))
4224 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4230 /*******************************************************************
4231 inits a SAMR_Q_SET_USERINFO structure.
4232 ********************************************************************/
4234 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO
* q_u
,
4235 const POLICY_HND
*hnd
, DATA_BLOB
*sess_key
,
4236 uint16 switch_value
, void *info
)
4238 DEBUG(5, ("init_samr_q_set_userinfo\n"));
4241 q_u
->switch_value
= switch_value
;
4242 init_samr_userinfo_ctr(q_u
->ctr
, sess_key
, switch_value
, info
);
4245 /*******************************************************************
4246 reads or writes a structure.
4247 ********************************************************************/
4249 bool samr_io_q_set_userinfo(const char *desc
, SAMR_Q_SET_USERINFO
* q_u
,
4250 prs_struct
*ps
, int depth
)
4255 prs_debug(ps
, depth
, desc
, "samr_io_q_set_userinfo");
4261 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
4263 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
4265 if(!samr_io_userinfo_ctr("ctr", &q_u
->ctr
, ps
, depth
))
4271 /*******************************************************************
4272 inits a SAMR_R_SET_USERINFO structure.
4273 ********************************************************************/
4275 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO
* r_u
, NTSTATUS status
)
4277 DEBUG(5, ("init_samr_r_set_userinfo\n"));
4279 r_u
->status
= status
; /* return status */
4282 /*******************************************************************
4283 reads or writes a structure.
4284 ********************************************************************/
4286 bool samr_io_r_set_userinfo(const char *desc
, SAMR_R_SET_USERINFO
* r_u
,
4287 prs_struct
*ps
, int depth
)
4292 prs_debug(ps
, depth
, desc
, "samr_io_r_set_userinfo");
4298 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4304 /*******************************************************************
4305 inits a SAMR_Q_SET_USERINFO2 structure.
4306 ********************************************************************/
4308 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2
* q_u
,
4309 const POLICY_HND
*hnd
, DATA_BLOB
*sess_key
,
4310 uint16 switch_value
, SAM_USERINFO_CTR
* ctr
)
4312 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
4315 q_u
->switch_value
= switch_value
;
4318 q_u
->ctr
->switch_value
= switch_value
;
4320 switch (switch_value
) {
4322 SamOEMhashBlob(ctr
->info
.id18
->lm_pwd
, 16, sess_key
);
4323 SamOEMhashBlob(ctr
->info
.id18
->nt_pwd
, 16, sess_key
);
4324 dump_data(100, sess_key
->data
, sess_key
->length
);
4325 dump_data(100, ctr
->info
.id18
->lm_pwd
, 16);
4326 dump_data(100, ctr
->info
.id18
->nt_pwd
, 16);
4331 /*******************************************************************
4332 reads or writes a structure.
4333 ********************************************************************/
4335 bool samr_io_q_set_userinfo2(const char *desc
, SAMR_Q_SET_USERINFO2
* q_u
,
4336 prs_struct
*ps
, int depth
)
4341 prs_debug(ps
, depth
, desc
, "samr_io_q_set_userinfo2");
4347 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
4350 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
4352 if(!samr_io_userinfo_ctr("ctr", &q_u
->ctr
, ps
, depth
))
4358 /*******************************************************************
4359 inits a SAMR_R_SET_USERINFO2 structure.
4360 ********************************************************************/
4362 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2
* r_u
, NTSTATUS status
)
4364 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
4366 r_u
->status
= status
; /* return status */
4369 /*******************************************************************
4370 reads or writes a structure.
4371 ********************************************************************/
4373 bool samr_io_r_set_userinfo2(const char *desc
, SAMR_R_SET_USERINFO2
* r_u
,
4374 prs_struct
*ps
, int depth
)
4379 prs_debug(ps
, depth
, desc
, "samr_io_r_set_userinfo2");
4385 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))