yeehaah got users to be included in S-1-5-xxx-yyy-zzz's local groups.
[samba.git] / source3 / rpc_parse / parse_samr.c
1 /* 
2  *  Unix SMB/Netbios implementation.
3  *  Version 1.9.
4  *  RPC Pipe client / server routines
5  *  Copyright (C) Andrew Tridgell              1992-1997,
6  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7  *  Copyright (C) Paul Ashton                       1997.
8  *  
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *  
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *  
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24
25 #include "includes.h"
26
27 extern int DEBUGLEVEL;
28
29
30 /*******************************************************************
31 makes a SAMR_Q_CLOSE_HND structure.
32 ********************************************************************/
33 void make_samr_q_close_hnd(SAMR_Q_CLOSE_HND *q_c, POLICY_HND *hnd)
34 {
35         if (q_c == NULL || hnd == NULL) return;
36
37         DEBUG(5,("make_samr_q_close_hnd\n"));
38
39         memcpy(&(q_c->pol), hnd, sizeof(q_c->pol));
40 }
41
42 /*******************************************************************
43 reads or writes a structure.
44 ********************************************************************/
45 void samr_io_q_close_hnd(char *desc,  SAMR_Q_CLOSE_HND *q_u, prs_struct *ps, int depth)
46 {
47         if (q_u == NULL) return;
48
49         prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
50         depth++;
51
52         prs_align(ps);
53
54         smb_io_pol_hnd("pol", &(q_u->pol), ps, depth); 
55         prs_align(ps);
56 }
57
58 /*******************************************************************
59 reads or writes a structure.
60 ********************************************************************/
61 void samr_io_r_close_hnd(char *desc,  SAMR_R_CLOSE_HND *r_u, prs_struct *ps, int depth)
62 {
63         if (r_u == NULL) return;
64
65         prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
66         depth++;
67
68         prs_align(ps);
69
70         smb_io_pol_hnd("pol", &(r_u->pol), ps, depth); 
71         prs_align(ps);
72
73         prs_uint32("status", ps, depth, &(r_u->status));
74 }
75
76
77 /*******************************************************************
78 reads or writes a structure.
79 ********************************************************************/
80 void make_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN *q_u,
81                                 POLICY_HND *connect_pol, uint32 rid,
82                                 DOM_SID *sid)
83 {
84         if (q_u == NULL) return;
85
86         DEBUG(5,("samr_make_q_open_domain\n"));
87
88         memcpy(&q_u->connect_pol, connect_pol, sizeof(q_u->connect_pol));
89         q_u->rid = rid;
90         make_dom_sid2(&(q_u->dom_sid), sid);
91 }
92
93 /*******************************************************************
94 reads or writes a structure.
95 ********************************************************************/
96 void samr_io_q_open_domain(char *desc,  SAMR_Q_OPEN_DOMAIN *q_u, prs_struct *ps, int depth)
97 {
98         if (q_u == NULL) return;
99
100         prs_debug(ps, depth, desc, "samr_io_q_open_domain");
101         depth++;
102
103         prs_align(ps);
104
105         smb_io_pol_hnd("connect_pol", &(q_u->connect_pol), ps, depth); 
106         prs_align(ps);
107
108         prs_uint32("rid", ps, depth, &(q_u->rid));
109
110         smb_io_dom_sid2("sid", &(q_u->dom_sid), ps, depth); 
111         prs_align(ps);
112 }
113
114
115 /*******************************************************************
116 reads or writes a structure.
117 ********************************************************************/
118 void samr_io_r_open_domain(char *desc,  SAMR_R_OPEN_DOMAIN *r_u, prs_struct *ps, int depth)
119 {
120         if (r_u == NULL) return;
121
122         prs_debug(ps, depth, desc, "samr_io_r_open_domain");
123         depth++;
124
125         prs_align(ps);
126
127         smb_io_pol_hnd("domain_pol", &(r_u->domain_pol), ps, depth); 
128         prs_align(ps);
129
130         prs_uint32("status", ps, depth, &(r_u->status));
131 }
132
133 /*******************************************************************
134 reads or writes a structure.
135 ********************************************************************/
136 void make_samr_q_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, POLICY_HND *user_pol)
137 {
138         if (q_u == NULL) return;
139
140         DEBUG(5,("samr_make_q_unknown_2c\n"));
141
142         memcpy(&q_u->user_pol, user_pol, sizeof(q_u->user_pol));
143 }
144
145
146 /*******************************************************************
147 reads or writes a structure.
148 ********************************************************************/
149 void samr_io_q_unknown_2c(char *desc,  SAMR_Q_UNKNOWN_2C *q_u, prs_struct *ps, int depth)
150 {
151         if (q_u == NULL) return;
152
153         prs_debug(ps, depth, desc, "samr_io_q_unknown_2c");
154         depth++;
155
156         prs_align(ps);
157
158         smb_io_pol_hnd("user_pol", &(q_u->user_pol), ps, depth); 
159         prs_align(ps);
160 }
161
162 /*******************************************************************
163 makes a structure.
164 ********************************************************************/
165 void make_samr_r_unknown_2c(SAMR_R_UNKNOWN_2C *q_u, uint32 status)
166 {
167         if (q_u == NULL) return;
168
169         DEBUG(5,("samr_make_r_unknown_2c\n"));
170
171         q_u->unknown_0 = 0x00160000;
172         q_u->unknown_1 = 0x00000000;
173         q_u->status    = status;
174 }
175
176
177 /*******************************************************************
178 reads or writes a structure.
179 ********************************************************************/
180 void samr_io_r_unknown_2c(char *desc,  SAMR_R_UNKNOWN_2C *r_u, prs_struct *ps, int depth)
181 {
182         if (r_u == NULL) return;
183
184         prs_debug(ps, depth, desc, "samr_io_r_unknown_2c");
185         depth++;
186
187         prs_align(ps);
188
189         prs_uint32("unknown_0", ps, depth, &(r_u->unknown_0));
190         prs_uint32("unknown_1", ps, depth, &(r_u->unknown_1));
191         prs_uint32("status   ", ps, depth, &(r_u->status   ));
192 }
193
194 /*******************************************************************
195 reads or writes a structure.
196 ********************************************************************/
197 void make_samr_q_unknown_3(SAMR_Q_UNKNOWN_3 *q_u,
198                                 POLICY_HND *user_pol, uint16 switch_value)
199 {
200         if (q_u == NULL) return;
201
202         DEBUG(5,("samr_make_q_unknown_3\n"));
203
204         memcpy(&q_u->user_pol, user_pol, sizeof(q_u->user_pol));
205         q_u->switch_value = switch_value;
206 }
207
208
209 /*******************************************************************
210 reads or writes a structure.
211 ********************************************************************/
212 void samr_io_q_unknown_3(char *desc,  SAMR_Q_UNKNOWN_3 *q_u, prs_struct *ps, int depth)
213 {
214         if (q_u == NULL) return;
215
216         prs_debug(ps, depth, desc, "samr_io_q_unknown_3");
217         depth++;
218
219         prs_align(ps);
220
221         smb_io_pol_hnd("user_pol", &(q_u->user_pol), ps, depth); 
222         prs_align(ps);
223
224         prs_uint16("switch_value", ps, depth, &(q_u->switch_value));
225         prs_align(ps);
226 }
227
228 /*******************************************************************
229 reads or writes a structure.
230 ********************************************************************/
231 void make_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u,
232                                 POLICY_HND *domain_pol, uint16 switch_value)
233 {
234         if (q_u == NULL) return;
235
236         DEBUG(5,("samr_make_q_query_dom_info\n"));
237
238         memcpy(&q_u->domain_pol, domain_pol, sizeof(q_u->domain_pol));
239         q_u->switch_value = switch_value;
240 }
241
242 /*******************************************************************
243 reads or writes a structure.
244 ********************************************************************/
245 void samr_io_q_query_dom_info(char *desc,  SAMR_Q_QUERY_DOMAIN_INFO *q_u, prs_struct *ps, int depth)
246 {
247         if (q_u == NULL) return;
248
249         prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
250         depth++;
251
252         prs_align(ps);
253
254         smb_io_pol_hnd("domain_pol", &(q_u->domain_pol), ps, depth); 
255         prs_align(ps);
256
257         prs_uint16("switch_value", ps, depth, &(q_u->switch_value));
258         prs_align(ps);
259 }
260
261 /*******************************************************************
262 makes a structure.
263 ********************************************************************/
264 void make_unk_info2(SAM_UNK_INFO_2 *u_2, char *domain, char *server)
265 {
266         int len_domain = strlen(domain);
267         int len_server = strlen(server);
268
269         if (u_2 == NULL) return;
270
271         u_2->unknown_0 = 0x00000000;
272         u_2->unknown_1 = 0x80000000;
273         u_2->unknown_2 = 0x00000000;
274
275         u_2->ptr_0 = 1;
276         make_uni_hdr(&(u_2->hdr_domain), len_domain, len_domain, 1);
277         make_uni_hdr(&(u_2->hdr_server), len_server, len_server, 1);
278
279         u_2->seq_num = 0x10000000;
280         u_2->unknown_3 = 0x00000000;
281         
282         u_2->unknown_4  = 0x00000001;
283         u_2->unknown_5  = 0x00000003;
284         u_2->unknown_6  = 0x00000001;
285         u_2->num_domain_usrs  = 0x00000008;
286         u_2->num_domain_grps = 0x00000003;
287         u_2->num_local_grps = 0x00000003;
288
289         memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
290
291         make_unistr2(&u_2->uni_domain, domain, len_domain);
292         make_unistr2(&u_2->uni_server, server, len_server);
293 }
294
295 /*******************************************************************
296 reads or writes a structure.
297 ********************************************************************/
298 void sam_io_unk_info2(char *desc, SAM_UNK_INFO_2 *u_2, prs_struct *ps, int depth)
299 {
300         if (u_2 == NULL) return;
301
302         prs_debug(ps, depth, desc, "sam_io_unk_info2");
303         depth++;
304
305         prs_uint32("unknown_0", ps, depth, &u_2->unknown_0); /* 0x0000 0000 */
306         prs_uint32("unknown_1", ps, depth, &u_2->unknown_1); /* 0x8000 0000 */
307         prs_uint32("unknown_2", ps, depth, &u_2->unknown_2); /* 0x0000 0000 */
308
309         prs_uint32("ptr_0", ps, depth, &u_2->ptr_0);     /* pointer to unknown structure */
310         smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth); /* domain name unicode header */
311         smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth); /* server name unicode header */
312
313         /* put all the data in here, at the moment, including what the above
314            pointer is referring to
315          */
316
317         prs_uint32("seq_num ", ps, depth, &u_2->seq_num ); /* 0x0000 0099 or 0x1000 0000 */
318         prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3 ); /* 0x0000 0000 */
319         
320         prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4 ); /* 0x0000 0001 */
321         prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5 ); /* 0x0000 0003 */
322         prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6 ); /* 0x0000 0001 */
323         prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs ); /* 0x0000 0008 */
324         prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps); /* 0x0000 0003 */
325         prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps); /* 0x0000 0003 */
326
327         prs_uint8s(False, "padding", ps, depth, u_2->padding, sizeof(u_2->padding)); /* 12 bytes zeros */
328
329         smb_io_unistr2( "uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth); /* domain name unicode string */
330         smb_io_unistr2( "uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth); /* server name unicode string */
331
332         prs_align(ps);
333
334 }
335
336 /*******************************************************************
337 makes a SAMR_R_QUERY_DOMAIN_INFO structure.
338 ********************************************************************/
339 void make_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO *r_u, 
340                                 uint16 switch_value, SAM_UNK_CTR *ctr,
341                                 uint32 status)
342 {
343         if (r_u == NULL || ctr == NULL) return;
344
345         DEBUG(5,("make_samr_r_query_dom_info\n"));
346
347         r_u->ptr_0 = 0;
348         r_u->switch_value = 0;
349         r_u->status = status; /* return status */
350
351         if (status == 0)
352         {
353                 r_u->switch_value = switch_value;
354                 r_u->ptr_0 = 1;
355                 r_u->ctr = ctr;
356         }
357 }
358
359 /*******************************************************************
360 reads or writes a structure.
361 ********************************************************************/
362 void samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO *r_u, prs_struct *ps, int depth)
363 {
364         if (r_u == NULL) return;
365
366         prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
367         depth++;
368
369         prs_align(ps);
370
371         prs_uint32("ptr_0       ", ps, depth, &(r_u->ptr_0));
372         prs_uint16("switch_value", ps, depth, &(r_u->switch_value));
373         prs_align(ps);
374
375         if (r_u->ptr_0 != 0 && r_u->ctr != NULL)
376         {
377                 switch (r_u->switch_value)
378                 {
379                         case 0x02:
380                         {
381                                 sam_io_unk_info2("unk_inf2", &r_u->ctr->info.inf2, ps, depth);
382                                 break;
383                         }
384                         default:
385                         {
386                                 DEBUG(3,("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
387                                           r_u->switch_value));
388                                 return;
389                         }
390                 }
391         }
392 }
393
394
395 /*******************************************************************
396  makes a DOM_SID3 structure.
397
398  calculate length by adding up the size of the components.
399  ********************************************************************/
400 void make_dom_sid3(DOM_SID3 *sid3, uint16 unk_0, uint16 unk_1, DOM_SID *sid)
401 {
402         if (sid3 == NULL) return;
403
404     sid3->sid = *sid;
405         sid3->len = 2 + 8 + sid3->sid.num_auths * 4;
406 }
407
408 /*******************************************************************
409 reads or writes a SAM_SID3 structure.
410
411 this one's odd, because the length (in bytes) is specified at the beginning.
412 the length _includes_ the length of the length, too :-)
413
414 ********************************************************************/
415 static void sam_io_dom_sid3(char *desc,  DOM_SID3 *sid3, prs_struct *ps, int depth)
416 {
417         if (sid3 == NULL) return;
418
419         prs_debug(ps, depth, desc, "sam_io_dom_sid3");
420         depth++;
421
422         prs_uint16("len", ps, depth, &(sid3->len));
423         prs_align(ps);
424         smb_io_dom_sid("", &(sid3->sid), ps, depth); 
425 }
426
427 /*******************************************************************
428 makes a SAMR_R_UNKNOWN3 structure.
429
430 unknown_2   : 0x0001
431 unknown_3   : 0x8004
432
433 unknown_4,5 : 0x0000 0014
434
435 unknown_6   : 0x0002
436 unknown_7   : 0x5800 or 0x0070
437
438 ********************************************************************/
439 static void make_sam_sid_stuff(SAM_SID_STUFF *stf,
440                                 uint16 unknown_2, uint16 unknown_3,
441                                 uint32 unknown_4, uint16 unknown_6, uint16 unknown_7,
442                                 int num_sid3s, DOM_SID3 sid3[MAX_SAM_SIDS])
443 {
444         stf->unknown_2 = unknown_2;
445         stf->unknown_3 = unknown_3;
446
447         bzero(stf->padding1, sizeof(stf->padding1));
448
449         stf->unknown_4 = unknown_4;
450         stf->unknown_5 = unknown_4;
451
452         stf->unknown_6 = unknown_6;
453         stf->unknown_7 = unknown_7;
454
455         stf->num_sids  = num_sid3s;
456
457         stf->padding2  = 0x0000;
458
459         memcpy(stf->sid, sid3, sizeof(DOM_SID3) * num_sid3s);
460 }
461
462 /*******************************************************************
463 reads or writes a SAM_SID_STUFF structure.
464 ********************************************************************/
465 static void sam_io_sid_stuff(char *desc,  SAM_SID_STUFF *stf, prs_struct *ps, int depth)
466 {
467         int i;
468
469         if (stf == NULL) return;
470
471         DEBUG(5,("make_sam_sid_stuff\n"));
472
473         prs_uint16("unknown_2", ps, depth, &(stf->unknown_2));
474         prs_uint16("unknown_3", ps, depth, &(stf->unknown_3));
475
476         prs_uint8s(False, "padding1", ps, depth, stf->padding1, sizeof(stf->padding1)); 
477         
478         prs_uint32("unknown_4", ps, depth, &(stf->unknown_4));
479         prs_uint32("unknown_5", ps, depth, &(stf->unknown_5));
480         prs_uint16("unknown_6", ps, depth, &(stf->unknown_6));
481         prs_uint16("unknown_7", ps, depth, &(stf->unknown_7));
482
483         prs_uint32("num_sids ", ps, depth, &(stf->num_sids ));
484         prs_uint16("padding2 ", ps, depth, &(stf->padding2 ));
485
486         SMB_ASSERT_ARRAY(stf->sid, stf->num_sids);
487
488         for (i = 0; i < stf->num_sids; i++)
489         {
490                 sam_io_dom_sid3("", &(stf->sid[i]), ps, depth); 
491         }
492 }
493
494 /*******************************************************************
495 reads or writes a SAMR_R_UNKNOWN3 structure.
496 ********************************************************************/
497 void make_samr_r_unknown_3(SAMR_R_UNKNOWN_3 *r_u,
498                                 uint16 unknown_2, uint16 unknown_3,
499                                 uint32 unknown_4, uint16 unknown_6, uint16 unknown_7,
500                                 int num_sid3s, DOM_SID3 sid3[MAX_SAM_SIDS],
501                                 uint32 status)
502 {
503         if (r_u == NULL) return;
504
505         DEBUG(5,("samr_make_r_unknown_3\n"));
506
507         r_u->ptr_0 = 0;
508         r_u->ptr_1 = 0;
509
510         if (status == 0x0)
511         {
512                 r_u->ptr_0 = 1;
513                 r_u->ptr_1 = 1;
514                 make_sam_sid_stuff(&(r_u->sid_stuff), unknown_2, unknown_3,
515                        unknown_4, unknown_6, unknown_7,
516                        num_sid3s, sid3);
517         }
518
519         r_u->status = status;
520 }
521
522
523 /*******************************************************************
524 reads or writes a SAMR_R_UNKNOWN_3 structure.
525
526 this one's odd, because the daft buggers use a different mechanism
527 for writing out the array of sids. they put the number of sids in
528 only one place: they've calculated the length of each sid and jumped
529 by that amount.  then, retrospectively, the length of the whole buffer
530 is put at the beginning of the data stream.
531
532 wierd.  
533
534 ********************************************************************/
535 void samr_io_r_unknown_3(char *desc,  SAMR_R_UNKNOWN_3 *r_u, prs_struct *ps, int depth)
536 {
537         int ptr_len0=0;
538         int ptr_len1=0;
539         int ptr_sid_stuff = 0;
540
541         if (r_u == NULL) return;
542
543         prs_debug(ps, depth, desc, "samr_io_r_unknown_3");
544         depth++;
545
546         prs_align(ps);
547
548         prs_uint32("ptr_0         ", ps, depth, &(r_u->ptr_0         ));
549
550         if (ps->io) 
551         {
552                 /* reading.  do the length later */
553                 prs_uint32("sid_stuff_len0", ps, depth, &(r_u->sid_stuff_len0));
554         }
555         else
556         {
557                 /* storing */
558                 ptr_len0 = ps->offset; ps->offset += 4;
559         }
560
561         if (r_u->ptr_0 != 0)
562         {
563                 prs_uint32("ptr_1         ", ps, depth, &(r_u->ptr_1         ));
564                 if (ps->io)
565                 {
566                         /* reading.  do the length later */
567                         prs_uint32("sid_stuff_len1", ps, depth, &(r_u->sid_stuff_len1));
568                 }
569                 else
570                 {
571                         /* storing */
572                         ptr_len1 = ps->offset; ps->offset += 4;
573                 }
574
575                 if (r_u->ptr_1 != 0)
576                 {
577                         ptr_sid_stuff = ps->offset;
578                         sam_io_sid_stuff("", &(r_u->sid_stuff), ps, depth); 
579                 }
580         }
581
582         if (!(ps->io)) /* storing not reading.  do the length, now. */
583         {
584                 if (ptr_sid_stuff != 0)
585                 {
586                         uint32 sid_stuff_len = ps->offset - ptr_sid_stuff;
587                         int old_len = ps->offset;
588
589                         ps->offset = ptr_len0;
590                         prs_uint32("sid_stuff_len0", ps, depth, &sid_stuff_len); 
591
592                         ps->offset = ptr_len1;
593                         prs_uint32("sid_stuff_len1", ps, depth, &sid_stuff_len);
594
595                         ps->offset = old_len;
596                 }
597         }
598
599         prs_uint32("status", ps, depth, &(r_u->status));
600 }
601
602 /*******************************************************************
603 reads or writes a SAM_STR1 structure.
604 ********************************************************************/
605 static void sam_io_sam_str1(char *desc,  SAM_STR1 *sam, uint32 acct_buf, uint32 name_buf, uint32 desc_buf, prs_struct *ps, int depth)
606 {
607         if (sam == NULL) return;
608
609         prs_debug(ps, depth, desc, "sam_io_sam_str1");
610         depth++;
611
612         prs_align(ps);
613
614         smb_io_unistr2("unistr2", &(sam->uni_acct_name), acct_buf, ps, depth); /* account name unicode string */
615         smb_io_unistr2("unistr2", &(sam->uni_full_name), name_buf, ps, depth); /* full name unicode string */
616         smb_io_unistr2("unistr2", &(sam->uni_acct_desc), desc_buf, ps, depth); /* account description unicode string */
617 }
618
619 /*******************************************************************
620 makes a SAM_ENTRY1 structure.
621 ********************************************************************/
622 static void make_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx, 
623                                 uint32 len_sam_name, uint32 len_sam_full, uint32 len_sam_desc,
624                                 uint32 rid_user, uint16 acb_info)
625 {
626         if (sam == NULL) return;
627
628         DEBUG(5,("make_sam_entry1\n"));
629
630         sam->user_idx = user_idx;
631         sam->rid_user = rid_user;
632         sam->acb_info = acb_info;
633         sam->pad      = 0;
634
635         make_uni_hdr(&(sam->hdr_acct_name), len_sam_name, len_sam_name, len_sam_name != 0);
636         make_uni_hdr(&(sam->hdr_user_name), len_sam_full, len_sam_full, len_sam_full != 0);
637         make_uni_hdr(&(sam->hdr_user_desc), len_sam_desc, len_sam_desc, len_sam_desc != 0);
638 }
639
640 /*******************************************************************
641 reads or writes a SAM_ENTRY1 structure.
642 ********************************************************************/
643 static void sam_io_sam_entry1(char *desc,  SAM_ENTRY1 *sam, prs_struct *ps, int depth)
644 {
645         if (sam == NULL) return;
646
647         prs_debug(ps, depth, desc, "sam_io_sam_entry1");
648         depth++;
649
650         prs_align(ps);
651
652         prs_uint32("user_idx ", ps, depth, &(sam->user_idx ));
653
654         prs_uint32("rid_user ", ps, depth, &(sam->rid_user ));
655         prs_uint16("acb_info ", ps, depth, &(sam->acb_info ));
656         prs_uint16("pad      ", ps, depth, &(sam->pad      ));
657
658         smb_io_unihdr("unihdr", &(sam->hdr_acct_name), ps, depth); /* account name unicode string header */
659         smb_io_unihdr("unihdr", &(sam->hdr_user_name), ps, depth); /* account name unicode string header */
660         smb_io_unihdr("unihdr", &(sam->hdr_user_desc), ps, depth); /* account name unicode string header */
661 }
662
663 /*******************************************************************
664 reads or writes a SAM_STR2 structure.
665 ********************************************************************/
666 static void sam_io_sam_str2(char *desc,  SAM_STR2 *sam, uint32 acct_buf, uint32 desc_buf, prs_struct *ps, int depth)
667 {
668         if (sam == NULL) return;
669
670         prs_debug(ps, depth, desc, "sam_io_sam_str2");
671         depth++;
672
673         prs_align(ps);
674
675         smb_io_unistr2("unistr2", &(sam->uni_srv_name), acct_buf, ps, depth); /* account name unicode string */
676         smb_io_unistr2("unistr2", &(sam->uni_srv_desc), desc_buf, ps, depth); /* account description unicode string */
677 }
678
679 /*******************************************************************
680 makes a SAM_ENTRY2 structure.
681 ********************************************************************/
682 static void make_sam_entry2(SAM_ENTRY2 *sam, uint32 user_idx, 
683                                 uint32 len_sam_name, uint32 len_sam_desc,
684                                 uint32 rid_user, uint16 acb_info)
685 {
686         if (sam == NULL) return;
687
688         DEBUG(5,("make_sam_entry2\n"));
689
690         sam->user_idx = user_idx;
691         sam->rid_user = rid_user;
692         sam->acb_info = acb_info;
693         sam->pad      = 0;
694
695         make_uni_hdr(&(sam->hdr_srv_name), len_sam_name, len_sam_name, len_sam_name != 0);
696         make_uni_hdr(&(sam->hdr_srv_desc), len_sam_desc, len_sam_desc, len_sam_desc != 0);
697 }
698
699 /*******************************************************************
700 reads or writes a SAM_ENTRY2 structure.
701 ********************************************************************/
702 static void sam_io_sam_entry2(char *desc,  SAM_ENTRY2 *sam, prs_struct *ps, int depth)
703 {
704         if (sam == NULL) return;
705
706         prs_debug(ps, depth, desc, "sam_io_sam_entry2");
707         depth++;
708
709         prs_align(ps);
710
711         prs_uint32("user_idx ", ps, depth, &(sam->user_idx ));
712
713         prs_uint32("rid_user ", ps, depth, &(sam->rid_user ));
714         prs_uint16("acb_info ", ps, depth, &(sam->acb_info ));
715         prs_uint16("pad      ", ps, depth, &(sam->pad      ));
716
717         smb_io_unihdr("unihdr", &(sam->hdr_srv_name), ps, depth); /* account name unicode string header */
718         smb_io_unihdr("unihdr", &(sam->hdr_srv_desc), ps, depth); /* account name unicode string header */
719 }
720
721 /*******************************************************************
722 reads or writes a SAM_STR3 structure.
723 ********************************************************************/
724 static void sam_io_sam_str3(char *desc,  SAM_STR3 *sam, uint32 acct_buf, uint32 desc_buf, prs_struct *ps, int depth)
725 {
726         if (sam == NULL) return;
727
728         prs_debug(ps, depth, desc, "sam_io_sam_str3");
729         depth++;
730
731         prs_align(ps);
732
733         smb_io_unistr2("unistr2", &(sam->uni_grp_name), acct_buf, ps, depth); /* account name unicode string */
734         smb_io_unistr2("unistr2", &(sam->uni_grp_desc), desc_buf, ps, depth); /* account description unicode string */
735 }
736
737 /*******************************************************************
738 makes a SAM_ENTRY3 structure.
739 ********************************************************************/
740 static void make_sam_entry3(SAM_ENTRY3 *sam, uint32 grp_idx, 
741                                 uint32 len_grp_name, uint32 len_grp_desc, uint32 rid_grp)
742 {
743         if (sam == NULL) return;
744
745         DEBUG(5,("make_sam_entry3\n"));
746
747         sam->grp_idx = grp_idx;
748         sam->rid_grp = rid_grp;
749         sam->attr    = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
750
751         make_uni_hdr(&(sam->hdr_grp_name), len_grp_name, len_grp_name, len_grp_name != 0);
752         make_uni_hdr(&(sam->hdr_grp_desc), len_grp_desc, len_grp_desc, len_grp_desc != 0);
753 }
754
755 /*******************************************************************
756 reads or writes a SAM_ENTRY3 structure.
757 ********************************************************************/
758 static void sam_io_sam_entry3(char *desc,  SAM_ENTRY3 *sam, prs_struct *ps, int depth)
759 {
760         if (sam == NULL) return;
761
762         prs_debug(ps, depth, desc, "sam_io_sam_entry3");
763         depth++;
764
765         prs_align(ps);
766
767         prs_uint32("grp_idx", ps, depth, &(sam->grp_idx));
768
769         prs_uint32("rid_grp", ps, depth, &(sam->rid_grp));
770         prs_uint32("attr   ", ps, depth, &(sam->attr   ));
771
772         smb_io_unihdr("unihdr", &(sam->hdr_grp_name), ps, depth); /* account name unicode string header */
773         smb_io_unihdr("unihdr", &(sam->hdr_grp_desc), ps, depth); /* account name unicode string header */
774 }
775
776 /*******************************************************************
777 makes a SAM_ENTRY structure.
778 ********************************************************************/
779 static void make_sam_entry(SAM_ENTRY *sam, uint32 len_sam_name, uint32 rid)
780 {
781         if (sam == NULL) return;
782
783         DEBUG(5,("make_sam_entry\n"));
784
785         sam->rid = rid;
786         make_uni_hdr(&(sam->hdr_name), len_sam_name, len_sam_name, len_sam_name != 0);
787 }
788
789 /*******************************************************************
790 reads or writes a SAM_ENTRY structure.
791 ********************************************************************/
792 static void sam_io_sam_entry(char *desc,  SAM_ENTRY *sam, prs_struct *ps, int depth)
793 {
794         if (sam == NULL) return;
795
796         prs_debug(ps, depth, desc, "sam_io_sam_entry");
797         depth++;
798
799         prs_align(ps);
800         prs_uint32("rid", ps, depth, &(sam->rid ));
801         smb_io_unihdr("unihdr", &(sam->hdr_name), ps, depth); /* account name unicode string header */
802 }
803
804
805 /*******************************************************************
806 makes a SAMR_Q_ENUM_DOM_USERS structure.
807 ********************************************************************/
808 void make_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_e, POLICY_HND *pol,
809                                 uint16 req_num_entries, uint16 unk_0,
810                                 uint16 acb_mask, uint16 unk_1, uint32 size)
811 {
812         if (q_e == NULL || pol == NULL) return;
813
814         DEBUG(5,("make_q_enum_dom_users\n"));
815
816         memcpy(&(q_e->pol), pol, sizeof(*pol));
817
818         q_e->req_num_entries = req_num_entries; /* zero indicates lots */
819         q_e->unknown_0 = unk_0; /* this gets returned in the response */
820         q_e->acb_mask  = acb_mask;
821         q_e->unknown_1 = unk_1;
822         q_e->max_size = size;
823 }
824
825 /*******************************************************************
826 reads or writes a structure.
827 ********************************************************************/
828 void samr_io_q_enum_dom_users(char *desc,  SAMR_Q_ENUM_DOM_USERS *q_e, prs_struct *ps, int depth)
829 {
830         if (q_e == NULL) return;
831
832         prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
833         depth++;
834
835         prs_align(ps);
836
837         smb_io_pol_hnd("pol", &(q_e->pol), ps, depth); 
838         prs_align(ps);
839
840         prs_uint16("req_num_entries", ps, depth, &(q_e->req_num_entries));
841         prs_uint16("unknown_0      ", ps, depth, &(q_e->unknown_0      ));
842
843         prs_uint16("acb_mask       ", ps, depth, &(q_e->acb_mask       ));
844         prs_uint16("unknown_1      ", ps, depth, &(q_e->unknown_1      ));
845
846         prs_uint32("max_size       ", ps, depth, &(q_e->max_size       ));
847
848         prs_align(ps);
849 }
850
851
852 /*******************************************************************
853 makes a SAMR_R_ENUM_DOM_USERS structure.
854 ********************************************************************/
855 void make_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS *r_u,
856                 uint16 total_num_entries, uint16 unk_0,
857                 uint32 num_sam_entries, SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES], uint32 status)
858 {
859         int i;
860
861         if (r_u == NULL) return;
862
863         DEBUG(5,("make_samr_r_enum_dom_users\n"));
864
865         if (num_sam_entries >= MAX_SAM_ENTRIES)
866         {
867                 num_sam_entries = MAX_SAM_ENTRIES;
868                 DEBUG(5,("limiting number of entries to %d\n",
869                          num_sam_entries));
870         }
871
872         r_u->total_num_entries = total_num_entries;
873         r_u->unknown_0         = unk_0;
874
875         if (total_num_entries > 0)
876         {
877                 r_u->ptr_entries1 = 1;
878                 r_u->ptr_entries2 = 1;
879                 r_u->num_entries2 = num_sam_entries;
880                 r_u->num_entries3 = num_sam_entries;
881
882                 SMB_ASSERT_ARRAY(r_u->sam, num_sam_entries);
883                 SMB_ASSERT_ARRAY(r_u->uni_acct_name, num_sam_entries);
884
885                 for (i = 0; i < num_sam_entries; i++)
886                 {
887                         make_sam_entry(&(r_u->sam[i]),
888                                        pass[i].uni_user_name.uni_str_len,
889                                        pass[i].user_rid);
890
891                         copy_unistr2(&(r_u->uni_acct_name[i]), &(pass[i].uni_user_name));
892                 }
893
894                 r_u->num_entries4 = num_sam_entries;
895         }
896         else
897         {
898                 r_u->ptr_entries1 = 0;
899                 r_u->num_entries2 = num_sam_entries;
900                 r_u->ptr_entries2 = 1;
901         }
902
903         r_u->status = status;
904 }
905
906 /*******************************************************************
907 reads or writes a structure.
908 ********************************************************************/
909 void samr_io_r_enum_dom_users(char *desc,  SAMR_R_ENUM_DOM_USERS *r_u, prs_struct *ps, int depth)
910 {
911         int i;
912
913         if (r_u == NULL) return;
914
915         prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
916         depth++;
917
918         prs_align(ps);
919
920         prs_uint16("total_num_entries", ps, depth, &(r_u->total_num_entries));
921         prs_uint16("unknown_0        ", ps, depth, &(r_u->unknown_0        ));
922         prs_uint32("ptr_entries1", ps, depth, &(r_u->ptr_entries1));
923
924         if (r_u->total_num_entries != 0 && r_u->ptr_entries1 != 0)
925         {
926                 prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
927                 prs_uint32("ptr_entries2", ps, depth, &(r_u->ptr_entries2));
928                 prs_uint32("num_entries3", ps, depth, &(r_u->num_entries3));
929
930                 SMB_ASSERT_ARRAY(r_u->sam, r_u->num_entries2);
931
932                 for (i = 0; i < r_u->num_entries2; i++)
933                 {
934                         prs_grow(ps);
935                         sam_io_sam_entry("", &(r_u->sam[i]), ps, depth);
936                 }
937
938                 SMB_ASSERT_ARRAY(r_u->uni_acct_name, r_u->num_entries2);
939
940                 for (i = 0; i < r_u->num_entries2; i++)
941                 {
942                         prs_grow(ps);
943                         smb_io_unistr2("", &(r_u->uni_acct_name[i]), r_u->sam[i].hdr_name.buffer, ps, depth);
944                 }
945
946                 prs_align(ps);
947
948                 prs_uint32("num_entries4", ps, depth, &(r_u->num_entries4));
949         }
950
951         prs_uint32("status", ps, depth, &(r_u->status));
952 }
953
954 /*******************************************************************
955 makes a SAMR_Q_ENUM_DOM_ALIASES structure.
956 ********************************************************************/
957 void make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol, uint32 size)
958 {
959         if (q_e == NULL || pol == NULL) return;
960
961         DEBUG(5,("make_q_enum_dom_aliases\n"));
962
963         memcpy(&(q_e->pol), pol, sizeof(*pol));
964
965         q_e->unknown_0 = 0;
966         q_e->max_size = size;
967 }
968
969
970 /*******************************************************************
971 reads or writes a structure.
972 ********************************************************************/
973 void samr_io_q_enum_dom_aliases(char *desc,  SAMR_Q_ENUM_DOM_ALIASES *q_e, prs_struct *ps, int depth)
974 {
975         if (q_e == NULL) return;
976
977         prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
978         depth++;
979
980         prs_align(ps);
981
982         smb_io_pol_hnd("pol", &(q_e->pol), ps, depth); 
983         prs_align(ps);
984
985         prs_uint32("unknown_0", ps, depth, &(q_e->unknown_0));
986         prs_uint32("max_size ", ps, depth, &(q_e->max_size ));
987
988         prs_align(ps);
989 }
990
991
992 /*******************************************************************
993 makes a SAMR_R_ENUM_DOM_ALIASES structure.
994 ********************************************************************/
995 void make_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
996                 uint32 num_sam_entries, LOCAL_GRP *alss,
997                 uint32 status)
998 {
999         int i;
1000
1001         if (r_u == NULL) return;
1002
1003         DEBUG(5,("make_samr_r_enum_dom_aliases\n"));
1004
1005         if (num_sam_entries >= MAX_SAM_ENTRIES)
1006         {
1007                 num_sam_entries = MAX_SAM_ENTRIES;
1008                 DEBUG(5,("limiting number of entries to %d\n", 
1009                          num_sam_entries));
1010         }
1011
1012         r_u->num_entries  = num_sam_entries;
1013
1014         if (num_sam_entries > 0)
1015         {
1016                 r_u->ptr_entries  = 1;
1017                 r_u->num_entries2 = num_sam_entries;
1018                 r_u->ptr_entries2 = 1;
1019                 r_u->num_entries3 = num_sam_entries;
1020
1021                 SMB_ASSERT_ARRAY(r_u->sam, num_sam_entries);
1022
1023                 for (i = 0; i < num_sam_entries; i++)
1024                 {
1025                         int acct_name_len = strlen(alss[i].name);
1026
1027                         make_sam_entry(&(r_u->sam[i]),
1028                                         acct_name_len,
1029                                         alss[i].rid);
1030
1031                         make_unistr2(&(r_u->uni_grp_name[i]), alss[i].name   , acct_name_len);
1032                 }
1033
1034                 r_u->num_entries4 = num_sam_entries;
1035         }
1036         else
1037         {
1038                 r_u->ptr_entries = 0;
1039         }
1040
1041         r_u->status = status;
1042 }
1043
1044 /*******************************************************************
1045 reads or writes a structure.
1046 ********************************************************************/
1047 void samr_io_r_enum_dom_aliases(char *desc,  SAMR_R_ENUM_DOM_ALIASES *r_u, prs_struct *ps, int depth)
1048 {
1049         int i;
1050
1051         if (r_u == NULL) return;
1052
1053         prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
1054         depth++;
1055
1056         prs_align(ps);
1057
1058         prs_uint32("num_entries", ps, depth, &(r_u->num_entries));
1059         prs_uint32("ptr_entries", ps, depth, &(r_u->ptr_entries));
1060
1061         if (r_u->num_entries != 0 && r_u->ptr_entries != 0)
1062         {
1063                 prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
1064                 prs_uint32("ptr_entries2", ps, depth, &(r_u->ptr_entries2));
1065                 prs_uint32("num_entries3", ps, depth, &(r_u->num_entries3));
1066
1067                 SMB_ASSERT_ARRAY(r_u->sam, r_u->num_entries);
1068
1069                 for (i = 0; i < r_u->num_entries; i++)
1070                 {
1071                         sam_io_sam_entry("", &(r_u->sam[i]), ps, depth);
1072                 }
1073
1074                 for (i = 0; i < r_u->num_entries; i++)
1075                 {
1076                         smb_io_unistr2("", &(r_u->uni_grp_name[i]), r_u->sam[i].hdr_name.buffer, ps, depth);
1077                 }
1078
1079                 prs_align(ps);
1080
1081                 prs_uint32("num_entries4", ps, depth, &(r_u->num_entries4));
1082         }
1083
1084         prs_uint32("status", ps, depth, &(r_u->status));
1085 }
1086
1087
1088 /*******************************************************************
1089 makes a SAMR_Q_QUERY_DISPINFO structure.
1090 ********************************************************************/
1091 void make_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_e, POLICY_HND *pol,
1092                                 uint16 switch_level, uint32 start_idx, uint32 size)
1093 {
1094         if (q_e == NULL || pol == NULL) return;
1095
1096         DEBUG(5,("make_q_query_dispinfo\n"));
1097
1098         memcpy(&(q_e->pol), pol, sizeof(*pol));
1099
1100         q_e->switch_level = switch_level;
1101
1102         q_e->unknown_0 = 0;
1103         q_e->start_idx = start_idx;
1104         q_e->unknown_1 = 0x000007d0;
1105         q_e->max_size  = size;
1106 }
1107
1108 /*******************************************************************
1109 reads or writes a structure.
1110 ********************************************************************/
1111 void samr_io_q_query_dispinfo(char *desc,  SAMR_Q_QUERY_DISPINFO *q_e, prs_struct *ps, int depth)
1112 {
1113         if (q_e == NULL) return;
1114
1115         prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1116         depth++;
1117
1118         prs_align(ps);
1119
1120         smb_io_pol_hnd("pol", &(q_e->pol), ps, depth); 
1121         prs_align(ps);
1122
1123         prs_uint16("switch_level", ps, depth, &(q_e->switch_level));
1124         prs_uint16("unknown_0   ", ps, depth, &(q_e->unknown_0   ));
1125         prs_uint32("start_idx   ", ps, depth, &(q_e->start_idx   ));
1126         prs_uint32("unknown_1   ", ps, depth, &(q_e->unknown_1   ));
1127         prs_uint32("max_size    ", ps, depth, &(q_e->max_size    ));
1128
1129         prs_align(ps);
1130 }
1131
1132
1133 /*******************************************************************
1134 makes a SAM_INFO_2 structure.
1135 ********************************************************************/
1136 void make_sam_info_2(SAM_INFO_2 *sam, uint32 acb_mask,
1137                 uint32 start_idx, uint32 num_sam_entries,
1138                 SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
1139 {
1140         int i;
1141         int entries_added;
1142
1143         if (sam == NULL) return;
1144
1145         DEBUG(5,("make_sam_info_2\n"));
1146
1147         if (num_sam_entries >= MAX_SAM_ENTRIES)
1148         {
1149                 num_sam_entries = MAX_SAM_ENTRIES;
1150                 DEBUG(5,("limiting number of entries to %d\n", 
1151                          num_sam_entries));
1152         }
1153
1154         for (i = start_idx, entries_added = 0; i < num_sam_entries; i++)
1155         {
1156                 if (IS_BITS_SET_ALL(pass[i].acb_info, acb_mask))
1157                 {
1158                         make_sam_entry2(&(sam->sam[entries_added]),
1159                                         start_idx + entries_added + 1,
1160                                         pass[i].uni_user_name.uni_str_len,
1161                                         pass[i].uni_acct_desc.uni_str_len,
1162                                         pass[i].user_rid,
1163                                         pass[i].acb_info);
1164
1165                         copy_unistr2(&(sam->str[entries_added].uni_srv_name), &(pass[i].uni_user_name));
1166                         copy_unistr2(&(sam->str[entries_added].uni_srv_desc), &(pass[i].uni_acct_desc));
1167
1168                         entries_added++;
1169                 }
1170
1171                 sam->num_entries   = entries_added;
1172                 sam->ptr_entries   = 1;
1173                 sam->num_entries2  = entries_added;
1174         }
1175 }
1176
1177 /*******************************************************************
1178 reads or writes a structure.
1179 ********************************************************************/
1180 static void sam_io_sam_info_2(char *desc,  SAM_INFO_2 *sam, prs_struct *ps, int depth)
1181 {
1182         int i;
1183
1184         if (sam == NULL) return;
1185
1186         prs_debug(ps, depth, desc, "sam_io_sam_info_2");
1187         depth++;
1188
1189         prs_align(ps);
1190
1191         prs_uint32("num_entries  ", ps, depth, &(sam->num_entries  ));
1192         prs_uint32("ptr_entries  ", ps, depth, &(sam->ptr_entries  ));
1193
1194         prs_uint32("num_entries2 ", ps, depth, &(sam->num_entries2 ));
1195
1196         SMB_ASSERT_ARRAY(sam->sam, sam->num_entries);
1197
1198         for (i = 0; i < sam->num_entries; i++)
1199         {
1200                 prs_grow(ps);
1201                 sam_io_sam_entry2("", &(sam->sam[i]), ps, depth);
1202         }
1203
1204         for (i = 0; i < sam->num_entries; i++)
1205         {
1206                 prs_grow(ps);
1207                 sam_io_sam_str2 ("", &(sam->str[i]),
1208                                                          sam->sam[i].hdr_srv_name.buffer,
1209                                                          sam->sam[i].hdr_srv_desc.buffer,
1210                                                          ps, depth);
1211         }
1212 }
1213
1214
1215 /*******************************************************************
1216 makes a SAM_INFO_1 structure.
1217 ********************************************************************/
1218 void make_sam_info_1(SAM_INFO_1 *sam, uint32 acb_mask,
1219                 uint32 start_idx, uint32 num_sam_entries,
1220                 SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
1221 {
1222         int i;
1223         int entries_added;
1224
1225         if (sam == NULL) return;
1226
1227         DEBUG(5,("make_sam_info_1\n"));
1228
1229         if (num_sam_entries >= MAX_SAM_ENTRIES)
1230         {
1231                 num_sam_entries = MAX_SAM_ENTRIES;
1232                 DEBUG(5,("limiting number of entries to %d\n", 
1233                          num_sam_entries));
1234         }
1235
1236         for (i = start_idx, entries_added = 0; i < num_sam_entries; i++)
1237         {
1238                 if (IS_BITS_SET_ALL(pass[i].acb_info, acb_mask))
1239                 {
1240                         make_sam_entry1(&(sam->sam[entries_added]),
1241                                                 start_idx + entries_added + 1,
1242                                                 pass[i].uni_user_name.uni_str_len,
1243                                                 pass[i].uni_full_name.uni_str_len, 
1244                                                 pass[i].uni_acct_desc.uni_str_len,
1245                                                 pass[i].user_rid,
1246                                                 pass[i].acb_info);
1247
1248                         copy_unistr2(&(sam->str[entries_added].uni_acct_name), &(pass[i].uni_user_name));
1249                         copy_unistr2(&(sam->str[entries_added].uni_full_name), &(pass[i].uni_full_name));
1250                         copy_unistr2(&(sam->str[entries_added].uni_acct_desc), &(pass[i].uni_acct_desc));
1251
1252                         entries_added++;
1253                 }
1254         }
1255
1256         sam->num_entries   = entries_added;
1257         sam->ptr_entries   = 1;
1258         sam->num_entries2  = entries_added;
1259 }
1260
1261
1262 /*******************************************************************
1263 reads or writes a structure.
1264 ********************************************************************/
1265 static void sam_io_sam_info_1(char *desc,  SAM_INFO_1 *sam, prs_struct *ps, int depth)
1266 {
1267         int i;
1268
1269         if (sam == NULL) return;
1270
1271         prs_debug(ps, depth, desc, "sam_io_sam_info_1");
1272         depth++;
1273
1274         prs_align(ps);
1275
1276         prs_uint32("num_entries  ", ps, depth, &(sam->num_entries  ));
1277         prs_uint32("ptr_entries  ", ps, depth, &(sam->ptr_entries  ));
1278
1279         prs_uint32("num_entries2 ", ps, depth, &(sam->num_entries2 ));
1280
1281         SMB_ASSERT_ARRAY(sam->sam, sam->num_entries);
1282
1283         for (i = 0; i < sam->num_entries; i++)
1284         {
1285                 prs_grow(ps);
1286                 sam_io_sam_entry1("", &(sam->sam[i]), ps, depth);
1287         }
1288
1289         for (i = 0; i < sam->num_entries; i++)
1290         {
1291                 prs_grow(ps);
1292                 sam_io_sam_str1 ("", &(sam->str[i]),
1293                                                          sam->sam[i].hdr_acct_name.buffer,
1294                                                          sam->sam[i].hdr_user_name.buffer,
1295                                                          sam->sam[i].hdr_user_desc.buffer,
1296                                                          ps, depth);
1297         }
1298 }
1299
1300
1301 /*******************************************************************
1302 makes a SAMR_R_QUERY_DISPINFO structure.
1303 ********************************************************************/
1304 void make_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO *r_u,
1305                 uint16 switch_level, SAM_INFO_CTR *ctr, uint32 status)
1306 {
1307         if (r_u == NULL) return;
1308
1309         DEBUG(5,("make_samr_r_query_dispinfo\n"));
1310
1311         if (status == 0x0)
1312         {
1313                 r_u->unknown_0 = 0x0000001;
1314                 r_u->unknown_1 = 0x0000001;
1315         }
1316         else
1317         {
1318                 r_u->unknown_0 = 0x0;
1319                 r_u->unknown_1 = 0x0;
1320         }
1321
1322         r_u->switch_level = switch_level;
1323         r_u->ctr = ctr;
1324         r_u->status = status;
1325 }
1326
1327
1328 /*******************************************************************
1329 reads or writes a structure.
1330 ********************************************************************/
1331 void samr_io_r_query_dispinfo(char *desc,  SAMR_R_QUERY_DISPINFO *r_u, prs_struct *ps, int depth)
1332 {
1333         if (r_u == NULL) return;
1334
1335         prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
1336         depth++;
1337
1338         prs_align(ps);
1339
1340         prs_uint32("unknown_0    ", ps, depth, &(r_u->unknown_0    ));
1341         prs_uint32("unknown_1    ", ps, depth, &(r_u->unknown_1    ));
1342         prs_uint16("switch_level ", ps, depth, &(r_u->switch_level ));
1343
1344         prs_align(ps);
1345
1346         switch (r_u->switch_level)
1347         {
1348                 case 0x1:
1349                 {
1350                         sam_io_sam_info_1("users", r_u->ctr->sam.info1, ps, depth);
1351                         break;
1352                 }
1353                 case 0x2:
1354                 {
1355                         sam_io_sam_info_2("servers", r_u->ctr->sam.info2, ps, depth);
1356                         break;
1357                 }
1358                 default:
1359                 {
1360                         DEBUG(5,("samr_io_r_query_dispinfo: unknown switch value\n"));
1361                         break;
1362                 }
1363         }
1364
1365         prs_uint32("status", ps, depth, &(r_u->status));
1366 }
1367
1368
1369 /*******************************************************************
1370 makes a SAMR_Q_ENUM_DOM_GROUPS structure.
1371 ********************************************************************/
1372 void make_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol,
1373                                 uint16 switch_level, uint32 start_idx, uint32 size)
1374 {
1375         if (q_e == NULL || pol == NULL) return;
1376
1377         DEBUG(5,("make_q_enum_dom_groups\n"));
1378
1379         memcpy(&(q_e->pol), pol, sizeof(*pol));
1380
1381         q_e->switch_level = switch_level;
1382
1383         q_e->unknown_0 = 0;
1384         q_e->start_idx = start_idx;
1385         q_e->unknown_1 = 0x000007d0;
1386         q_e->max_size  = size;
1387 }
1388
1389
1390 /*******************************************************************
1391 reads or writes a structure.
1392 ********************************************************************/
1393 void samr_io_q_enum_dom_groups(char *desc,  SAMR_Q_ENUM_DOM_GROUPS *q_e, prs_struct *ps, int depth)
1394 {
1395         if (q_e == NULL) return;
1396
1397         prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
1398         depth++;
1399
1400         prs_align(ps);
1401
1402         smb_io_pol_hnd("pol", &(q_e->pol), ps, depth); 
1403         prs_align(ps);
1404
1405         prs_uint16("switch_level", ps, depth, &(q_e->switch_level));
1406         prs_uint16("unknown_0   ", ps, depth, &(q_e->unknown_0   ));
1407         prs_uint32("start_idx   ", ps, depth, &(q_e->start_idx   ));
1408         prs_uint32("unknown_1   ", ps, depth, &(q_e->unknown_1   ));
1409         prs_uint32("max_size    ", ps, depth, &(q_e->max_size    ));
1410
1411         prs_align(ps);
1412 }
1413
1414
1415 /*******************************************************************
1416 makes a SAMR_R_ENUM_DOM_GROUPS structure.
1417 ********************************************************************/
1418 void make_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS *r_u,
1419                 uint32 start_idx, uint32 num_sam_entries,
1420                 DOMAIN_GRP *grp,
1421                 uint32 status)
1422 {
1423         int i;
1424         int entries_added;
1425
1426         if (r_u == NULL) return;
1427
1428         DEBUG(5,("make_samr_r_enum_dom_groups\n"));
1429
1430         if (num_sam_entries >= MAX_SAM_ENTRIES)
1431         {
1432                 num_sam_entries = MAX_SAM_ENTRIES;
1433                 DEBUG(5,("limiting number of entries to %d\n", 
1434                          num_sam_entries));
1435         }
1436
1437         if (status == 0x0)
1438         {
1439                 for (i = start_idx, entries_added = 0; i < num_sam_entries; i++)
1440                 {
1441                         int acct_name_len = strlen(grp[i].name);
1442                         int acct_desc_len = strlen(grp[i].comment);
1443
1444                         make_sam_entry3(&(r_u->sam[entries_added]),
1445                                         start_idx + entries_added + 1,
1446                                         acct_name_len,
1447                                         acct_desc_len,
1448                                         grp[i].rid);
1449
1450                         make_unistr2(&(r_u->str[entries_added].uni_grp_name), grp[i].name   , acct_name_len);
1451                         make_unistr2(&(r_u->str[entries_added].uni_grp_desc), grp[i].comment, acct_desc_len);
1452
1453                         entries_added++;
1454                 }
1455
1456                 if (entries_added > 0)
1457                 {
1458                         r_u->unknown_0 = 0x0000492;
1459                         r_u->unknown_1 = 0x000049a;
1460                 }
1461                 else
1462                 {
1463                         r_u->unknown_0 = 0x0;
1464                         r_u->unknown_1 = 0x0;
1465                 }
1466                 r_u->switch_level  = 3;
1467                 r_u->num_entries   = entries_added;
1468                 r_u->ptr_entries   = 1;
1469                 r_u->num_entries2  = entries_added;
1470         }
1471         else
1472         {
1473                 r_u->switch_level = 0;
1474         }
1475
1476         r_u->status = status;
1477 }
1478
1479 /*******************************************************************
1480 reads or writes a structure.
1481 ********************************************************************/
1482 void samr_io_r_enum_dom_groups(char *desc,  SAMR_R_ENUM_DOM_GROUPS *r_u, prs_struct *ps, int depth)
1483 {
1484         int i;
1485
1486         if (r_u == NULL) return;
1487
1488         prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
1489         depth++;
1490
1491         prs_align(ps);
1492
1493         prs_uint32("unknown_0    ", ps, depth, &(r_u->unknown_0    ));
1494         prs_uint32("unknown_1    ", ps, depth, &(r_u->unknown_1    ));
1495         prs_uint32("switch_level ", ps, depth, &(r_u->switch_level ));
1496
1497         if (r_u->switch_level != 0)
1498         {
1499                 prs_uint32("num_entries  ", ps, depth, &(r_u->num_entries  ));
1500                 prs_uint32("ptr_entries  ", ps, depth, &(r_u->ptr_entries  ));
1501
1502                 prs_uint32("num_entries2 ", ps, depth, &(r_u->num_entries2 ));
1503
1504                 SMB_ASSERT_ARRAY(r_u->sam, r_u->num_entries);
1505
1506                 for (i = 0; i < r_u->num_entries; i++)
1507                 {
1508                         prs_grow(ps);
1509                         sam_io_sam_entry3("", &(r_u->sam[i]), ps, depth);
1510                 }
1511
1512                 for (i = 0; i < r_u->num_entries; i++)
1513                 {
1514                         prs_grow(ps);
1515                         sam_io_sam_str3 ("", &(r_u->str[i]),
1516                                              r_u->sam[i].hdr_grp_name.buffer,
1517                                              r_u->sam[i].hdr_grp_desc.buffer,
1518                                              ps, depth);
1519                 }
1520         }
1521
1522         prs_uint32("status", ps, depth, &(r_u->status));
1523 }
1524
1525
1526 /*******************************************************************
1527 makes a SAMR_Q_QUERY_ALIASINFO structure.
1528 ********************************************************************/
1529 void make_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_e,
1530                                 POLICY_HND *pol,
1531                                 uint16 switch_level)
1532 {
1533         if (q_e == NULL || pol == NULL) return;
1534
1535         DEBUG(5,("make_q_query_aliasinfo\n"));
1536
1537         memcpy(&(q_e->pol), pol, sizeof(*pol));
1538
1539         q_e->switch_level = switch_level;
1540 }
1541
1542
1543 /*******************************************************************
1544 reads or writes a structure.
1545 ********************************************************************/
1546 void samr_io_q_query_aliasinfo(char *desc,  SAMR_Q_QUERY_ALIASINFO *q_e, prs_struct *ps, int depth)
1547 {
1548         if (q_e == NULL) return;
1549
1550         prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
1551         depth++;
1552
1553         prs_align(ps);
1554
1555         smb_io_pol_hnd("pol", &(q_e->pol), ps, depth); 
1556         prs_align(ps);
1557
1558         prs_uint16("switch_level", ps, depth, &(q_e->switch_level));
1559 }
1560
1561
1562 /*******************************************************************
1563 makes a SAMR_R_QUERY_ALIASINFO structure.
1564 ********************************************************************/
1565 void make_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *r_u,
1566                 uint16 switch_value, char *acct_desc,
1567                 uint32 status)
1568 {
1569         if (r_u == NULL) return;
1570
1571         DEBUG(5,("make_samr_r_query_aliasinfo\n"));
1572
1573         r_u->ptr = 0;
1574
1575         if (status == 0)
1576         {
1577                 r_u->switch_value = switch_value;
1578
1579                 switch (switch_value)
1580                 {
1581                         case 3:
1582                         {
1583                                 int acct_len = acct_desc ? strlen(acct_desc) : 0;
1584
1585                                 r_u->ptr = 1;
1586
1587                                 make_uni_hdr(&(r_u->alias.info3.hdr_acct_desc), acct_len , acct_len, acct_desc ? 1 : 0);
1588                                 make_unistr2(&(r_u->alias.info3.uni_acct_desc), acct_desc, acct_len);
1589
1590                                 break;
1591                         }
1592
1593                         default:
1594                         {
1595                                 DEBUG(4,("make_samr_r_query_aliasinfo: unsupported switch level\n"));
1596                                 break;
1597                         }
1598                 }
1599         }
1600
1601         r_u->status = status;
1602 }
1603
1604
1605 /*******************************************************************
1606 reads or writes a structure.
1607 ********************************************************************/
1608 void samr_io_r_query_aliasinfo(char *desc,  SAMR_R_QUERY_ALIASINFO *r_u, prs_struct *ps, int depth)
1609 {
1610         if (r_u == NULL) return;
1611
1612         prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
1613         depth++;
1614
1615         prs_align(ps);
1616
1617         prs_uint32("ptr         ", ps, depth, &(r_u->ptr         ));
1618         
1619         if (r_u->ptr != 0)
1620         {
1621                 prs_uint16("switch_value", ps, depth, &(r_u->switch_value));
1622                 prs_align(ps);
1623
1624                 if (r_u->switch_value != 0)
1625                 {
1626                         switch (r_u->switch_value)
1627                         {
1628                                 case 3:
1629                                 {
1630                                         smb_io_unihdr ("", &(r_u->alias.info3.hdr_acct_desc), ps, depth);
1631                                         smb_io_unistr2("", &(r_u->alias.info3.uni_acct_desc), r_u->alias.info3.hdr_acct_desc.buffer, ps, depth);
1632                                         break;
1633                                 }
1634                                 default:
1635                                 {
1636                                         DEBUG(4,("samr_io_r_query_aliasinfo: unsupported switch level\n"));
1637                                         break;
1638                                 }
1639                         }
1640                 }
1641         }
1642
1643         prs_align(ps);
1644
1645         prs_uint32("status", ps, depth, &(r_u->status));
1646 }
1647
1648 /*******************************************************************
1649 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
1650 ********************************************************************/
1651 void samr_io_q_query_useraliases(char *desc,  SAMR_Q_QUERY_USERALIASES *q_u, prs_struct *ps, int depth)
1652 {
1653         fstring tmp;
1654         int i;
1655
1656         if (q_u == NULL) return;
1657
1658         prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
1659         depth++;
1660
1661         prs_align(ps);
1662
1663         smb_io_pol_hnd("pol", &(q_u->pol), ps, depth); 
1664         prs_align(ps);
1665
1666         prs_uint32("num_sids1", ps, depth, &(q_u->num_sids1));
1667         prs_uint32("ptr      ", ps, depth, &(q_u->ptr      ));
1668         prs_uint32("num_sids2", ps, depth, &(q_u->num_sids2));
1669
1670         SMB_ASSERT_ARRAY(q_u->ptr_sid, q_u->num_sids2);
1671
1672         for (i = 0; i < q_u->num_sids2; i++)
1673         {
1674                 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
1675                 prs_uint32(tmp, ps, depth, &(q_u->ptr_sid[i]));
1676         }
1677
1678         for (i = 0; i < q_u->num_sids2; i++)
1679         {
1680                 if (q_u->ptr_sid[i] != 0)
1681                 {
1682                         prs_grow(ps);
1683                         slprintf(tmp, sizeof(tmp)-1, "sid[%02d]", i);
1684                         smb_io_dom_sid2(tmp, &(q_u->sid[i]), ps, depth); 
1685                 }
1686         }
1687
1688         prs_align(ps);
1689 }
1690
1691
1692 /*******************************************************************
1693 makes a SAMR_R_QUERY_USERALIASES structure.
1694 ********************************************************************/
1695 void make_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES *r_u,
1696                 uint32 num_rids, uint32 *rid, uint32 status)
1697 {
1698         int i;
1699         if (r_u == NULL) return;
1700
1701         DEBUG(5,("make_samr_r_query_useraliases\n"));
1702
1703         if (status == 0x0)
1704         {
1705                 r_u->num_entries  = num_rids;
1706                 r_u->ptr = 1;
1707                 r_u->num_entries2 = num_rids;
1708
1709                 SMB_ASSERT_ARRAY(r_u->rid, num_rids);
1710
1711                 for (i = 0; i < num_rids; i++)
1712                 {
1713                         r_u->rid[i] = rid[i];
1714                 }
1715         }
1716         else
1717         {
1718                 r_u->num_entries  = 0;
1719                 r_u->ptr = 0;
1720                 r_u->num_entries2 = 0;
1721         }
1722
1723         r_u->status = status;
1724 }
1725
1726 /*******************************************************************
1727 reads or writes a structure.
1728 ********************************************************************/
1729 void samr_io_r_query_useraliases(char *desc,  SAMR_R_QUERY_USERALIASES *r_u, prs_struct *ps, int depth)
1730 {
1731         fstring tmp;
1732         int i;
1733         if (r_u == NULL) return;
1734
1735         prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
1736         depth++;
1737
1738         prs_align(ps);
1739
1740         prs_uint32("num_entries", ps, depth, &(r_u->num_entries));
1741         prs_uint32("ptr        ", ps, depth, &(r_u->ptr        ));
1742         prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
1743
1744         if (r_u->num_entries != 0)
1745         {
1746                 SMB_ASSERT_ARRAY(r_u->rid, r_u->num_entries2);
1747
1748                 for (i = 0; i < r_u->num_entries2; i++)
1749                 {
1750                         slprintf(tmp, sizeof(tmp)-1, "rid[%02d]", i);
1751                         prs_uint32(tmp, ps, depth, &(r_u->rid[i]));
1752                 }
1753         }
1754
1755         prs_uint32("status", ps, depth, &(r_u->status));
1756 }
1757
1758 /*******************************************************************
1759 reads or writes a structure.
1760 ********************************************************************/
1761 void samr_io_q_lookup_names(char *desc,  SAMR_Q_LOOKUP_NAMES *q_u, prs_struct *ps, int depth)
1762 {
1763         int i;
1764
1765         if (q_u == NULL) return;
1766
1767         prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
1768         depth++;
1769
1770         prs_align(ps);
1771
1772         smb_io_pol_hnd("pol", &(q_u->pol), ps, depth); 
1773         prs_align(ps);
1774
1775         prs_uint32("num_rids1", ps, depth, &(q_u->num_rids1));
1776         prs_uint32("rid      ", ps, depth, &(q_u->rid      ));
1777         prs_uint32("ptr      ", ps, depth, &(q_u->ptr      ));
1778         prs_uint32("num_rids2", ps, depth, &(q_u->num_rids2));
1779
1780         SMB_ASSERT_ARRAY(q_u->hdr_user_name, q_u->num_rids2);
1781
1782         for (i = 0; i < q_u->num_rids2; i++)
1783         {
1784                 prs_grow(ps);
1785                 smb_io_unihdr ("", &(q_u->hdr_user_name[i]), ps, depth); 
1786         }
1787         for (i = 0; i < q_u->num_rids2; i++)
1788         {
1789                 prs_grow(ps);
1790                 smb_io_unistr2("", &(q_u->uni_user_name[i]), q_u->hdr_user_name[i].buffer, ps, depth); 
1791         }
1792
1793         prs_align(ps);
1794 }
1795
1796
1797 /*******************************************************************
1798 makes a SAMR_R_LOOKUP_NAMES structure.
1799 ********************************************************************/
1800 void make_samr_r_lookup_names(SAMR_R_LOOKUP_NAMES *r_u,
1801                 uint32 num_rids, uint32 *rid, uint8 *type, uint32 status)
1802 {
1803         int i;
1804         if (r_u == NULL) return;
1805
1806         DEBUG(5,("make_samr_r_lookup_names\n"));
1807
1808         if (status == 0x0)
1809         {
1810                 r_u->num_entries  = num_rids;
1811                 r_u->undoc_buffer = 1;
1812                 r_u->num_entries2 = num_rids;
1813
1814                 SMB_ASSERT_ARRAY(r_u->dom_rid, num_rids);
1815
1816                 for (i = 0; i < num_rids; i++)
1817                 {
1818                         make_dom_rid3(&(r_u->dom_rid[i]), rid[i], type[i]);
1819                 }
1820
1821                 r_u->num_entries3 = num_rids;
1822         }
1823         else
1824         {
1825                 r_u->num_entries  = 0;
1826                 r_u->undoc_buffer = 0;
1827                 r_u->num_entries2 = 0;
1828                 r_u->num_entries3 = 0;
1829         }
1830
1831         r_u->status = status;
1832 }
1833
1834 /*******************************************************************
1835 reads or writes a structure.
1836 ********************************************************************/
1837 void samr_io_r_lookup_names(char *desc,  SAMR_R_LOOKUP_NAMES *r_u, prs_struct *ps, int depth)
1838 {
1839         int i;
1840         if (r_u == NULL) return;
1841
1842         prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
1843         depth++;
1844
1845         prs_align(ps);
1846
1847         prs_uint32("num_entries ", ps, depth, &(r_u->num_entries ));
1848         prs_uint32("undoc_buffer", ps, depth, &(r_u->undoc_buffer));
1849         prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
1850
1851         if (r_u->num_entries != 0)
1852         {
1853                 SMB_ASSERT_ARRAY(r_u->dom_rid, r_u->num_entries2);
1854
1855                 for (i = 0; i < r_u->num_entries2; i++)
1856                 {
1857                         prs_grow(ps);
1858                         smb_io_dom_rid3("", &(r_u->dom_rid[i]), ps, depth);
1859                 }
1860
1861         }
1862
1863         prs_uint32("num_entries3", ps, depth, &(r_u->num_entries3));
1864
1865         prs_uint32("status", ps, depth, &(r_u->status));
1866 }
1867
1868 /*******************************************************************
1869 reads or writes a structure.
1870 ********************************************************************/
1871 void samr_io_q_unknown_12(char *desc,  SAMR_Q_UNKNOWN_12 *q_u, prs_struct *ps, int depth)
1872 {
1873         int i;
1874         fstring tmp;
1875
1876         if (q_u == NULL) return;
1877
1878         prs_debug(ps, depth, desc, "samr_io_q_unknown_12");
1879         depth++;
1880
1881         prs_align(ps);
1882
1883         smb_io_pol_hnd("pol", &(q_u->pol), ps, depth); 
1884         prs_align(ps);
1885
1886         prs_uint32("num_gids1", ps, depth, &(q_u->num_gids1));
1887         prs_uint32("rid      ", ps, depth, &(q_u->rid      ));
1888         prs_uint32("ptr      ", ps, depth, &(q_u->ptr      ));
1889         prs_uint32("num_gids2", ps, depth, &(q_u->num_gids2));
1890
1891         SMB_ASSERT_ARRAY(q_u->gid, q_u->num_gids2);
1892
1893         for (i = 0; i < q_u->num_gids2; i++)
1894         {
1895                 prs_grow(ps);
1896                 slprintf(tmp, sizeof(tmp) - 1, "gid[%02d]  ", i);
1897                 prs_uint32(tmp, ps, depth, &(q_u->gid[i]));
1898         }
1899
1900         prs_align(ps);
1901 }
1902
1903
1904 /*******************************************************************
1905 makes a SAMR_R_UNKNOWN_12 structure.
1906 ********************************************************************/
1907 void make_samr_r_unknown_12(SAMR_R_UNKNOWN_12 *r_u,
1908                 uint32 num_aliases, fstring *als_name, uint8 *num_als_usrs,
1909                 uint32 status)
1910 {
1911         int i;
1912         if (r_u == NULL || als_name == NULL || num_als_usrs == NULL) return;
1913
1914         DEBUG(5,("make_samr_r_unknown_12\n"));
1915
1916         if (status == 0x0)
1917         {
1918                 r_u->num_aliases1 = num_aliases;
1919                 r_u->ptr_aliases  = 1;
1920                 r_u->num_aliases2 = num_aliases;
1921
1922                 r_u->num_als_usrs1 = num_aliases;
1923                 r_u->ptr_als_usrs  = 1;
1924                 r_u->num_als_usrs2 = num_aliases;
1925
1926                 SMB_ASSERT_ARRAY(r_u->hdr_als_name, num_aliases);
1927
1928                 for (i = 0; i < num_aliases; i++)
1929                 {
1930                         int als_len = als_name[i] != NULL ? strlen(als_name[i]) : 0;
1931                         make_uni_hdr(&(r_u->hdr_als_name[i]), als_len    , als_len, als_name[i] ? 1 : 0);
1932                         make_unistr2(&(r_u->uni_als_name[i]), als_name[i], als_len);
1933                         r_u->num_als_usrs[i] = num_als_usrs[i];
1934                 }
1935         }
1936         else
1937         {
1938                 r_u->num_aliases1 = num_aliases;
1939                 r_u->ptr_aliases  = 0;
1940                 r_u->num_aliases2 = num_aliases;
1941
1942                 r_u->num_als_usrs1 = num_aliases;
1943                 r_u->ptr_als_usrs  = 0;
1944                 r_u->num_als_usrs2 = num_aliases;
1945         }
1946
1947         r_u->status = status;
1948 }
1949
1950 /*******************************************************************
1951 reads or writes a structure.
1952 ********************************************************************/
1953 void samr_io_r_unknown_12(char *desc,  SAMR_R_UNKNOWN_12 *r_u, prs_struct *ps, int depth)
1954 {
1955         int i;
1956         fstring tmp;
1957         if (r_u == NULL) return;
1958
1959         prs_debug(ps, depth, desc, "samr_io_r_unknown_12");
1960         depth++;
1961
1962         prs_align(ps);
1963
1964         prs_uint32("num_aliases1", ps, depth, &(r_u->num_aliases1));
1965         prs_uint32("ptr_aliases ", ps, depth, &(r_u->ptr_aliases ));
1966         prs_uint32("num_aliases2", ps, depth, &(r_u->num_aliases2));
1967
1968         if (r_u->ptr_aliases != 0 && r_u->num_aliases1 != 0)
1969         {
1970                 SMB_ASSERT_ARRAY(r_u->hdr_als_name, r_u->num_aliases2);
1971
1972                 for (i = 0; i < r_u->num_aliases2; i++)
1973                 {
1974                         prs_grow(ps);
1975                         slprintf(tmp, sizeof(tmp) - 1, "als_hdr[%02d]  ", i);
1976                         smb_io_unihdr ("", &(r_u->hdr_als_name[i]), ps, depth); 
1977                 }
1978                 for (i = 0; i < r_u->num_aliases2; i++)
1979                 {
1980                         prs_grow(ps);
1981                         slprintf(tmp, sizeof(tmp) - 1, "als_str[%02d]  ", i);
1982                         smb_io_unistr2("", &(r_u->uni_als_name[i]), r_u->hdr_als_name[i].buffer, ps, depth); 
1983                 }
1984         }
1985
1986         prs_align(ps);
1987
1988         prs_uint32("num_als_usrs1", ps, depth, &(r_u->num_als_usrs1));
1989         prs_uint32("ptr_als_usrs ", ps, depth, &(r_u->ptr_als_usrs ));
1990         prs_uint32("num_als_usrs2", ps, depth, &(r_u->num_als_usrs2));
1991
1992         if (r_u->ptr_als_usrs != 0 && r_u->num_als_usrs1 != 0)
1993         {
1994                 SMB_ASSERT_ARRAY(r_u->num_als_usrs, r_u->num_als_usrs2);
1995
1996                 for (i = 0; i < r_u->num_als_usrs2; i++)
1997                 {
1998                         prs_grow(ps);
1999                         slprintf(tmp, sizeof(tmp) - 1, "als_usrs[%02d]  ", i);
2000                         prs_uint32(tmp, ps, depth, &(r_u->num_als_usrs[i]));
2001                 }
2002         }
2003
2004         prs_uint32("status", ps, depth, &(r_u->status));
2005 }
2006
2007
2008 /*******************************************************************
2009 reads or writes a structure.
2010 ********************************************************************/
2011 void make_samr_q_open_user(SAMR_Q_OPEN_USER *q_u,
2012                                 POLICY_HND *pol,
2013                                 uint32 unk_0, uint32 rid)
2014 {
2015         if (q_u == NULL) return;
2016
2017         DEBUG(5,("samr_make_q_open_user\n"));
2018
2019         memcpy(&q_u->domain_pol, pol, sizeof(q_u->domain_pol));
2020         
2021         q_u->unknown_0 = unk_0;
2022         q_u->user_rid  = rid;
2023 }
2024
2025 /*******************************************************************
2026 reads or writes a structure.
2027 ********************************************************************/
2028 void samr_io_q_open_user(char *desc,  SAMR_Q_OPEN_USER *q_u, prs_struct *ps, int depth)
2029 {
2030         if (q_u == NULL) return;
2031
2032         prs_debug(ps, depth, desc, "samr_io_q_open_user");
2033         depth++;
2034
2035         prs_align(ps);
2036
2037         smb_io_pol_hnd("domain_pol", &(q_u->domain_pol), ps, depth); 
2038         prs_align(ps);
2039
2040         prs_uint32("unknown_0", ps, depth, &(q_u->unknown_0));
2041         prs_uint32("user_rid ", ps, depth, &(q_u->user_rid ));
2042
2043         prs_align(ps);
2044 }
2045
2046 /*******************************************************************
2047 reads or writes a structure.
2048 ********************************************************************/
2049 void samr_io_r_open_user(char *desc,  SAMR_R_OPEN_USER *r_u, prs_struct *ps, int depth)
2050 {
2051         if (r_u == NULL) return;
2052
2053         prs_debug(ps, depth, desc, "samr_io_r_open_user");
2054         depth++;
2055
2056         prs_align(ps);
2057
2058         smb_io_pol_hnd("user_pol", &(r_u->user_pol), ps, depth); 
2059         prs_align(ps);
2060
2061         prs_uint32("status", ps, depth, &(r_u->status));
2062 }
2063
2064 /*******************************************************************
2065 makes a SAMR_Q_QUERY_USERGROUPS structure.
2066 ********************************************************************/
2067 void make_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u,
2068                                 POLICY_HND *hnd)
2069 {
2070         if (q_u == NULL || hnd == NULL) return;
2071
2072         DEBUG(5,("make_samr_q_query_usergroups\n"));
2073
2074         memcpy(&(q_u->pol), hnd, sizeof(q_u->pol));
2075 }
2076
2077
2078 /*******************************************************************
2079 reads or writes a structure.
2080 ********************************************************************/
2081 void samr_io_q_query_usergroups(char *desc,  SAMR_Q_QUERY_USERGROUPS *q_u, prs_struct *ps, int depth)
2082 {
2083         if (q_u == NULL) return;
2084
2085         prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2086         depth++;
2087
2088         prs_align(ps);
2089
2090         smb_io_pol_hnd("pol", &(q_u->pol), ps, depth); 
2091         prs_align(ps);
2092 }
2093
2094 /*******************************************************************
2095 makes a SAMR_R_QUERY_USERGROUPS structure.
2096 ********************************************************************/
2097 void make_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS *r_u,
2098                 uint32 num_gids, DOM_GID *gid, uint32 status)
2099 {
2100         if (r_u == NULL) return;
2101
2102         DEBUG(5,("make_samr_r_query_usergroups\n"));
2103
2104         if (status == 0x0)
2105         {
2106                 r_u->ptr_0        = 1;
2107                 r_u->num_entries  = num_gids;
2108                 r_u->ptr_1        = (num_gids != 0) ? 1 : 0;
2109                 r_u->num_entries2 = num_gids;
2110
2111                 r_u->gid = gid;
2112         }
2113         else
2114         {
2115                 r_u->ptr_0       = 0;
2116                 r_u->num_entries = 0;
2117                 r_u->ptr_1       = 0;
2118         }
2119
2120         r_u->status = status;
2121 }
2122
2123 /*******************************************************************
2124 reads or writes a structure.
2125 ********************************************************************/
2126 void samr_io_r_query_usergroups(char *desc,  SAMR_R_QUERY_USERGROUPS *r_u, prs_struct *ps, int depth)
2127 {
2128         int i;
2129         if (r_u == NULL) return;
2130
2131         prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
2132         depth++;
2133
2134         prs_align(ps);
2135
2136         prs_uint32("ptr_0       ", ps, depth, &(r_u->ptr_0      ));
2137
2138         if (r_u->ptr_0 != 0)
2139         {
2140                 prs_uint32("num_entries ", ps, depth, &(r_u->num_entries));
2141                 prs_uint32("ptr_1       ", ps, depth, &(r_u->ptr_1      ));
2142
2143                 if (r_u->num_entries != 0)
2144                 {
2145                         prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
2146
2147                         for (i = 0; i < r_u->num_entries2; i++)
2148                         {
2149                                 prs_grow(ps);
2150                                 smb_io_gid("", &(r_u->gid[i]), ps, depth);
2151                         }
2152                 }
2153         }
2154         prs_uint32("status", ps, depth, &(r_u->status));
2155 }
2156
2157 /*******************************************************************
2158 makes a SAMR_Q_QUERY_USERINFO structure.
2159 ********************************************************************/
2160 void make_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u,
2161                                 POLICY_HND *hnd, uint16 switch_value)
2162 {
2163         if (q_u == NULL || hnd == NULL) return;
2164
2165         DEBUG(5,("make_samr_q_query_userinfo\n"));
2166
2167         memcpy(&(q_u->pol), hnd, sizeof(q_u->pol));
2168         q_u->switch_value = switch_value;
2169 }
2170
2171
2172 /*******************************************************************
2173 reads or writes a structure.
2174 ********************************************************************/
2175 void samr_io_q_query_userinfo(char *desc,  SAMR_Q_QUERY_USERINFO *q_u, prs_struct *ps, int depth)
2176 {
2177         if (q_u == NULL) return;
2178
2179         prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
2180         depth++;
2181
2182         prs_align(ps);
2183
2184         smb_io_pol_hnd("pol", &(q_u->pol), ps, depth); 
2185         prs_align(ps);
2186
2187         prs_uint16("switch_value", ps, depth, &(q_u->switch_value)); /* 0x0015 or 0x0011 */
2188
2189         prs_align(ps);
2190 }
2191
2192 /*******************************************************************
2193 reads or writes a LOGON_HRS structure.
2194 ********************************************************************/
2195 static void sam_io_logon_hrs(char *desc,  LOGON_HRS *hrs, prs_struct *ps, int depth)
2196 {
2197         if (hrs == NULL) return;
2198
2199         prs_debug(ps, depth, desc, "sam_io_logon_hrs");
2200         depth++;
2201
2202         prs_align(ps);
2203         
2204         prs_uint32 (       "len  ", ps, depth, &(hrs->len ));
2205
2206         if (hrs->len > 64)
2207         {
2208                 DEBUG(5,("sam_io_logon_hrs: truncating length\n"));
2209                 hrs->len = 64;
2210         }
2211
2212         prs_uint8s (False, "hours", ps, depth, hrs->hours, hrs->len);
2213 }
2214
2215 /*******************************************************************
2216 makes a SAM_USER_INFO_10 structure.
2217 ********************************************************************/
2218 void make_sam_user_info10(SAM_USER_INFO_10 *usr,
2219                                 uint32 acb_info)
2220 {
2221         if (usr == NULL) return;
2222
2223         DEBUG(5,("make_sam_user_info10\n"));
2224
2225         usr->acb_info = acb_info;
2226 }
2227
2228 /*******************************************************************
2229 reads or writes a structure.
2230 ********************************************************************/
2231 void sam_io_user_info10(char *desc,  SAM_USER_INFO_10 *usr, prs_struct *ps, int depth)
2232 {
2233         if (usr == NULL) return;
2234
2235         prs_debug(ps, depth, desc, "samr_io_r_user_info10");
2236         depth++;
2237
2238         prs_align(ps);
2239
2240         prs_uint32("acb_info", ps, depth, &(usr->acb_info));
2241 }
2242
2243 /*******************************************************************
2244 makes a SAM_USER_INFO_11 structure.
2245 ********************************************************************/
2246 void make_sam_user_info11(SAM_USER_INFO_11 *usr,
2247                                 NTTIME *expiry,
2248                                 char *mach_acct,
2249                                 uint32 rid_user,
2250                                 uint32 rid_group,
2251                                 uint16 acct_ctrl)
2252                                 
2253 {
2254         int len_mach_acct;
2255         if (usr == NULL || expiry == NULL || mach_acct == NULL) return;
2256
2257         DEBUG(5,("make_sam_user_info11\n"));
2258
2259         len_mach_acct = strlen(mach_acct);
2260
2261         memcpy(&(usr->expiry),expiry, sizeof(usr->expiry)); /* expiry time or something? */
2262         bzero(usr->padding_1, sizeof(usr->padding_1)); /* 0 - padding 24 bytes */
2263
2264         make_uni_hdr(&(usr->hdr_mach_acct), len_mach_acct, len_mach_acct, 4);  /* unicode header for machine account */
2265         usr->padding_2 = 0;               /* 0 - padding 4 bytes */
2266
2267         usr->ptr_1        = 1;            /* pointer */
2268         bzero(usr->padding_3, sizeof(usr->padding_3)); /* 0 - padding 32 bytes */
2269         usr->padding_4    = 0;            /* 0 - padding 4 bytes */
2270
2271         usr->ptr_2        = 1;            /* pointer */
2272         usr->padding_5    = 0;            /* 0 - padding 4 bytes */
2273
2274         usr->ptr_3        = 1;          /* pointer */
2275         bzero(usr->padding_6, sizeof(usr->padding_6)); /* 0 - padding 32 bytes */
2276
2277         usr->rid_user     = rid_user; 
2278         usr->rid_group    = rid_group;
2279
2280         usr->acct_ctrl    = acct_ctrl;
2281         usr->unknown_3    = 0x0000;
2282
2283         usr->unknown_4    = 0x003f;       /* 0x003f      - 16 bit unknown */
2284         usr->unknown_5    = 0x003c;       /* 0x003c      - 16 bit unknown */
2285
2286         bzero(usr->padding_7, sizeof(usr->padding_7)); /* 0 - padding 16 bytes */
2287         usr->padding_8    = 0;            /* 0 - padding 4 bytes */
2288         
2289         make_unistr2(&(usr->uni_mach_acct), mach_acct, len_mach_acct);  /* unicode string for machine account */
2290
2291         bzero(usr->padding_9, sizeof(usr->padding_9)); /* 0 - padding 48 bytes */
2292 }
2293
2294 /*******************************************************************
2295 reads or writes a structure.
2296 ********************************************************************/
2297 void sam_io_user_info11(char *desc,  SAM_USER_INFO_11 *usr, prs_struct *ps, int depth)
2298 {
2299         if (usr == NULL) return;
2300
2301         prs_debug(ps, depth, desc, "samr_io_r_unknown_24");
2302         depth++;
2303
2304         prs_align(ps);
2305
2306         prs_uint8s (False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)); 
2307
2308         smb_io_time("time", &(usr->expiry), ps, depth); 
2309
2310         prs_uint8s (False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1));
2311
2312         smb_io_unihdr ("unihdr", &(usr->hdr_mach_acct), ps, depth); 
2313         prs_uint32(        "padding_2", ps, depth, &(usr->padding_2));
2314
2315         prs_uint32(        "ptr_1    ", ps, depth, &(usr->ptr_1    ));
2316         prs_uint8s (False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3));
2317         prs_uint32(        "padding_4", ps, depth, &(usr->padding_4));
2318
2319         prs_uint32(        "ptr_2    ", ps, depth, &(usr->ptr_2    ));
2320         prs_uint32(        "padding_5", ps, depth, &(usr->padding_5));
2321
2322         prs_uint32(        "ptr_3    ", ps, depth, &(usr->ptr_3    ));
2323         prs_uint8s (False, "padding_6", ps, depth, usr->padding_6, sizeof(usr->padding_6));
2324
2325         prs_uint32(        "rid_user ", ps, depth, &(usr->rid_user ));
2326         prs_uint32(        "rid_group", ps, depth, &(usr->rid_group));
2327         prs_uint16(        "acct_ctrl", ps, depth, &(usr->acct_ctrl));
2328         prs_uint16(        "unknown_3", ps, depth, &(usr->unknown_3));
2329         prs_uint16(        "unknown_4", ps, depth, &(usr->unknown_4));
2330         prs_uint16(        "unknown_5", ps, depth, &(usr->unknown_5));
2331
2332         prs_uint8s (False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7));
2333         prs_uint32(        "padding_8", ps, depth, &(usr->padding_8));
2334         
2335         smb_io_unistr2("unistr2", &(usr->uni_mach_acct), True, ps, depth); 
2336         prs_align(ps);
2337
2338         prs_uint8s (False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9));
2339 }
2340 /*************************************************************************
2341  make_sam_user_info21
2342
2343  unknown_3 = 0x00ff ffff
2344  unknown_5 = 0x0002 0000
2345  unknown_6 = 0x0000 04ec 
2346
2347  *************************************************************************/
2348 void make_sam_user_info21(SAM_USER_INFO_21 *usr,
2349
2350         NTTIME *logon_time,
2351         NTTIME *logoff_time,
2352         NTTIME *kickoff_time,
2353         NTTIME *pass_last_set_time,
2354         NTTIME *pass_can_change_time,
2355         NTTIME *pass_must_change_time,
2356
2357         char *user_name,
2358         char *full_name,
2359         char *home_dir,
2360         char *dir_drive,
2361         char *logon_script,
2362         char *profile_path,
2363         char *description,
2364         char *workstations,
2365         char *unknown_str,
2366         char *munged_dial,
2367
2368         uint32 user_rid,
2369         uint32 group_rid,
2370         uint16 acb_info, 
2371
2372         uint32 unknown_3,
2373         uint16 logon_divs,
2374         LOGON_HRS *hrs,
2375         uint32 unknown_5,
2376         uint32 unknown_6)
2377 {
2378         int len_user_name    = user_name    != NULL ? strlen(user_name   ) : 0;
2379         int len_full_name    = full_name    != NULL ? strlen(full_name   ) : 0;
2380         int len_home_dir     = home_dir     != NULL ? strlen(home_dir    ) : 0;
2381         int len_dir_drive    = dir_drive    != NULL ? strlen(dir_drive   ) : 0;
2382         int len_logon_script = logon_script != NULL ? strlen(logon_script) : 0;
2383         int len_profile_path = profile_path != NULL ? strlen(profile_path) : 0;
2384         int len_description  = description  != NULL ? strlen(description ) : 0;
2385         int len_workstations = workstations != NULL ? strlen(workstations) : 0;
2386         int len_unknown_str  = unknown_str  != NULL ? strlen(unknown_str ) : 0;
2387         int len_munged_dial  = munged_dial  != NULL ? strlen(munged_dial ) : 0;
2388
2389         usr->logon_time            = *logon_time;
2390         usr->logoff_time           = *logoff_time;
2391         usr->kickoff_time          = *kickoff_time;
2392         usr->pass_last_set_time    = *pass_last_set_time;
2393         usr->pass_can_change_time  = *pass_can_change_time;
2394         usr->pass_must_change_time = *pass_must_change_time;
2395
2396         make_uni_hdr(&(usr->hdr_user_name   ), len_user_name   , len_user_name   , 1);
2397         make_uni_hdr(&(usr->hdr_full_name   ), len_full_name   , len_full_name   , 1);
2398         make_uni_hdr(&(usr->hdr_home_dir    ), len_home_dir    , len_home_dir    , 1);
2399         make_uni_hdr(&(usr->hdr_dir_drive   ), len_dir_drive   , len_dir_drive   , 1);
2400         make_uni_hdr(&(usr->hdr_logon_script), len_logon_script, len_logon_script, 1);
2401         make_uni_hdr(&(usr->hdr_profile_path), len_profile_path, len_profile_path, 1);
2402         make_uni_hdr(&(usr->hdr_acct_desc   ), len_description , len_description , 1);
2403         make_uni_hdr(&(usr->hdr_workstations), len_workstations, len_workstations, 1);
2404         make_uni_hdr(&(usr->hdr_unknown_str ), len_unknown_str , len_unknown_str , 1);
2405         make_uni_hdr(&(usr->hdr_munged_dial ), len_munged_dial , len_munged_dial , 1);
2406
2407         bzero(usr->nt_pwd, sizeof(usr->nt_pwd));
2408         bzero(usr->lm_pwd, sizeof(usr->lm_pwd));
2409
2410         usr->user_rid  = user_rid;
2411         usr->group_rid = group_rid;
2412         usr->acb_info = acb_info;
2413         usr->unknown_3 = unknown_3; /* 0x00ff ffff */
2414
2415         usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
2416         usr->ptr_logon_hrs = hrs ? 1 : 0;
2417         usr->unknown_5 = unknown_5; /* 0x0002 0000 */
2418
2419         bzero(usr->padding1, sizeof(usr->padding1));
2420
2421         make_unistr2(&(usr->uni_user_name   ), user_name   , len_user_name   );
2422         make_unistr2(&(usr->uni_full_name   ), full_name   , len_full_name   );
2423         make_unistr2(&(usr->uni_home_dir    ), home_dir    , len_home_dir    );
2424         make_unistr2(&(usr->uni_dir_drive   ), dir_drive   , len_dir_drive   );
2425         make_unistr2(&(usr->uni_logon_script), logon_script, len_logon_script);
2426         make_unistr2(&(usr->uni_profile_path), profile_path, len_profile_path);
2427         make_unistr2(&(usr->uni_acct_desc ), description , len_description );
2428         make_unistr2(&(usr->uni_workstations), workstations, len_workstations);
2429         make_unistr2(&(usr->uni_unknown_str ), unknown_str , len_unknown_str );
2430         make_unistr2(&(usr->uni_munged_dial ), munged_dial , len_munged_dial );
2431
2432         usr->unknown_6 = unknown_6; /* 0x0000 04ec */
2433         usr->padding4 = 0;
2434
2435         if (hrs)
2436         {
2437                 memcpy(&(usr->logon_hrs), hrs, sizeof(usr->logon_hrs));
2438         }
2439         else
2440         {
2441                 memset(&(usr->logon_hrs), 0xff, sizeof(usr->logon_hrs));
2442         }
2443 }
2444
2445
2446 /*******************************************************************
2447 reads or writes a structure.
2448 ********************************************************************/
2449 static void sam_io_user_info21(char *desc,  SAM_USER_INFO_21 *usr, prs_struct *ps, int depth)
2450 {
2451         if (usr == NULL) return;
2452
2453         prs_debug(ps, depth, desc, "lsa_io_user_info");
2454         depth++;
2455
2456         prs_align(ps);
2457         
2458         smb_io_time("logon_time           ", &(usr->logon_time)           , ps, depth);
2459         smb_io_time("logoff_time          ", &(usr->logoff_time)          , ps, depth); 
2460         smb_io_time("kickoff_time         ", &(usr->kickoff_time)         , ps, depth); 
2461         smb_io_time("pass_last_set_time   ", &(usr->pass_last_set_time)   , ps, depth); 
2462         smb_io_time("pass_can_change_time ", &(usr->pass_can_change_time) , ps, depth); 
2463         smb_io_time("pass_must_change_time", &(usr->pass_must_change_time), ps, depth); 
2464
2465         smb_io_unihdr("hdr_user_name   ", &(usr->hdr_user_name)   , ps, depth); /* username unicode string header */
2466         smb_io_unihdr("hdr_full_name   ", &(usr->hdr_full_name)   , ps, depth); /* user's full name unicode string header */
2467         smb_io_unihdr("hdr_home_dir    ", &(usr->hdr_home_dir)    , ps, depth); /* home directory unicode string header */
2468         smb_io_unihdr("hdr_dir_drive   ", &(usr->hdr_dir_drive)   , ps, depth); /* home directory drive */
2469         smb_io_unihdr("hdr_logon_script", &(usr->hdr_logon_script), ps, depth); /* logon script unicode string header */
2470         smb_io_unihdr("hdr_profile_path", &(usr->hdr_profile_path), ps, depth); /* profile path unicode string header */
2471         smb_io_unihdr("hdr_acct_desc   ", &(usr->hdr_acct_desc  ) , ps, depth); /* account description */
2472         smb_io_unihdr("hdr_workstations", &(usr->hdr_workstations), ps, depth); /* workstations user can log on from */
2473         smb_io_unihdr("hdr_unknown_str ", &(usr->hdr_unknown_str ), ps, depth); /* unknown string */
2474         smb_io_unihdr("hdr_munged_dial ", &(usr->hdr_munged_dial ), ps, depth); /* workstations user can log on from */
2475
2476         prs_uint8s (False, "lm_pwd        ", ps, depth, usr->lm_pwd   , sizeof(usr->lm_pwd   ));
2477         prs_uint8s (False, "nt_pwd        ", ps, depth, usr->nt_pwd   , sizeof(usr->nt_pwd   ));
2478
2479         prs_uint32("user_rid      ", ps, depth, &(usr->user_rid     ));       /* User ID */
2480         prs_uint32("group_rid     ", ps, depth, &(usr->group_rid    ));      /* Group ID */
2481         prs_uint16("acb_info      ", ps, depth, &(usr->acb_info     ));      /* Group ID */
2482         prs_align(ps);
2483
2484         prs_uint32("unknown_3     ", ps, depth, &(usr->unknown_3    ));
2485         prs_uint16("logon_divs    ", ps, depth, &(usr->logon_divs   ));     /* logon divisions per week */
2486         prs_align(ps);
2487         prs_uint32("ptr_logon_hrs ", ps, depth, &(usr->ptr_logon_hrs));
2488         prs_uint32("unknown_5     ", ps, depth, &(usr->unknown_5    ));
2489
2490         prs_uint8s (False, "padding1      ", ps, depth, usr->padding1, sizeof(usr->padding1));
2491
2492         /* here begins pointed-to data */
2493
2494         smb_io_unistr2("uni_user_name   ", &(usr->uni_user_name)   , usr->hdr_user_name   .buffer, ps, depth); /* username unicode string */
2495         smb_io_unistr2("uni_full_name   ", &(usr->uni_full_name)   , usr->hdr_full_name   .buffer, ps, depth); /* user's full name unicode string */
2496         smb_io_unistr2("uni_home_dir    ", &(usr->uni_home_dir)    , usr->hdr_home_dir    .buffer, ps, depth); /* home directory unicode string */
2497         smb_io_unistr2("uni_dir_drive   ", &(usr->uni_dir_drive)   , usr->hdr_dir_drive   .buffer, ps, depth); /* home directory drive unicode string */
2498         smb_io_unistr2("uni_logon_script", &(usr->uni_logon_script), usr->hdr_logon_script.buffer, ps, depth); /* logon script unicode string */
2499         smb_io_unistr2("uni_profile_path", &(usr->uni_profile_path), usr->hdr_profile_path.buffer, ps, depth); /* profile path unicode string */
2500         smb_io_unistr2("uni_acct_desc   ", &(usr->uni_acct_desc   ), usr->hdr_acct_desc   .buffer, ps, depth); /* user description unicode string */
2501         smb_io_unistr2("uni_workstations", &(usr->uni_workstations), usr->hdr_workstations.buffer, ps, depth); /* worksations user can log on from */
2502         smb_io_unistr2("uni_unknown_str ", &(usr->uni_unknown_str ), usr->hdr_unknown_str .buffer, ps, depth); /* unknown string */
2503         smb_io_unistr2("uni_munged_dial ", &(usr->uni_munged_dial ), usr->hdr_munged_dial .buffer, ps, depth); /* worksations user can log on from */
2504
2505         prs_uint32("unknown_6     ", ps, depth, &(usr->unknown_6  ));
2506         prs_uint32("padding4      ", ps, depth, &(usr->padding4   ));
2507
2508         if (usr->ptr_logon_hrs)
2509         {
2510                 sam_io_logon_hrs("logon_hrs", &(usr->logon_hrs)   , ps, depth);
2511                 prs_align(ps);
2512         }
2513 }
2514
2515
2516 /*******************************************************************
2517 makes a SAMR_R_QUERY_USERINFO structure.
2518 ********************************************************************/
2519 void make_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO *r_u,
2520                                 uint16 switch_value, void *info, uint32 status)
2521                                 
2522 {
2523         if (r_u == NULL || info == NULL) return;
2524
2525         DEBUG(5,("make_samr_r_query_userinfo\n"));
2526
2527         r_u->ptr = 0;
2528         r_u->switch_value = 0;
2529
2530         if (status == 0)
2531         {
2532                 r_u->switch_value = switch_value;
2533
2534                 switch (switch_value)
2535                 {
2536                         case 0x10:
2537                         {
2538                                 r_u->ptr = 1;
2539                                 r_u->info.id10 = (SAM_USER_INFO_10*)info;
2540
2541                                 break;
2542                         }
2543
2544                         case 0x11:
2545                         {
2546                                 r_u->ptr = 1;
2547                                 r_u->info.id11 = (SAM_USER_INFO_11*)info;
2548
2549                                 break;
2550                         }
2551
2552                         case 21:
2553                         {
2554                                 r_u->ptr = 1;
2555                                 r_u->info.id21 = (SAM_USER_INFO_21*)info;
2556
2557                                 break;
2558                         }
2559
2560                         default:
2561                         {
2562                                 DEBUG(4,("make_samr_r_query_aliasinfo: unsupported switch level\n"));
2563                                 break;
2564                         }
2565                 }
2566         }
2567
2568         r_u->status = status;         /* return status */
2569 }
2570
2571 /*******************************************************************
2572 reads or writes a structure.
2573 ********************************************************************/
2574 void samr_io_r_query_userinfo(char *desc,  SAMR_R_QUERY_USERINFO *r_u, prs_struct *ps, int depth)
2575 {
2576         if (r_u == NULL) return;
2577
2578         prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
2579         depth++;
2580
2581         prs_align(ps);
2582
2583         prs_uint32("ptr         ", ps, depth, &(r_u->ptr         ));
2584         prs_uint16("switch_value", ps, depth, &(r_u->switch_value));
2585         prs_align(ps);
2586
2587         if (r_u->ptr != 0 && r_u->switch_value != 0)
2588         {
2589                 switch (r_u->switch_value)
2590                 {
2591                         case 0x10:
2592                         {
2593                                 if (r_u->info.id10 != NULL)
2594                                 {
2595                                         sam_io_user_info10("", r_u->info.id10, ps, depth);
2596                                 }
2597                                 else
2598                                 {
2599                                         DEBUG(2,("samr_io_r_query_userinfo: info pointer not initialised\n"));
2600                                         return;
2601                                 }
2602                                 break;
2603                         }
2604 /*
2605                         case 0x11:
2606                         {
2607                                 if (r_u->info.id11 != NULL)
2608                                 {
2609                                         sam_io_user_info11("", r_u->info.id11, ps, depth);
2610                                 }
2611                                 else
2612                                 {
2613                                         DEBUG(2,("samr_io_r_query_userinfo: info pointer not initialised\n"));
2614                                         return;
2615                                 }
2616                                 break;
2617                         }
2618 */
2619                         case 21:
2620                         {
2621                                 if (r_u->info.id21 != NULL)
2622                                 {
2623                                         sam_io_user_info21("", r_u->info.id21, ps, depth);
2624                                 }
2625                                 else
2626                                 {
2627                                         DEBUG(2,("samr_io_r_query_userinfo: info pointer not initialised\n"));
2628                                         return;
2629                                 }
2630                                 break;
2631                         }
2632                         default:
2633                         {
2634                                 DEBUG(2,("samr_io_r_query_userinfo: unknown switch level\n"));
2635                                 break;
2636                         }
2637                                 
2638                 }
2639         }
2640
2641         prs_uint32("status", ps, depth, &(r_u->status));
2642 }
2643
2644 /*******************************************************************
2645 reads or writes a structure.
2646 ********************************************************************/
2647 void samr_io_q_unknown_32(char *desc,  SAMR_Q_UNKNOWN_32 *q_u, prs_struct *ps, int depth)
2648 {
2649         if (q_u == NULL) return;
2650
2651         prs_debug(ps, depth, desc, "samr_io_q_unknown_32");
2652         depth++;
2653
2654         prs_align(ps);
2655
2656         smb_io_pol_hnd("pol", &(q_u->pol), ps, depth); 
2657         prs_align(ps);
2658
2659         smb_io_unihdr ("", &(q_u->hdr_mach_acct), ps, depth); 
2660         smb_io_unistr2("", &(q_u->uni_mach_acct), q_u->hdr_mach_acct.buffer, ps, depth); 
2661
2662         prs_align(ps);
2663
2664         prs_uint32("acct_ctrl", ps, depth, &(q_u->acct_ctrl));
2665         prs_uint16("unknown_1", ps, depth, &(q_u->unknown_1));
2666         prs_uint16("unknown_2", ps, depth, &(q_u->unknown_2));
2667 }
2668
2669 /*******************************************************************
2670 reads or writes a structure.
2671 ********************************************************************/
2672 void samr_io_r_unknown_32(char *desc,  SAMR_R_UNKNOWN_32 *r_u, prs_struct *ps, int depth)
2673 {
2674         if (r_u == NULL) return;
2675
2676         prs_debug(ps, depth, desc, "samr_io_r_unknown_32");
2677         depth++;
2678
2679         prs_align(ps);
2680
2681         smb_io_pol_hnd("pol", &(r_u->pol), ps, depth); 
2682         prs_align(ps);
2683
2684         prs_uint32("status", ps, depth, &(r_u->status));
2685 }
2686
2687
2688 /*******************************************************************
2689 makes a SAMR_Q_CONNECT structure.
2690 ********************************************************************/
2691 void make_samr_q_connect(SAMR_Q_CONNECT *q_u,
2692                                 char *srv_name, uint32 unknown_0)
2693 {
2694         int len_srv_name = strlen(srv_name);
2695
2696         if (q_u == NULL) return;
2697
2698         DEBUG(5,("make_q_connect\n"));
2699
2700         /* make PDC server name \\server */
2701         q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0; 
2702         make_unistr2(&(q_u->uni_srv_name), srv_name, len_srv_name+1);  
2703
2704         /* example values: 0x0000 0002 */
2705         q_u->unknown_0 = unknown_0; 
2706 }
2707
2708
2709 /*******************************************************************
2710 reads or writes a structure.
2711 ********************************************************************/
2712 void samr_io_q_connect(char *desc,  SAMR_Q_CONNECT *q_u, prs_struct *ps, int depth)
2713 {
2714         if (q_u == NULL) return;
2715
2716         prs_debug(ps, depth, desc, "samr_io_q_connect");
2717         depth++;
2718
2719         prs_align(ps);
2720
2721         prs_uint32("ptr_srv_name", ps, depth, &(q_u->ptr_srv_name));
2722         smb_io_unistr2("", &(q_u->uni_srv_name), q_u->ptr_srv_name, ps, depth); 
2723
2724         prs_align(ps);
2725
2726         prs_uint32("unknown_0   ", ps, depth, &(q_u->unknown_0   ));
2727 }
2728
2729 /*******************************************************************
2730 reads or writes a structure.
2731 ********************************************************************/
2732 void samr_io_r_connect(char *desc,  SAMR_R_CONNECT *r_u, prs_struct *ps, int depth)
2733 {
2734         if (r_u == NULL) return;
2735
2736         prs_debug(ps, depth, desc, "samr_io_r_connect");
2737         depth++;
2738
2739         prs_align(ps);
2740
2741         smb_io_pol_hnd("connect_pol", &(r_u->connect_pol), ps, depth); 
2742         prs_align(ps);
2743
2744         prs_uint32("status", ps, depth, &(r_u->status));
2745 }
2746
2747 /*******************************************************************
2748 makes a SAMR_Q_CONNECT_ANON structure.
2749 ********************************************************************/
2750 void make_samr_q_connect_anon(SAMR_Q_CONNECT_ANON *q_u)
2751 {
2752         if (q_u == NULL) return;
2753
2754         DEBUG(5,("make_q_connect_anon\n"));
2755
2756         q_u->ptr       = 1;
2757         q_u->unknown_0 = 0x5c; /* server name (?!!) */
2758         q_u->unknown_1 = 0x01;
2759         q_u->unknown_2 = 0x20;
2760 }
2761
2762
2763 /*******************************************************************
2764 reads or writes a structure.
2765 ********************************************************************/
2766 void samr_io_q_connect_anon(char *desc,  SAMR_Q_CONNECT_ANON *q_u, prs_struct *ps, int depth)
2767 {
2768         if (q_u == NULL) return;
2769
2770         prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
2771         depth++;
2772
2773         prs_align(ps);
2774
2775         prs_uint32("ptr      ", ps, depth, &(q_u->ptr      ));
2776         prs_uint16("unknown_0", ps, depth, &(q_u->unknown_0));
2777         prs_uint16("unknown_1", ps, depth, &(q_u->unknown_1));
2778         prs_uint32("unknown_2", ps, depth, &(q_u->unknown_2));
2779 }
2780
2781 /*******************************************************************
2782 reads or writes a structure.
2783 ********************************************************************/
2784 void samr_io_r_connect_anon(char *desc,  SAMR_R_CONNECT_ANON *r_u, prs_struct *ps, int depth)
2785 {
2786         if (r_u == NULL) return;
2787
2788         prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
2789         depth++;
2790
2791         prs_align(ps);
2792
2793         smb_io_pol_hnd("connect_pol", &(r_u->connect_pol), ps, depth); 
2794         prs_align(ps);
2795
2796         prs_uint32("status", ps, depth, &(r_u->status));
2797 }
2798
2799 /*******************************************************************
2800 makes a SAMR_Q_OPEN_ALIAS structure.
2801 ********************************************************************/
2802 void make_samr_q_open_alias(SAMR_Q_OPEN_ALIAS *q_u,
2803                                 uint32 unknown_0, uint32 rid)
2804 {
2805         if (q_u == NULL) return;
2806
2807         DEBUG(5,("make_q_open_alias\n"));
2808
2809         /* example values: 0x0000 0008 */
2810         q_u->unknown_0 = unknown_0; 
2811
2812         q_u->rid_alias = rid; 
2813 }
2814
2815 /*******************************************************************
2816 reads or writes a structure.
2817 ********************************************************************/
2818 void samr_io_q_open_alias(char *desc,  SAMR_Q_OPEN_ALIAS *q_u, prs_struct *ps, int depth)
2819 {
2820         if (q_u == NULL) return;
2821
2822         prs_debug(ps, depth, desc, "samr_io_q_open_alias");
2823         depth++;
2824
2825         prs_align(ps);
2826
2827         prs_uint32("unknown_0", ps, depth, &(q_u->unknown_0));
2828         prs_uint32("rid_alias", ps, depth, &(q_u->rid_alias));
2829 }
2830
2831 /*******************************************************************
2832 reads or writes a structure.
2833 ********************************************************************/
2834 void samr_io_r_open_alias(char *desc,  SAMR_R_OPEN_ALIAS *r_u, prs_struct *ps, int depth)
2835 {
2836         if (r_u == NULL) return;
2837
2838         prs_debug(ps, depth, desc, "samr_io_r_open_alias");
2839         depth++;
2840
2841         prs_align(ps);
2842
2843         smb_io_pol_hnd("pol", &(r_u->pol), ps, depth); 
2844         prs_align(ps);
2845
2846         prs_uint32("status", ps, depth, &(r_u->status));
2847 }
2848
2849 /*******************************************************************
2850 makes a SAMR_Q_UNKNOWN_12 structure.
2851 ********************************************************************/
2852 void make_samr_q_unknown_12(SAMR_Q_UNKNOWN_12 *q_u,
2853                 POLICY_HND *pol, uint32 rid,
2854                 uint32 num_gids, uint32 *gid)
2855 {
2856         int i;
2857         if (q_u == NULL) return;
2858
2859         DEBUG(5,("make_samr_r_unknwon_12\n"));
2860
2861         memcpy(&(q_u->pol), pol, sizeof(*pol));
2862
2863         q_u->num_gids1 = num_gids;
2864         q_u->rid       = rid;
2865         q_u->ptr       = 0;
2866         q_u->num_gids2 = num_gids;
2867
2868         for (i = 0; i < num_gids; i++)
2869         {
2870                 q_u->gid[i] = gid[i];
2871         }
2872 }
2873
2874
2875 /*******************************************************************
2876 makes a SAMR_Q_UNKNOWN_21 structure.
2877 ********************************************************************/
2878 void make_samr_q_unknown_21(SAMR_Q_UNKNOWN_21 *q_c,
2879                                 POLICY_HND *hnd, uint16 unk_1, uint16 unk_2)
2880 {
2881         if (q_c == NULL || hnd == NULL) return;
2882
2883         DEBUG(5,("make_samr_q_unknown_21\n"));
2884
2885         memcpy(&(q_c->group_pol), hnd, sizeof(q_c->group_pol));
2886         q_c->unknown_1 = unk_1;
2887         q_c->unknown_2 = unk_2;
2888 }
2889
2890
2891 /*******************************************************************
2892 makes a SAMR_Q_UNKNOWN_13 structure.
2893 ********************************************************************/
2894 void make_samr_q_unknown_13(SAMR_Q_UNKNOWN_13 *q_c,
2895                                 POLICY_HND *hnd, uint16 unk_1, uint16 unk_2)
2896 {
2897         if (q_c == NULL || hnd == NULL) return;
2898
2899         DEBUG(5,("make_samr_q_unknown_13\n"));
2900
2901         memcpy(&(q_c->alias_pol), hnd, sizeof(q_c->alias_pol));
2902         q_c->unknown_1 = unk_1;
2903         q_c->unknown_2 = unk_2;
2904 }
2905
2906
2907 /*******************************************************************
2908 makes a SAMR_Q_UNKNOWN_38 structure.
2909 ********************************************************************/
2910 void make_samr_q_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, char *srv_name)
2911 {
2912         int len_srv_name = strlen(srv_name);
2913
2914         if (q_u == NULL) return;
2915
2916         DEBUG(5,("make_q_unknown_38\n"));
2917
2918         q_u->ptr = 1;
2919         make_uni_hdr(&(q_u->hdr_srv_name), len_srv_name, len_srv_name, len_srv_name != 0);
2920         make_unistr2(&(q_u->uni_srv_name), srv_name, len_srv_name);  
2921
2922 }
2923
2924 /*******************************************************************
2925 reads or writes a structure.
2926 ********************************************************************/
2927 void samr_io_q_unknown_38(char *desc,  SAMR_Q_UNKNOWN_38 *q_u, prs_struct *ps, int depth)
2928 {
2929         if (q_u == NULL) return;
2930
2931         prs_debug(ps, depth, desc, "samr_io_q_unknown_38");
2932         depth++;
2933
2934         prs_align(ps);
2935
2936         prs_uint32("ptr", ps, depth, &(q_u->ptr));
2937         if (q_u->ptr != 0)
2938         {
2939                 smb_io_unihdr ("", &(q_u->hdr_srv_name), ps, depth); 
2940                 smb_io_unistr2("", &(q_u->uni_srv_name), q_u->hdr_srv_name.buffer, ps, depth); 
2941         }
2942 }
2943
2944 /*******************************************************************
2945 makes a SAMR_R_UNKNOWN_38 structure.
2946 ********************************************************************/
2947 void make_samr_r_unknown_38(SAMR_R_UNKNOWN_38 *r_u)
2948 {
2949         if (r_u == NULL) return;
2950
2951         DEBUG(5,("make_r_unknown_38\n"));
2952
2953         r_u->unk_0 = 0;
2954         r_u->unk_1 = 0;
2955         r_u->unk_2 = 0;
2956         r_u->unk_3 = 0;
2957 }
2958
2959 /*******************************************************************
2960 reads or writes a structure.
2961 ********************************************************************/
2962 void samr_io_r_unknown_38(char *desc,  SAMR_R_UNKNOWN_38 *r_u, prs_struct *ps, int depth)
2963 {
2964         if (r_u == NULL) return;
2965
2966         prs_debug(ps, depth, desc, "samr_io_r_unknown_38");
2967         depth++;
2968
2969         prs_align(ps);
2970
2971         prs_uint16("unk_0", ps, depth, &(r_u->unk_0));
2972         prs_align(ps);
2973         prs_uint16("unk_1", ps, depth, &(r_u->unk_1));
2974         prs_align(ps);
2975         prs_uint16("unk_2", ps, depth, &(r_u->unk_2));
2976         prs_align(ps);
2977         prs_uint16("unk_3", ps, depth, &(r_u->unk_3));
2978         prs_align(ps);
2979 }
2980
2981 /*******************************************************************
2982 make a SAMR_ENC_PASSWD structure.
2983 ********************************************************************/
2984 void make_enc_passwd(SAMR_ENC_PASSWD *pwd, char pass[512])
2985 {
2986         if (pwd == NULL) return;
2987
2988         pwd->ptr = 1;
2989         memcpy(pwd->pass, pass, sizeof(pwd->pass)); 
2990 }
2991
2992 /*******************************************************************
2993 reads or writes a SAMR_ENC_PASSWD structure.
2994 ********************************************************************/
2995 void samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD *pwd, prs_struct *ps, int depth)
2996 {
2997         if (pwd == NULL) return;
2998
2999         prs_debug(ps, depth, desc, "samr_io_enc_passwd");
3000         depth++;
3001
3002         prs_align(ps);
3003
3004         prs_uint32("ptr", ps, depth, &(pwd->ptr));
3005         prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)); 
3006 }
3007
3008 /*******************************************************************
3009 makes a SAMR_ENC_HASH structure.
3010 ********************************************************************/
3011 void make_enc_hash(SAMR_ENC_HASH *hsh, uchar hash[16])
3012 {
3013         if (hsh == NULL) return;
3014
3015         hsh->ptr = 1;
3016         memcpy(hsh->hash, hash, sizeof(hsh->hash));
3017 }
3018
3019 /*******************************************************************
3020 reads or writes a SAMR_ENC_HASH structure.
3021 ********************************************************************/
3022 void samr_io_enc_hash(char *desc, SAMR_ENC_HASH *hsh, prs_struct *ps, int depth)
3023 {
3024         if (hsh == NULL) return;
3025
3026         prs_debug(ps, depth, desc, "samr_io_enc_hash");
3027         depth++;
3028
3029         prs_align(ps);
3030
3031         prs_uint32("ptr ", ps, depth, &(hsh->ptr));
3032         prs_uint8s(False, "hash", ps, depth, hsh->hash, sizeof(hsh->hash)); 
3033 }
3034
3035 /*******************************************************************
3036 makes a SAMR_R_UNKNOWN_38 structure.
3037 ********************************************************************/
3038 void make_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u,
3039                                 char *dest_host, char *user_name,
3040                                 char nt_newpass[516], uchar nt_oldhash[16],
3041                                 char lm_newpass[516], uchar lm_oldhash[16])
3042 {
3043         int len_dest_host = strlen(dest_host);
3044         int len_user_name = strlen(user_name);
3045
3046         if (q_u == NULL) return;
3047
3048         DEBUG(5,("make_samr_q_chgpasswd_user\n"));
3049
3050         q_u->ptr_0 = 1;
3051         make_uni_hdr(&(q_u->hdr_dest_host), len_dest_host, len_dest_host, len_dest_host != 0);
3052         make_unistr2(&(q_u->uni_dest_host), dest_host, len_dest_host);  
3053         make_uni_hdr(&(q_u->hdr_user_name), len_user_name, len_user_name, len_user_name != 0);
3054         make_unistr2(&(q_u->uni_user_name), user_name, len_user_name);  
3055
3056         make_enc_passwd(&(q_u->nt_newpass), nt_newpass);
3057         make_enc_hash  (&(q_u->nt_oldhash), nt_oldhash);
3058
3059         q_u->unknown = 0x01;
3060
3061         make_enc_passwd(&(q_u->lm_newpass), lm_newpass);
3062         make_enc_hash  (&(q_u->lm_oldhash), lm_oldhash);
3063 }
3064
3065 /*******************************************************************
3066 reads or writes a structure.
3067 ********************************************************************/
3068 void samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER *q_u, prs_struct *ps, int depth)
3069 {
3070         if (q_u == NULL) return;
3071
3072         prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
3073         depth++;
3074
3075         prs_align(ps);
3076
3077         prs_uint32("ptr_0", ps, depth, &(q_u->ptr_0));
3078
3079         smb_io_unihdr ("", &(q_u->hdr_dest_host), ps, depth); 
3080         smb_io_unistr2("", &(q_u->uni_dest_host), q_u->hdr_dest_host.buffer, ps, depth); 
3081         smb_io_unihdr ("", &(q_u->hdr_user_name), ps, depth); 
3082         smb_io_unistr2("", &(q_u->uni_user_name), q_u->hdr_user_name.buffer, ps, depth); 
3083
3084         samr_io_enc_passwd("nt_newpass", &(q_u->nt_newpass), ps, depth); 
3085         prs_grow(ps);
3086         samr_io_enc_hash  ("nt_oldhash", &(q_u->nt_oldhash), ps, depth); 
3087
3088         prs_uint32("unknown", ps, depth, &(q_u->unknown));
3089
3090         samr_io_enc_passwd("lm_newpass", &(q_u->lm_newpass), ps, depth); 
3091         prs_grow(ps);
3092         samr_io_enc_hash  ("lm_oldhash", &(q_u->lm_oldhash), ps, depth); 
3093 }
3094
3095 /*******************************************************************
3096 makes a SAMR_R_CHGPASSWD_USER structure.
3097 ********************************************************************/
3098 void make_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER *r_u, uint32 status)
3099 {
3100         if (r_u == NULL) return;
3101
3102         DEBUG(5,("make_r_chgpasswd_user\n"));
3103
3104         r_u->status = status;
3105 }
3106
3107 /*******************************************************************
3108 reads or writes a structure.
3109 ********************************************************************/
3110 void samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER *r_u, prs_struct *ps, int depth)
3111 {
3112         if (r_u == NULL) return;
3113
3114         prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
3115         depth++;
3116
3117         prs_align(ps);
3118
3119         prs_uint32("status", ps, depth, &(r_u->status));
3120 }
3121
3122