ef54b4a30db30940946a972318cfbc51c003fe56
[samba.git] / source3 / rpc_parse / parse_lsa.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Paul Ashton                       1997,
7  *  Copyright (C) Andrew Bartlett                   2002,
8  *  Copyright (C) Jim McDonough <jmcd@us.ibm.com>   2002.
9  *  Copyright (C) Gerald )Jerry) Carter             2005
10  *  
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 3 of the License, or
14  *  (at your option) any later version.
15  *  
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *  
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
23  */
24
25 #include "includes.h"
26
27 #undef DBGC_CLASS
28 #define DBGC_CLASS DBGC_RPC_PARSE
29
30 static bool lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn, prs_struct *ps, int depth);
31 static bool lsa_io_trans_names2(const char *desc, LSA_TRANS_NAME_ENUM2 *trn, prs_struct *ps, int depth);
32
33 /*******************************************************************
34  Inits a LSA_TRANS_NAME structure.
35 ********************************************************************/
36
37 void init_lsa_trans_name(LSA_TRANS_NAME *trn, UNISTR2 *uni_name,
38                          uint16 sid_name_use, const char *name, uint32 idx)
39 {
40         trn->sid_name_use = sid_name_use;
41         init_unistr2(uni_name, name, UNI_FLAGS_NONE);
42         init_uni_hdr(&trn->hdr_name, uni_name);
43         trn->domain_idx = idx;
44 }
45
46 /*******************************************************************
47  Reads or writes a LSA_TRANS_NAME structure.
48 ********************************************************************/
49
50 static bool lsa_io_trans_name(const char *desc, LSA_TRANS_NAME *trn, prs_struct *ps, 
51                               int depth)
52 {
53         prs_debug(ps, depth, desc, "lsa_io_trans_name");
54         depth++;
55
56         if(!prs_align(ps))
57                 return False;
58         
59         if(!prs_uint16("sid_name_use", ps, depth, &trn->sid_name_use))
60                 return False;
61         if(!prs_align(ps))
62                 return False;
63         
64         if(!smb_io_unihdr ("hdr_name", &trn->hdr_name, ps, depth))
65                 return False;
66         if(!prs_uint32("domain_idx  ", ps, depth, &trn->domain_idx))
67                 return False;
68
69         return True;
70 }
71
72 /*******************************************************************
73  Inits a LSA_TRANS_NAME2 structure.
74 ********************************************************************/
75
76 void init_lsa_trans_name2(LSA_TRANS_NAME2 *trn, UNISTR2 *uni_name,
77                          uint16 sid_name_use, const char *name, uint32 idx)
78 {
79         trn->sid_name_use = sid_name_use;
80         init_unistr2(uni_name, name, UNI_FLAGS_NONE);
81         init_uni_hdr(&trn->hdr_name, uni_name);
82         trn->domain_idx = idx;
83         trn->unknown = 0;
84 }
85
86 /*******************************************************************
87  Reads or writes a LSA_TRANS_NAME2 structure.
88 ********************************************************************/
89
90 static bool lsa_io_trans_name2(const char *desc, LSA_TRANS_NAME2 *trn, prs_struct *ps, 
91                               int depth)
92 {
93         prs_debug(ps, depth, desc, "lsa_io_trans_name2");
94         depth++;
95
96         if(!prs_align(ps))
97                 return False;
98         
99         if(!prs_uint16("sid_name_use", ps, depth, &trn->sid_name_use))
100                 return False;
101         if(!prs_align(ps))
102                 return False;
103         
104         if(!smb_io_unihdr ("hdr_name", &trn->hdr_name, ps, depth))
105                 return False;
106         if(!prs_uint32("domain_idx  ", ps, depth, &trn->domain_idx))
107                 return False;
108         if(!prs_uint32("unknown  ", ps, depth, &trn->unknown))
109                 return False;
110
111         return True;
112 }
113
114 /*******************************************************************
115  Reads or writes a DOM_R_REF structure.
116 ********************************************************************/
117
118 static bool lsa_io_dom_r_ref(const char *desc, DOM_R_REF *dom, prs_struct *ps, int depth)
119 {
120         unsigned int i;
121
122         prs_debug(ps, depth, desc, "lsa_io_dom_r_ref");
123         depth++;
124
125         if(!prs_align(ps))
126                 return False;
127         
128         if(!prs_uint32("num_ref_doms_1", ps, depth, &dom->num_ref_doms_1)) /* num referenced domains? */
129                 return False;
130         if(!prs_uint32("ptr_ref_dom   ", ps, depth, &dom->ptr_ref_dom)) /* undocumented buffer pointer. */
131                 return False;
132         if(!prs_uint32("max_entries   ", ps, depth, &dom->max_entries)) /* 32 - max number of entries */
133                 return False;
134
135         SMB_ASSERT_ARRAY(dom->hdr_ref_dom, dom->num_ref_doms_1);
136
137         if (dom->ptr_ref_dom != 0) {
138
139                 if(!prs_uint32("num_ref_doms_2", ps, depth, &dom->num_ref_doms_2)) /* 4 - num referenced domains? */
140                         return False;
141
142                 SMB_ASSERT_ARRAY(dom->ref_dom, dom->num_ref_doms_2);
143
144                 for (i = 0; i < dom->num_ref_doms_1; i++) {
145                         fstring t;
146
147                         slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
148                         if(!smb_io_unihdr(t, &dom->hdr_ref_dom[i].hdr_dom_name, ps, depth))
149                                 return False;
150
151                         slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i);
152                         if(!prs_uint32(t, ps, depth, &dom->hdr_ref_dom[i].ptr_dom_sid))
153                                 return False;
154                 }
155
156                 for (i = 0; i < dom->num_ref_doms_2; i++) {
157                         fstring t;
158
159                         if (dom->hdr_ref_dom[i].hdr_dom_name.buffer != 0) {
160                                 slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
161                                 if(!smb_io_unistr2(t, &dom->ref_dom[i].uni_dom_name, True, ps, depth)) /* domain name unicode string */
162                                         return False;
163                                 if(!prs_align(ps))
164                                         return False;
165                         }
166
167                         if (dom->hdr_ref_dom[i].ptr_dom_sid != 0) {
168                                 slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i);
169                                 if(!smb_io_dom_sid2(t, &dom->ref_dom[i].ref_dom, ps, depth)) /* referenced domain SIDs */
170                                         return False;
171                         }
172                 }
173         }
174
175         return True;
176 }
177
178 /*******************************************************************
179  Inits an LSA_SEC_QOS structure.
180 ********************************************************************/
181
182 void init_lsa_sec_qos(LSA_SEC_QOS *qos, uint16 imp_lev, uint8 ctxt, uint8 eff)
183 {
184         DEBUG(5, ("init_lsa_sec_qos\n"));
185
186         qos->len = 0x0c; /* length of quality of service block, in bytes */
187         qos->sec_imp_level = imp_lev;
188         qos->sec_ctxt_mode = ctxt;
189         qos->effective_only = eff;
190 }
191
192 /*******************************************************************
193  Reads or writes an LSA_SEC_QOS structure.
194 ********************************************************************/
195
196 static bool lsa_io_sec_qos(const char *desc,  LSA_SEC_QOS *qos, prs_struct *ps, 
197                            int depth)
198 {
199         uint32 start;
200
201         prs_debug(ps, depth, desc, "lsa_io_obj_qos");
202         depth++;
203
204         if(!prs_align(ps))
205                 return False;
206         
207         start = prs_offset(ps);
208
209         /* these pointers had _better_ be zero, because we don't know
210            what they point to!
211          */
212         if(!prs_uint32("len           ", ps, depth, &qos->len)) /* 0x18 - length (in bytes) inc. the length field. */
213                 return False;
214         if(!prs_uint16("sec_imp_level ", ps, depth, &qos->sec_imp_level ))
215                 return False;
216         if(!prs_uint8 ("sec_ctxt_mode ", ps, depth, &qos->sec_ctxt_mode ))
217                 return False;
218         if(!prs_uint8 ("effective_only", ps, depth, &qos->effective_only))
219                 return False;
220
221         if (qos->len != prs_offset(ps) - start) {
222                 DEBUG(3,("lsa_io_sec_qos: length %x does not match size %x\n",
223                          qos->len, prs_offset(ps) - start));
224         }
225
226         return True;
227 }
228
229 /*******************************************************************
230  Inits an LSA_OBJ_ATTR structure.
231 ********************************************************************/
232
233 static void init_lsa_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, LSA_SEC_QOS *qos)
234 {
235         DEBUG(5, ("init_lsa_obj_attr\n"));
236
237         attr->len = 0x18; /* length of object attribute block, in bytes */
238         attr->ptr_root_dir = 0;
239         attr->ptr_obj_name = 0;
240         attr->attributes = attributes;
241         attr->ptr_sec_desc = 0;
242         
243         if (qos != NULL) {
244                 attr->ptr_sec_qos = 1;
245                 attr->sec_qos = qos;
246         } else {
247                 attr->ptr_sec_qos = 0;
248                 attr->sec_qos = NULL;
249         }
250 }
251
252 /*******************************************************************
253  Reads or writes an LSA_OBJ_ATTR structure.
254 ********************************************************************/
255
256 static bool lsa_io_obj_attr(const char *desc, LSA_OBJ_ATTR *attr, prs_struct *ps, 
257                             int depth)
258 {
259         prs_debug(ps, depth, desc, "lsa_io_obj_attr");
260         depth++;
261
262         if(!prs_align(ps))
263                 return False;
264         
265         /* these pointers had _better_ be zero, because we don't know
266            what they point to!
267          */
268         if(!prs_uint32("len         ", ps, depth, &attr->len)) /* 0x18 - length (in bytes) inc. the length field. */
269                 return False;
270         if(!prs_uint32("ptr_root_dir", ps, depth, &attr->ptr_root_dir)) /* 0 - root directory (pointer) */
271                 return False;
272         if(!prs_uint32("ptr_obj_name", ps, depth, &attr->ptr_obj_name)) /* 0 - object name (pointer) */
273                 return False;
274         if(!prs_uint32("attributes  ", ps, depth, &attr->attributes)) /* 0 - attributes (undocumented) */
275                 return False;
276         if(!prs_uint32("ptr_sec_desc", ps, depth, &attr->ptr_sec_desc)) /* 0 - security descriptior (pointer) */
277                 return False;
278         if(!prs_uint32("ptr_sec_qos ", ps, depth, &attr->ptr_sec_qos )) /* security quality of service (pointer) */
279                 return False;
280
281         if (attr->ptr_sec_qos != 0) {
282                 if (UNMARSHALLING(ps))
283                         if (!(attr->sec_qos = PRS_ALLOC_MEM(ps,LSA_SEC_QOS,1)))
284                                 return False;
285
286                 if(!lsa_io_sec_qos("sec_qos", attr->sec_qos, ps, depth))
287                         return False;
288         }
289
290         return True;
291 }
292
293
294 /*******************************************************************
295  Inits an LSA_Q_OPEN_POL structure.
296 ********************************************************************/
297
298 void init_q_open_pol(LSA_Q_OPEN_POL *in, uint16 system_name,
299                      uint32 attributes, uint32 desired_access,
300                      LSA_SEC_QOS *qos)
301 {
302         DEBUG(5, ("init_open_pol: attr:%d da:%d\n", attributes, 
303                   desired_access));
304
305         in->ptr = 1; /* undocumented pointer */
306
307         in->des_access = desired_access;
308
309         in->system_name = system_name;
310         init_lsa_obj_attr(&in->attr, attributes, qos);
311 }
312
313 /*******************************************************************
314  Reads or writes an LSA_Q_OPEN_POL structure.
315 ********************************************************************/
316
317 bool lsa_io_q_open_pol(const char *desc, LSA_Q_OPEN_POL *in, prs_struct *ps, 
318                        int depth)
319 {
320         prs_debug(ps, depth, desc, "lsa_io_q_open_pol");
321         depth++;
322
323         if(!prs_uint32("ptr       ", ps, depth, &in->ptr))
324                 return False;
325         if(!prs_uint16("system_name", ps, depth, &in->system_name))
326                 return False;
327         if(!prs_align( ps ))
328                 return False;
329
330         if(!lsa_io_obj_attr("", &in->attr, ps, depth))
331                 return False;
332
333         if(!prs_uint32("des_access", ps, depth, &in->des_access))
334                 return False;
335
336         return True;
337 }
338
339 /*******************************************************************
340  Reads or writes an LSA_R_OPEN_POL structure.
341 ********************************************************************/
342
343 bool lsa_io_r_open_pol(const char *desc, LSA_R_OPEN_POL *out, prs_struct *ps, 
344                        int depth)
345 {
346         prs_debug(ps, depth, desc, "lsa_io_r_open_pol");
347         depth++;
348
349         if(!smb_io_pol_hnd("", &out->pol, ps, depth))
350                 return False;
351
352         if(!prs_ntstatus("status", ps, depth, &out->status))
353                 return False;
354
355         return True;
356 }
357
358 /*******************************************************************
359  Inits an LSA_Q_OPEN_POL2 structure.
360 ********************************************************************/
361
362 void init_q_open_pol2(LSA_Q_OPEN_POL2 *in, const char *server_name,
363                         uint32 attributes, uint32 desired_access,
364                         LSA_SEC_QOS *qos)
365 {
366         DEBUG(5, ("init_q_open_pol2: attr:%d da:%d\n", attributes, 
367                   desired_access));
368
369         in->ptr = 1; /* undocumented pointer */
370
371         in->des_access = desired_access;
372
373         init_unistr2(&in->uni_server_name, server_name, UNI_STR_TERMINATE);
374
375         init_lsa_obj_attr(&in->attr, attributes, qos);
376 }
377
378 /*******************************************************************
379  Reads or writes an LSA_Q_OPEN_POL2 structure.
380 ********************************************************************/
381
382 bool lsa_io_q_open_pol2(const char *desc, LSA_Q_OPEN_POL2 *in, prs_struct *ps, 
383                         int depth)
384 {
385         prs_debug(ps, depth, desc, "lsa_io_q_open_pol2");
386         depth++;
387
388         if(!prs_uint32("ptr       ", ps, depth, &in->ptr))
389                 return False;
390
391         if(!smb_io_unistr2 ("", &in->uni_server_name, in->ptr, ps, depth))
392                 return False;
393         if(!lsa_io_obj_attr("", &in->attr, ps, depth))
394                 return False;
395
396         if(!prs_uint32("des_access", ps, depth, &in->des_access))
397                 return False;
398
399         return True;
400 }
401
402 /*******************************************************************
403  Reads or writes an LSA_R_OPEN_POL2 structure.
404 ********************************************************************/
405
406 bool lsa_io_r_open_pol2(const char *desc, LSA_R_OPEN_POL2 *out, prs_struct *ps, 
407                         int depth)
408 {
409         prs_debug(ps, depth, desc, "lsa_io_r_open_pol2");
410         depth++;
411
412         if(!smb_io_pol_hnd("", &out->pol, ps, depth))
413                 return False;
414
415         if(!prs_ntstatus("status", ps, depth, &out->status))
416                 return False;
417
418         return True;
419 }
420
421 /*******************************************************************
422 makes an LSA_Q_ENUM_TRUST_DOM structure.
423 ********************************************************************/
424 bool init_q_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM * q_e, POLICY_HND *pol,
425                            uint32 enum_context, uint32 preferred_len)
426 {
427         DEBUG(5, ("init_q_enum_trust_dom\n"));
428
429         q_e->pol = *pol;
430         q_e->enum_context = enum_context;
431         q_e->preferred_len = preferred_len;
432
433         return True;
434 }
435
436 /*******************************************************************
437  Reads or writes an LSA_Q_ENUM_TRUST_DOM structure.
438 ********************************************************************/
439
440 bool lsa_io_q_enum_trust_dom(const char *desc, LSA_Q_ENUM_TRUST_DOM *q_e, 
441                              prs_struct *ps, int depth)
442 {
443         prs_debug(ps, depth, desc, "lsa_io_q_enum_trust_dom");
444         depth++;
445
446         if(!smb_io_pol_hnd("", &q_e->pol, ps, depth))
447                 return False;
448
449         if(!prs_uint32("enum_context ", ps, depth, &q_e->enum_context))
450                 return False;
451         if(!prs_uint32("preferred_len", ps, depth, &q_e->preferred_len))
452                 return False;
453
454         return True;
455 }
456
457 /*******************************************************************
458  Inits an LSA_R_ENUM_TRUST_DOM structure.
459 ********************************************************************/
460
461 void init_r_enum_trust_dom(TALLOC_CTX *ctx, LSA_R_ENUM_TRUST_DOM *out,
462                            uint32 enum_context, uint32 num_domains,
463                            struct trustdom_info **td)
464 {
465         unsigned int i;
466
467         DEBUG(5, ("init_r_enum_trust_dom\n"));
468         
469         out->enum_context  = enum_context;
470         out->count         = num_domains;
471                         
472         if ( num_domains != 0 ) {
473         
474                 /* allocate container memory */
475                 
476                 out->domlist = TALLOC_P( ctx, DOMAIN_LIST );
477
478                 if ( !out->domlist ) {
479                         out->status = NT_STATUS_NO_MEMORY;
480                         return;
481                 }
482
483                 if (out->count) {
484                         out->domlist->domains = TALLOC_ARRAY( ctx, DOMAIN_INFO,
485                                                       out->count );
486                         if ( !out->domlist->domains ) {
487                                 out->status = NT_STATUS_NO_MEMORY;
488                                 return;
489                         }
490                 } else {                
491                         out->domlist->domains = NULL;
492                 }
493         
494                 out->domlist->count = out->count;
495                 
496                 /* initialize the list of domains and their sid */
497                 
498                 for (i = 0; i < num_domains; i++) {     
499                         smb_ucs2_t *name;
500                         if ( !(out->domlist->domains[i].sid =
501                                TALLOC_P(ctx, DOM_SID2)) ) {
502                                 out->status = NT_STATUS_NO_MEMORY;
503                                 return;
504                         }
505                                 
506                         init_dom_sid2(out->domlist->domains[i].sid,
507                                       &(td[i])->sid);
508                         if (push_ucs2_talloc(ctx, &name, (td[i])->name) == (size_t)-1){
509                                 out->status = NT_STATUS_NO_MEMORY;
510                                 return;
511                         }
512                         init_unistr4_w(ctx, &out->domlist->domains[i].name,
513                                        name);
514                 }
515         }
516
517 }
518
519 /*******************************************************************
520 ********************************************************************/
521
522 bool lsa_io_domain_list( const char *desc, prs_struct *ps, int depth, DOMAIN_LIST *domlist )
523 {
524         int i;
525         
526         prs_debug(ps, depth, desc, "lsa_io_domain_list");
527         depth++;
528
529         if(!prs_uint32("count", ps, depth, &domlist->count))
530                 return False;
531
532         if ( domlist->count == 0 )
533                 return True;
534                 
535         if ( UNMARSHALLING(ps) ) {
536                 if ( !(domlist->domains = PRS_ALLOC_MEM( ps, DOMAIN_INFO, domlist->count )) )
537                         return False;
538         }
539         
540         /* headers */
541         
542         for ( i=0; i<domlist->count; i++ ) {
543                 if ( !prs_unistr4_hdr("name_header", ps, depth, &domlist->domains[i].name) )
544                         return False;
545                 if ( !smb_io_dom_sid2_p("sid_header", ps, depth, &domlist->domains[i].sid) )
546                         return False;
547         }
548
549         /* data */
550         
551         for ( i=0; i<domlist->count; i++ ) {
552                 if ( !prs_unistr4_str("name", ps, depth, &domlist->domains[i].name) )
553                         return False;
554                 if( !smb_io_dom_sid2("sid", domlist->domains[i].sid, ps, depth) )
555                         return False;
556         }
557         
558         return True;
559 }
560
561 /*******************************************************************
562  Reads or writes an LSA_R_ENUM_TRUST_DOM structure.
563 ********************************************************************/
564
565 bool lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *out, 
566                              prs_struct *ps, int depth)
567 {
568         prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom");
569         depth++;
570
571         if(!prs_uint32("enum_context", ps, depth, &out->enum_context))
572                 return False;
573
574         if(!prs_uint32("count", ps, depth, &out->count))
575                 return False;
576
577         if ( !prs_pointer("trusted_domains", ps, depth, (void*)&out->domlist, sizeof(DOMAIN_LIST), (PRS_POINTER_CAST)lsa_io_domain_list))
578                 return False;
579                 
580         if(!prs_ntstatus("status", ps, depth, &out->status))
581                 return False;
582
583         return True;
584 }
585
586 /*******************************************************************
587  Inits a LSA_SID_ENUM structure.
588 ********************************************************************/
589
590 static void init_lsa_sid_enum(TALLOC_CTX *mem_ctx, LSA_SID_ENUM *sen, 
591                        int num_entries, const DOM_SID *sids)
592 {
593         int i;
594
595         DEBUG(5, ("init_lsa_sid_enum\n"));
596
597         sen->num_entries  = num_entries;
598         sen->ptr_sid_enum = (num_entries != 0);
599         sen->num_entries2 = num_entries;
600
601         /* Allocate memory for sids and sid pointers */
602
603         if (num_entries) {
604                 if ((sen->ptr_sid = TALLOC_ZERO_ARRAY(mem_ctx, uint32, num_entries )) == NULL) {
605                         DEBUG(3, ("init_lsa_sid_enum(): out of memory for ptr_sid\n"));
606                         return;
607                 }
608
609                 if ((sen->sid = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID2, num_entries)) == NULL) {
610                         DEBUG(3, ("init_lsa_sid_enum(): out of memory for sids\n"));
611                         return;
612                 }
613         }
614
615         /* Copy across SIDs and SID pointers */
616
617         for (i = 0; i < num_entries; i++) {
618                 sen->ptr_sid[i] = 1;
619                 init_dom_sid2(&sen->sid[i], &sids[i]);
620         }
621 }
622
623 /*******************************************************************
624  Reads or writes a LSA_SID_ENUM structure.
625 ********************************************************************/
626
627 static bool lsa_io_sid_enum(const char *desc, LSA_SID_ENUM *sen, prs_struct *ps, 
628                             int depth)
629 {
630         unsigned int i;
631
632         prs_debug(ps, depth, desc, "lsa_io_sid_enum");
633         depth++;
634
635         if(!prs_align(ps))
636                 return False;
637         
638         if(!prs_uint32("num_entries ", ps, depth, &sen->num_entries))
639                 return False;
640         if(!prs_uint32("ptr_sid_enum", ps, depth, &sen->ptr_sid_enum))
641                 return False;
642
643         /*
644            if the ptr is NULL, leave here. checked from a real w2k trace.
645            JFM, 11/23/2001
646          */
647         
648         if (sen->ptr_sid_enum==0)
649                 return True;
650
651         if(!prs_uint32("num_entries2", ps, depth, &sen->num_entries2))
652                 return False;
653
654         /* Mallocate memory if we're unpacking from the wire */
655
656         if (UNMARSHALLING(ps) && sen->num_entries) {
657                 if ((sen->ptr_sid = PRS_ALLOC_MEM( ps, uint32, sen->num_entries)) == NULL) {
658                         DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
659                                   "ptr_sid\n"));
660                         return False;
661                 }
662
663                 if ((sen->sid = PRS_ALLOC_MEM( ps, DOM_SID2, sen->num_entries)) == NULL) {
664                         DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
665                                   "sids\n"));
666                         return False;
667                 }
668         }
669
670         for (i = 0; i < sen->num_entries; i++) {        
671                 fstring temp;
672
673                 slprintf(temp, sizeof(temp) - 1, "ptr_sid[%d]", i);
674                 if(!prs_uint32(temp, ps, depth, &sen->ptr_sid[i])) {
675                         return False;
676                 }
677         }
678
679         for (i = 0; i < sen->num_entries; i++) {
680                 fstring temp;
681
682                 slprintf(temp, sizeof(temp) - 1, "sid[%d]", i);
683                 if(!smb_io_dom_sid2(temp, &sen->sid[i], ps, depth)) {
684                         return False;
685                 }
686         }
687
688         return True;
689 }
690
691 /*******************************************************************
692  Inits an LSA_R_ENUM_TRUST_DOM structure.
693 ********************************************************************/
694
695 void init_q_lookup_sids(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_SIDS *q_l, 
696                         POLICY_HND *hnd, int num_sids, const DOM_SID *sids,
697                         uint16 level)
698 {
699         DEBUG(5, ("init_q_lookup_sids\n"));
700
701         ZERO_STRUCTP(q_l);
702
703         memcpy(&q_l->pol, hnd, sizeof(q_l->pol));
704         init_lsa_sid_enum(mem_ctx, &q_l->sids, num_sids, sids);
705         
706         q_l->level = level;
707 }
708
709 /*******************************************************************
710  Reads or writes a LSA_Q_LOOKUP_SIDS structure.
711 ********************************************************************/
712
713 bool lsa_io_q_lookup_sids(const char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps,
714                           int depth)
715 {
716         prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids");
717         depth++;
718
719         if(!prs_align(ps))
720                 return False;
721         
722         if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */
723                 return False;
724         if(!lsa_io_sid_enum("sids   ", &q_s->sids, ps, depth)) /* sids to be looked up */
725                 return False;
726         if(!lsa_io_trans_names("names  ", &q_s->names, ps, depth)) /* translated names */
727                 return False;
728
729         if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */
730                 return False;
731         if(!prs_align(ps))
732                 return False;
733
734         if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count))
735                 return False;
736
737         return True;
738 }
739
740 /*******************************************************************
741  Reads or writes a LSA_Q_LOOKUP_SIDS2 structure.
742 ********************************************************************/
743
744 bool lsa_io_q_lookup_sids2(const char *desc, LSA_Q_LOOKUP_SIDS2 *q_s, prs_struct *ps,
745                           int depth)
746 {
747         prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids2");
748         depth++;
749
750         if(!prs_align(ps))
751                 return False;
752         
753         if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */
754                 return False;
755         if(!lsa_io_sid_enum("sids   ", &q_s->sids, ps, depth)) /* sids to be looked up */
756                 return False;
757         if(!lsa_io_trans_names2("names  ", &q_s->names, ps, depth)) /* translated names */
758                 return False;
759
760         if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */
761                 return False;
762         if(!prs_align(ps))
763                 return False;
764
765         if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count))
766                 return False;
767         if(!prs_uint32("unknown1", ps, depth, &q_s->unknown1))
768                 return False;
769         if(!prs_uint32("unknown2", ps, depth, &q_s->unknown2))
770                 return False;
771
772         return True;
773 }
774
775 /*******************************************************************
776  Reads or writes a LSA_Q_LOOKUP_SIDS3 structure.
777 ********************************************************************/
778
779 bool lsa_io_q_lookup_sids3(const char *desc, LSA_Q_LOOKUP_SIDS3 *q_s, prs_struct *ps,
780                           int depth)
781 {
782         prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids3");
783         depth++;
784
785         if(!prs_align(ps))
786                 return False;
787         
788         if(!lsa_io_sid_enum("sids   ", &q_s->sids, ps, depth)) /* sids to be looked up */
789                 return False;
790         if(!lsa_io_trans_names2("names  ", &q_s->names, ps, depth)) /* translated names */
791                 return False;
792
793         if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */
794                 return False;
795         if(!prs_align(ps))
796                 return False;
797
798         if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count))
799                 return False;
800         if(!prs_uint32("unknown1", ps, depth, &q_s->unknown1))
801                 return False;
802         if(!prs_uint32("unknown2", ps, depth, &q_s->unknown2))
803                 return False;
804
805         return True;
806 }
807
808
809 /*******************************************************************
810  Reads or writes a structure.
811 ********************************************************************/
812
813 static bool lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn,
814                 prs_struct *ps, int depth)
815 {
816         unsigned int i;
817
818         prs_debug(ps, depth, desc, "lsa_io_trans_names");
819         depth++;
820
821         if(!prs_align(ps))
822                 return False;
823    
824         if(!prs_uint32("num_entries    ", ps, depth, &trn->num_entries))
825                 return False;
826         if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names))
827                 return False;
828
829         if (trn->ptr_trans_names != 0) {
830                 if(!prs_uint32("num_entries2   ", ps, depth, 
831                                &trn->num_entries2))
832                         return False;
833
834                 if (trn->num_entries2 != trn->num_entries) {
835                         /* RPC fault */
836                         return False;
837                 }
838
839                 if (UNMARSHALLING(ps) && trn->num_entries2) {
840                         if ((trn->name = PRS_ALLOC_MEM(ps, LSA_TRANS_NAME, trn->num_entries2)) == NULL) {
841                                 return False;
842                         }
843
844                         if ((trn->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, trn->num_entries2)) == NULL) {
845                                 return False;
846                         }
847                 }
848
849                 for (i = 0; i < trn->num_entries2; i++) {
850                         fstring t;
851                         slprintf(t, sizeof(t) - 1, "name[%d] ", i);
852
853                         if(!lsa_io_trans_name(t, &trn->name[i], ps, depth)) /* translated name */
854                                 return False;
855                 }
856
857                 for (i = 0; i < trn->num_entries2; i++) {
858                         fstring t;
859                         slprintf(t, sizeof(t) - 1, "name[%d] ", i);
860
861                         if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth))
862                                 return False;
863                         if(!prs_align(ps))
864                                 return False;
865                 }
866         }
867
868         return True;
869 }
870
871 /*******************************************************************
872  Reads or writes a structure.
873 ********************************************************************/
874
875 static bool lsa_io_trans_names2(const char *desc, LSA_TRANS_NAME_ENUM2 *trn,
876                 prs_struct *ps, int depth)
877 {
878         unsigned int i;
879
880         prs_debug(ps, depth, desc, "lsa_io_trans_names2");
881         depth++;
882
883         if(!prs_align(ps))
884                 return False;
885    
886         if(!prs_uint32("num_entries    ", ps, depth, &trn->num_entries))
887                 return False;
888         if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names))
889                 return False;
890
891         if (trn->ptr_trans_names != 0) {
892                 if(!prs_uint32("num_entries2   ", ps, depth, 
893                                &trn->num_entries2))
894                         return False;
895
896                 if (trn->num_entries2 != trn->num_entries) {
897                         /* RPC fault */
898                         return False;
899                 }
900
901                 if (UNMARSHALLING(ps) && trn->num_entries2) {
902                         if ((trn->name = PRS_ALLOC_MEM(ps, LSA_TRANS_NAME2, trn->num_entries2)) == NULL) {
903                                 return False;
904                         }
905
906                         if ((trn->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, trn->num_entries2)) == NULL) {
907                                 return False;
908                         }
909                 }
910
911                 for (i = 0; i < trn->num_entries2; i++) {
912                         fstring t;
913                         slprintf(t, sizeof(t) - 1, "name[%d] ", i);
914
915                         if(!lsa_io_trans_name2(t, &trn->name[i], ps, depth)) /* translated name */
916                                 return False;
917                 }
918
919                 for (i = 0; i < trn->num_entries2; i++) {
920                         fstring t;
921                         slprintf(t, sizeof(t) - 1, "name[%d] ", i);
922
923                         if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth))
924                                 return False;
925                         if(!prs_align(ps))
926                                 return False;
927                 }
928         }
929
930         return True;
931 }
932
933
934 /*******************************************************************
935  Reads or writes a structure.
936 ********************************************************************/
937
938 bool lsa_io_r_lookup_sids(const char *desc, LSA_R_LOOKUP_SIDS *r_s, 
939                           prs_struct *ps, int depth)
940 {
941         prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids");
942         depth++;
943
944         if(!prs_align(ps))
945                 return False;
946         
947         if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref))
948                 return False;
949
950         if (r_s->ptr_dom_ref != 0)
951                 if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */
952                         return False;
953
954         if(!lsa_io_trans_names("names  ", &r_s->names, ps, depth)) /* translated names */
955                 return False;
956
957         if(!prs_align(ps))
958                 return False;
959
960         if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count))
961                 return False;
962
963         if(!prs_ntstatus("status      ", ps, depth, &r_s->status))
964                 return False;
965
966         return True;
967 }
968
969 /*******************************************************************
970  Reads or writes a structure.
971 ********************************************************************/
972
973 bool lsa_io_r_lookup_sids2(const char *desc, LSA_R_LOOKUP_SIDS2 *r_s, 
974                           prs_struct *ps, int depth)
975 {
976         prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids2");
977         depth++;
978
979         if(!prs_align(ps))
980                 return False;
981         
982         if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref))
983                 return False;
984
985         if (r_s->ptr_dom_ref != 0)
986                 if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */
987                         return False;
988
989         if(!lsa_io_trans_names2("names  ", &r_s->names, ps, depth)) /* translated names */
990                 return False;
991
992         if(!prs_align(ps))
993                 return False;
994
995         if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count))
996                 return False;
997
998         if(!prs_ntstatus("status      ", ps, depth, &r_s->status))
999                 return False;
1000
1001         return True;
1002 }
1003
1004
1005 /*******************************************************************
1006  Reads or writes a structure.
1007 ********************************************************************/
1008
1009 bool lsa_io_r_lookup_sids3(const char *desc, LSA_R_LOOKUP_SIDS3 *r_s, 
1010                           prs_struct *ps, int depth)
1011 {
1012         prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids3");
1013         depth++;
1014
1015         if(!prs_align(ps))
1016                 return False;
1017         
1018         if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref))
1019                 return False;
1020
1021         if (r_s->ptr_dom_ref != 0)
1022                 if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */
1023                         return False;
1024
1025         if(!lsa_io_trans_names2("names  ", &r_s->names, ps, depth)) /* translated names */
1026                 return False;
1027
1028         if(!prs_align(ps))
1029                 return False;
1030
1031         if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count))
1032                 return False;
1033
1034         if(!prs_ntstatus("status      ", ps, depth, &r_s->status))
1035                 return False;
1036
1037         return True;
1038 }
1039
1040 /*******************************************************************
1041 makes a structure.
1042 ********************************************************************/
1043
1044 void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l, 
1045                          POLICY_HND *hnd, int num_names, const char **names, 
1046                          int level)
1047 {
1048         unsigned int i;
1049
1050         DEBUG(5, ("init_q_lookup_names\n"));
1051
1052         ZERO_STRUCTP(q_l);
1053
1054         q_l->pol = *hnd;
1055         q_l->num_entries = num_names;
1056         q_l->num_entries2 = num_names;
1057         q_l->lookup_level = level;
1058
1059         if (num_names) {
1060                 if ((q_l->uni_name = TALLOC_ZERO_ARRAY(mem_ctx, UNISTR2, num_names)) == NULL) {
1061                         DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1062                         return;
1063                 }
1064
1065                 if ((q_l->hdr_name = TALLOC_ZERO_ARRAY(mem_ctx, UNIHDR, num_names)) == NULL) {
1066                         DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1067                         return;
1068                 }
1069         } else {
1070                 q_l->uni_name = NULL;
1071                 q_l->hdr_name = NULL;
1072         }
1073
1074         for (i = 0; i < num_names; i++) {
1075                 init_unistr2(&q_l->uni_name[i], names[i], UNI_FLAGS_NONE);
1076                 init_uni_hdr(&q_l->hdr_name[i], &q_l->uni_name[i]);
1077         }
1078 }
1079
1080 /*******************************************************************
1081 reads or writes a structure.
1082 ********************************************************************/
1083
1084 bool lsa_io_q_lookup_names(const char *desc, LSA_Q_LOOKUP_NAMES *q_r, 
1085                            prs_struct *ps, int depth)
1086 {
1087         unsigned int i;
1088
1089         prs_debug(ps, depth, desc, "lsa_io_q_lookup_names");
1090         depth++;
1091
1092         if(!prs_align(ps))
1093                 return False;
1094
1095         if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */
1096                 return False;
1097
1098         if(!prs_align(ps))
1099                 return False;
1100         if(!prs_uint32("num_entries    ", ps, depth, &q_r->num_entries))
1101                 return False;
1102         if(!prs_uint32("num_entries2   ", ps, depth, &q_r->num_entries2))
1103                 return False;
1104
1105         if (UNMARSHALLING(ps)) {
1106                 if (q_r->num_entries) {
1107                         if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)
1108                                 return False;
1109                         if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)
1110                                 return False;
1111                 }
1112         }
1113
1114         for (i = 0; i < q_r->num_entries; i++) {
1115                 if(!prs_align(ps))
1116                         return False;
1117                 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1118                         return False;
1119         }
1120
1121         for (i = 0; i < q_r->num_entries; i++) {
1122                 if(!prs_align(ps))
1123                         return False;
1124                 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1125                         return False;
1126         }
1127
1128         if(!prs_align(ps))
1129                 return False;
1130         if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1131                 return False;
1132         if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1133                 return False;
1134         if(!prs_uint16("lookup_level   ", ps, depth, &q_r->lookup_level))
1135                 return False;
1136         if(!prs_align(ps))
1137                 return False;
1138         if(!prs_uint32("mapped_count   ", ps, depth, &q_r->mapped_count))
1139                 return False;
1140
1141         return True;
1142 }
1143
1144 /*******************************************************************
1145 reads or writes a structure.
1146 ********************************************************************/
1147
1148 bool lsa_io_r_lookup_names(const char *desc, LSA_R_LOOKUP_NAMES *out, prs_struct *ps, int depth)
1149 {
1150         unsigned int i;
1151
1152         prs_debug(ps, depth, desc, "lsa_io_r_lookup_names");
1153         depth++;
1154
1155         if(!prs_align(ps))
1156                 return False;
1157
1158         if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref))
1159                 return False;
1160
1161         if (out->ptr_dom_ref != 0)
1162                 if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth))
1163                         return False;
1164
1165         if(!prs_uint32("num_entries", ps, depth, &out->num_entries))
1166                 return False;
1167         if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries))
1168                 return False;
1169
1170         if (out->ptr_entries != 0) {
1171                 if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2))
1172                         return False;
1173
1174                 if (out->num_entries2 != out->num_entries) {
1175                         /* RPC fault */
1176                         return False;
1177                 }
1178
1179                 if (UNMARSHALLING(ps) && out->num_entries2) {
1180                         if ((out->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID, out->num_entries2))
1181                             == NULL) {
1182                                 DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n"));
1183                                 return False;
1184                         }
1185                 }
1186
1187                 for (i = 0; i < out->num_entries2; i++)
1188                         if(!smb_io_dom_rid("", &out->dom_rid[i], ps, depth)) /* domain RIDs being looked up */
1189                                 return False;
1190         }
1191
1192         if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count))
1193                 return False;
1194
1195         if(!prs_ntstatus("status      ", ps, depth, &out->status))
1196                 return False;
1197
1198         return True;
1199 }
1200
1201 /*******************************************************************
1202 reads or writes a structure.
1203 ********************************************************************/
1204
1205 bool lsa_io_q_lookup_names2(const char *desc, LSA_Q_LOOKUP_NAMES2 *q_r, 
1206                            prs_struct *ps, int depth)
1207 {
1208         unsigned int i;
1209
1210         prs_debug(ps, depth, desc, "lsa_io_q_lookup_names2");
1211         depth++;
1212
1213         if(!prs_align(ps))
1214                 return False;
1215
1216         if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */
1217                 return False;
1218
1219         if(!prs_align(ps))
1220                 return False;
1221         if(!prs_uint32("num_entries    ", ps, depth, &q_r->num_entries))
1222                 return False;
1223         if(!prs_uint32("num_entries2   ", ps, depth, &q_r->num_entries2))
1224                 return False;
1225
1226         if (UNMARSHALLING(ps)) {
1227                 if (q_r->num_entries) {
1228                         if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)
1229                                 return False;
1230                         if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)
1231                                 return False;
1232                 }
1233         }
1234
1235         for (i = 0; i < q_r->num_entries; i++) {
1236                 if(!prs_align(ps))
1237                         return False;
1238                 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1239                         return False;
1240         }
1241
1242         for (i = 0; i < q_r->num_entries; i++) {
1243                 if(!prs_align(ps))
1244                         return False;
1245                 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1246                         return False;
1247         }
1248
1249         if(!prs_align(ps))
1250                 return False;
1251         if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1252                 return False;
1253         if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1254                 return False;
1255         if(!prs_uint16("lookup_level   ", ps, depth, &q_r->lookup_level))
1256                 return False;
1257         if(!prs_align(ps))
1258                 return False;
1259         if(!prs_uint32("mapped_count   ", ps, depth, &q_r->mapped_count))
1260                 return False;
1261         if(!prs_uint32("unknown1   ", ps, depth, &q_r->unknown1))
1262                 return False;
1263         if(!prs_uint32("unknown2   ", ps, depth, &q_r->unknown2))
1264                 return False;
1265
1266         return True;
1267 }
1268
1269 /*******************************************************************
1270 reads or writes a structure.
1271 ********************************************************************/
1272
1273 bool lsa_io_r_lookup_names2(const char *desc, LSA_R_LOOKUP_NAMES2 *out, prs_struct *ps, int depth)
1274 {
1275         unsigned int i;
1276
1277         prs_debug(ps, depth, desc, "lsa_io_r_lookup_names2");
1278         depth++;
1279
1280         if(!prs_align(ps))
1281                 return False;
1282
1283         if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref))
1284                 return False;
1285
1286         if (out->ptr_dom_ref != 0)
1287                 if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth))
1288                         return False;
1289
1290         if(!prs_uint32("num_entries", ps, depth, &out->num_entries))
1291                 return False;
1292         if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries))
1293                 return False;
1294
1295         if (out->ptr_entries != 0) {
1296                 if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2))
1297                         return False;
1298
1299                 if (out->num_entries2 != out->num_entries) {
1300                         /* RPC fault */
1301                         return False;
1302                 }
1303
1304                 if (UNMARSHALLING(ps) && out->num_entries2) {
1305                         if ((out->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID2, out->num_entries2))
1306                             == NULL) {
1307                                 DEBUG(3, ("lsa_io_r_lookup_names2(): out of memory\n"));
1308                                 return False;
1309                         }
1310                 }
1311
1312                 for (i = 0; i < out->num_entries2; i++)
1313                         if(!smb_io_dom_rid2("", &out->dom_rid[i], ps, depth)) /* domain RIDs being looked up */
1314                                 return False;
1315         }
1316
1317         if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count))
1318                 return False;
1319
1320         if(!prs_ntstatus("status      ", ps, depth, &out->status))
1321                 return False;
1322
1323         return True;
1324 }
1325
1326 /*******************************************************************
1327  Internal lsa data type io.
1328  Following pass must read DOM_SID2 types.
1329 ********************************************************************/
1330
1331 bool smb_io_lsa_translated_sids3(const char *desc, LSA_TRANSLATED_SID3 *q_r, 
1332                            prs_struct *ps, int depth)
1333 {
1334         prs_debug(ps, depth, desc, "smb_io_lsa_translated_sids3");
1335         depth++;
1336
1337         if(!prs_align(ps))
1338                 return False;
1339         if(!prs_uint8 ("sid_type ", ps, depth, &q_r->sid_type ))
1340                 return False;
1341         if(!prs_align(ps))
1342                 return False;
1343         /* Second pass will read/write these. */
1344         if (!smb_io_dom_sid2_p("sid_header", ps, depth, &q_r->sid2))
1345                 return False;
1346         if(!prs_uint32("sid_idx ", ps, depth, &q_r->sid_idx ))
1347                 return False;
1348         if(!prs_uint32("unknown ", ps, depth, &q_r->unknown ))
1349                 return False;
1350         
1351         return True;
1352 }
1353
1354 /*******************************************************************
1355  Identical to lsa_io_q_lookup_names2.
1356 ********************************************************************/
1357
1358 bool lsa_io_q_lookup_names3(const char *desc, LSA_Q_LOOKUP_NAMES3 *q_r, 
1359                            prs_struct *ps, int depth)
1360 {
1361         unsigned int i;
1362
1363         prs_debug(ps, depth, desc, "lsa_io_q_lookup_names3");
1364         depth++;
1365
1366         if(!prs_align(ps))
1367                 return False;
1368
1369         if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */
1370                 return False;
1371
1372         if(!prs_align(ps))
1373                 return False;
1374         if(!prs_uint32("num_entries    ", ps, depth, &q_r->num_entries))
1375                 return False;
1376         if(!prs_uint32("num_entries2   ", ps, depth, &q_r->num_entries2))
1377                 return False;
1378
1379         if (UNMARSHALLING(ps)) {
1380                 if (q_r->num_entries) {
1381                         if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)
1382                                 return False;
1383                         if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)
1384                                 return False;
1385                 }
1386         }
1387
1388         for (i = 0; i < q_r->num_entries; i++) {
1389                 if(!prs_align(ps))
1390                         return False;
1391                 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1392                         return False;
1393         }
1394
1395         for (i = 0; i < q_r->num_entries; i++) {
1396                 if(!prs_align(ps))
1397                         return False;
1398                 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1399                         return False;
1400         }
1401
1402         if(!prs_align(ps))
1403                 return False;
1404         if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1405                 return False;
1406         if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1407                 return False;
1408         if(!prs_uint16("lookup_level   ", ps, depth, &q_r->lookup_level))
1409                 return False;
1410         if(!prs_align(ps))
1411                 return False;
1412         if(!prs_uint32("mapped_count   ", ps, depth, &q_r->mapped_count))
1413                 return False;
1414         if(!prs_uint32("unknown1   ", ps, depth, &q_r->unknown1))
1415                 return False;
1416         if(!prs_uint32("unknown2   ", ps, depth, &q_r->unknown2))
1417                 return False;
1418
1419         return True;
1420 }
1421
1422 /*******************************************************************
1423 reads or writes a structure.
1424 ********************************************************************/
1425
1426 bool lsa_io_r_lookup_names3(const char *desc, LSA_R_LOOKUP_NAMES3 *out, prs_struct *ps, int depth)
1427 {
1428         unsigned int i;
1429
1430         prs_debug(ps, depth, desc, "lsa_io_r_lookup_names3");
1431         depth++;
1432
1433         if(!prs_align(ps))
1434                 return False;
1435
1436         if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref))
1437                 return False;
1438
1439         if (out->ptr_dom_ref != 0)
1440                 if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth))
1441                         return False;
1442
1443         if(!prs_uint32("num_entries", ps, depth, &out->num_entries))
1444                 return False;
1445         if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries))
1446                 return False;
1447
1448         if (out->ptr_entries != 0) {
1449                 if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2))
1450                         return False;
1451
1452                 if (out->num_entries2 != out->num_entries) {
1453                         /* RPC fault */
1454                         return False;
1455                 }
1456
1457                 if (UNMARSHALLING(ps) && out->num_entries2) {
1458                         if ((out->trans_sids = PRS_ALLOC_MEM(ps, LSA_TRANSLATED_SID3, out->num_entries2))
1459                             == NULL) {
1460                                 DEBUG(3, ("lsa_io_r_lookup_names3(): out of memory\n"));
1461                                 return False;
1462                         }
1463                 }
1464
1465                 for (i = 0; i < out->num_entries2; i++) {
1466                         if(!smb_io_lsa_translated_sids3("", &out->trans_sids[i], ps, depth)) {
1467                                 return False;
1468                         }
1469                 }
1470                 /* Now process the DOM_SID2 entries. */
1471                 for (i = 0; i < out->num_entries2; i++) {
1472                         if (out->trans_sids[i].sid2) {
1473                                 if( !smb_io_dom_sid2("sid2", out->trans_sids[i].sid2, ps, depth) ) {
1474                                         return False;
1475                                 }
1476                         }
1477                 }
1478         }
1479
1480         if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count))
1481                 return False;
1482
1483         if(!prs_ntstatus("status      ", ps, depth, &out->status))
1484                 return False;
1485
1486         return True;
1487 }
1488
1489 /*******************************************************************
1490 ********************************************************************/
1491
1492 bool lsa_io_q_lookup_names4(const char *desc, LSA_Q_LOOKUP_NAMES4 *q_r, 
1493                            prs_struct *ps, int depth)
1494 {
1495         unsigned int i;
1496
1497         prs_debug(ps, depth, desc, "lsa_io_q_lookup_names4");
1498         depth++;
1499
1500         if(!prs_align(ps))
1501                 return False;
1502
1503         if(!prs_uint32("num_entries    ", ps, depth, &q_r->num_entries))
1504                 return False;
1505         if(!prs_uint32("num_entries2   ", ps, depth, &q_r->num_entries2))
1506                 return False;
1507
1508         if (UNMARSHALLING(ps)) {
1509                 if (q_r->num_entries) {
1510                         if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)
1511                                 return False;
1512                         if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)
1513                                 return False;
1514                 }
1515         }
1516
1517         for (i = 0; i < q_r->num_entries; i++) {
1518                 if(!prs_align(ps))
1519                         return False;
1520                 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1521                         return False;
1522         }
1523
1524         for (i = 0; i < q_r->num_entries; i++) {
1525                 if(!prs_align(ps))
1526                         return False;
1527                 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1528                         return False;
1529         }
1530
1531         if(!prs_align(ps))
1532                 return False;
1533         if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1534                 return False;
1535         if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1536                 return False;
1537         if(!prs_uint16("lookup_level   ", ps, depth, &q_r->lookup_level))
1538                 return False;
1539         if(!prs_align(ps))
1540                 return False;
1541         if(!prs_uint32("mapped_count   ", ps, depth, &q_r->mapped_count))
1542                 return False;
1543         if(!prs_uint32("unknown1   ", ps, depth, &q_r->unknown1))
1544                 return False;
1545         if(!prs_uint32("unknown2   ", ps, depth, &q_r->unknown2))
1546                 return False;
1547
1548         return True;
1549 }
1550
1551 /*******************************************************************
1552  Identical to lsa_io_r_lookup_names3.
1553 ********************************************************************/
1554
1555 bool lsa_io_r_lookup_names4(const char *desc, LSA_R_LOOKUP_NAMES4 *out, prs_struct *ps, int depth)
1556 {
1557         unsigned int i;
1558
1559         prs_debug(ps, depth, desc, "lsa_io_r_lookup_names4");
1560         depth++;
1561
1562         if(!prs_align(ps))
1563                 return False;
1564
1565         if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref))
1566                 return False;
1567
1568         if (out->ptr_dom_ref != 0)
1569                 if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth))
1570                         return False;
1571
1572         if(!prs_uint32("num_entries", ps, depth, &out->num_entries))
1573                 return False;
1574         if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries))
1575                 return False;
1576
1577         if (out->ptr_entries != 0) {
1578                 if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2))
1579                         return False;
1580
1581                 if (out->num_entries2 != out->num_entries) {
1582                         /* RPC fault */
1583                         return False;
1584                 }
1585
1586                 if (UNMARSHALLING(ps) && out->num_entries2) {
1587                         if ((out->trans_sids = PRS_ALLOC_MEM(ps, LSA_TRANSLATED_SID3, out->num_entries2))
1588                             == NULL) {
1589                                 DEBUG(3, ("lsa_io_r_lookup_names4(): out of memory\n"));
1590                                 return False;
1591                         }
1592                 }
1593
1594                 for (i = 0; i < out->num_entries2; i++) {
1595                         if(!smb_io_lsa_translated_sids3("", &out->trans_sids[i], ps, depth)) {
1596                                 return False;
1597                         }
1598                 }
1599                 /* Now process the DOM_SID2 entries. */
1600                 for (i = 0; i < out->num_entries2; i++) {
1601                         if (out->trans_sids[i].sid2) {
1602                                 if( !smb_io_dom_sid2("sid2", out->trans_sids[i].sid2, ps, depth) ) {
1603                                         return False;
1604                                 }
1605                         }
1606                 }
1607         }
1608
1609         if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count))
1610                 return False;
1611
1612         if(!prs_ntstatus("status      ", ps, depth, &out->status))
1613                 return False;
1614
1615         return True;
1616 }
1617
1618 /*******************************************************************
1619  Inits an LSA_Q_ENUM_PRIVS structure.
1620 ********************************************************************/
1621
1622 void init_q_enum_privs(LSA_Q_ENUM_PRIVS *in, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1623 {
1624         DEBUG(5, ("init_q_enum_privs\n"));
1625
1626         memcpy(&in->pol, hnd, sizeof(in->pol));
1627
1628         in->enum_context = enum_context;
1629         in->pref_max_length = pref_max_length;
1630 }
1631
1632 /*******************************************************************
1633 reads or writes a structure.
1634 ********************************************************************/
1635 bool lsa_io_q_enum_privs(const char *desc, LSA_Q_ENUM_PRIVS *in, prs_struct *ps, int depth)
1636 {
1637         if (in == NULL)
1638                 return False;
1639
1640         prs_debug(ps, depth, desc, "lsa_io_q_enum_privs");
1641         depth++;
1642
1643         if (!smb_io_pol_hnd("", &in->pol, ps, depth))
1644                 return False;
1645
1646         if(!prs_uint32("enum_context   ", ps, depth, &in->enum_context))
1647                 return False;
1648         if(!prs_uint32("pref_max_length", ps, depth, &in->pref_max_length))
1649                 return False;
1650
1651         return True;
1652 }
1653
1654 /*******************************************************************
1655 reads or writes a structure.
1656 ********************************************************************/
1657 static bool lsa_io_priv_entries(const char *desc, LSA_PRIV_ENTRY *entries, uint32 count, prs_struct *ps, int depth)
1658 {
1659         uint32 i;
1660
1661         if (entries == NULL)
1662                 return False;
1663
1664         prs_debug(ps, depth, desc, "lsa_io_priv_entries");
1665         depth++;
1666
1667         if(!prs_align(ps))
1668                 return False;
1669
1670         for (i = 0; i < count; i++) {
1671                 if (!smb_io_unihdr("", &entries[i].hdr_name, ps, depth))
1672                         return False;
1673                 if(!prs_uint32("luid_low ", ps, depth, &entries[i].luid_low))
1674                         return False;
1675                 if(!prs_uint32("luid_high", ps, depth, &entries[i].luid_high))
1676                         return False;
1677         }
1678
1679         for (i = 0; i < count; i++)
1680                 if (!smb_io_unistr2("", &entries[i].name, entries[i].hdr_name.buffer, ps, depth))
1681                         return False;
1682
1683         return True;
1684 }
1685
1686 /*******************************************************************
1687  Inits an LSA_R_ENUM_PRIVS structure.
1688 ********************************************************************/
1689
1690 void init_lsa_r_enum_privs(LSA_R_ENUM_PRIVS *out, uint32 enum_context,
1691                           uint32 count, LSA_PRIV_ENTRY *entries)
1692 {
1693         DEBUG(5, ("init_lsa_r_enum_privs\n"));
1694
1695         out->enum_context=enum_context;
1696         out->count=count;
1697         
1698         if (entries!=NULL) {
1699                 out->ptr=1;
1700                 out->count1=count;
1701                 out->privs=entries;
1702         } else {
1703                 out->ptr=0;
1704                 out->count1=0;
1705                 out->privs=NULL;
1706         }               
1707 }
1708
1709 /*******************************************************************
1710 reads or writes a structure.
1711 ********************************************************************/
1712 bool lsa_io_r_enum_privs(const char *desc, LSA_R_ENUM_PRIVS *out, prs_struct *ps, int depth)
1713 {
1714         if (out == NULL)
1715                 return False;
1716
1717         prs_debug(ps, depth, desc, "lsa_io_r_enum_privs");
1718         depth++;
1719
1720         if(!prs_align(ps))
1721                 return False;
1722
1723         if(!prs_uint32("enum_context", ps, depth, &out->enum_context))
1724                 return False;
1725         if(!prs_uint32("count", ps, depth, &out->count))
1726                 return False;
1727         if(!prs_uint32("ptr", ps, depth, &out->ptr))
1728                 return False;
1729
1730         if (out->ptr) {
1731                 if(!prs_uint32("count1", ps, depth, &out->count1))
1732                         return False;
1733
1734                 if (UNMARSHALLING(ps) && out->count1)
1735                         if (!(out->privs = PRS_ALLOC_MEM(ps, LSA_PRIV_ENTRY, out->count1)))
1736                                 return False;
1737
1738                 if (!lsa_io_priv_entries("", out->privs, out->count1, ps, depth))
1739                         return False;
1740         }
1741
1742         if(!prs_align(ps))
1743                 return False;
1744
1745         if(!prs_ntstatus("status", ps, depth, &out->status))
1746                 return False;
1747
1748         return True;
1749 }
1750
1751 void init_lsa_priv_get_dispname(LSA_Q_PRIV_GET_DISPNAME *trn, POLICY_HND *hnd, const char *name, uint16 lang_id, uint16 lang_id_sys)
1752 {
1753         memcpy(&trn->pol, hnd, sizeof(trn->pol));
1754
1755         init_unistr2(&trn->name, name, UNI_FLAGS_NONE);
1756         init_uni_hdr(&trn->hdr_name, &trn->name);
1757         trn->lang_id = lang_id;
1758         trn->lang_id_sys = lang_id_sys;
1759 }
1760
1761 /*******************************************************************
1762 reads or writes a structure.
1763 ********************************************************************/
1764 bool lsa_io_q_priv_get_dispname(const char *desc, LSA_Q_PRIV_GET_DISPNAME *in, prs_struct *ps, int depth)
1765 {
1766         if (in == NULL)
1767                 return False;
1768
1769         prs_debug(ps, depth, desc, "lsa_io_q_priv_get_dispname");
1770         depth++;
1771
1772         if(!prs_align(ps))
1773                 return False;
1774
1775         if (!smb_io_pol_hnd("", &in->pol, ps, depth))
1776                 return False;
1777
1778         if (!smb_io_unihdr("hdr_name", &in->hdr_name, ps, depth))
1779                 return False;
1780
1781         if (!smb_io_unistr2("name", &in->name, in->hdr_name.buffer, ps, depth))
1782                 return False;
1783
1784         if(!prs_uint16("lang_id    ", ps, depth, &in->lang_id))
1785                 return False;
1786         if(!prs_uint16("lang_id_sys", ps, depth, &in->lang_id_sys))
1787                 return False;
1788
1789         return True;
1790 }
1791
1792 /*******************************************************************
1793 reads or writes a structure.
1794 ********************************************************************/
1795 bool lsa_io_r_priv_get_dispname(const char *desc, LSA_R_PRIV_GET_DISPNAME *out, prs_struct *ps, int depth)
1796 {
1797         if (out == NULL)
1798                 return False;
1799
1800         prs_debug(ps, depth, desc, "lsa_io_r_priv_get_dispname");
1801         depth++;
1802
1803         if (!prs_align(ps))
1804                 return False;
1805
1806         if (!prs_uint32("ptr_info", ps, depth, &out->ptr_info))
1807                 return False;
1808
1809         if (out->ptr_info){
1810                 if (!smb_io_unihdr("hdr_name", &out->hdr_desc, ps, depth))
1811                         return False;
1812
1813                 if (!smb_io_unistr2("desc", &out->desc, out->hdr_desc.buffer, ps, depth))
1814                         return False;
1815         }
1816 /*
1817         if(!prs_align(ps))
1818                 return False;
1819 */
1820         if(!prs_uint16("lang_id", ps, depth, &out->lang_id))
1821                 return False;
1822
1823         if(!prs_align(ps))
1824                 return False;
1825         if(!prs_ntstatus("status", ps, depth, &out->status))
1826                 return False;
1827
1828         return True;
1829 }
1830
1831 /*
1832   initialise a LSA_Q_ENUM_ACCOUNTS structure
1833 */
1834 void init_lsa_q_enum_accounts(LSA_Q_ENUM_ACCOUNTS *trn, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1835 {
1836         memcpy(&trn->pol, hnd, sizeof(trn->pol));
1837
1838         trn->enum_context = enum_context;
1839         trn->pref_max_length = pref_max_length;
1840 }
1841
1842 /*******************************************************************
1843 reads or writes a structure.
1844 ********************************************************************/
1845 bool lsa_io_q_enum_accounts(const char *desc, LSA_Q_ENUM_ACCOUNTS *in, prs_struct *ps, int depth)
1846 {
1847         if (in == NULL)
1848                 return False;
1849
1850         prs_debug(ps, depth, desc, "lsa_io_q_enum_accounts");
1851         depth++;
1852
1853         if (!smb_io_pol_hnd("", &in->pol, ps, depth))
1854                 return False;
1855
1856         if(!prs_uint32("enum_context   ", ps, depth, &in->enum_context))
1857                 return False;
1858         if(!prs_uint32("pref_max_length", ps, depth, &in->pref_max_length))
1859                 return False;
1860
1861         return True;
1862 }
1863
1864
1865 /*******************************************************************
1866  Inits an LSA_R_ENUM_PRIVS structure.
1867 ********************************************************************/
1868
1869 void init_lsa_r_enum_accounts(LSA_R_ENUM_ACCOUNTS *out, uint32 enum_context)
1870 {
1871         DEBUG(5, ("init_lsa_r_enum_accounts\n"));
1872
1873         out->enum_context=enum_context;
1874         if (out->enum_context!=0) {
1875                 out->sids.num_entries=enum_context;
1876                 out->sids.ptr_sid_enum=1;
1877                 out->sids.num_entries2=enum_context;
1878         } else {
1879                 out->sids.num_entries=0;
1880                 out->sids.ptr_sid_enum=0;
1881                 out->sids.num_entries2=0;
1882         }
1883 }
1884
1885 /*******************************************************************
1886 reads or writes a structure.
1887 ********************************************************************/
1888 bool lsa_io_r_enum_accounts(const char *desc, LSA_R_ENUM_ACCOUNTS *out, prs_struct *ps, int depth)
1889 {
1890         if (out == NULL)
1891                 return False;
1892
1893         prs_debug(ps, depth, desc, "lsa_io_r_enum_accounts");
1894         depth++;
1895
1896         if (!prs_align(ps))
1897                 return False;
1898
1899         if(!prs_uint32("enum_context", ps, depth, &out->enum_context))
1900                 return False;
1901
1902         if (!lsa_io_sid_enum("sids", &out->sids, ps, depth))
1903                 return False;
1904
1905         if (!prs_align(ps))
1906                 return False;
1907
1908         if(!prs_ntstatus("status", ps, depth, &out->status))
1909                 return False;
1910
1911         return True;
1912 }
1913
1914
1915 /*******************************************************************
1916  Reads or writes an LSA_Q_UNK_GET_CONNUSER structure.
1917 ********************************************************************/
1918
1919 bool lsa_io_q_unk_get_connuser(const char *desc, LSA_Q_UNK_GET_CONNUSER *in, prs_struct *ps, int depth)
1920 {
1921         prs_debug(ps, depth, desc, "lsa_io_q_unk_get_connuser");
1922         depth++;
1923
1924         if(!prs_align(ps))
1925                 return False;
1926    
1927         if(!prs_uint32("ptr_srvname", ps, depth, &in->ptr_srvname))
1928                 return False;
1929
1930         if(!smb_io_unistr2("uni2_srvname", &in->uni2_srvname, in->ptr_srvname, ps, depth)) /* server name to be looked up */
1931                 return False;
1932
1933         if (!prs_align(ps))
1934           return False;
1935
1936         if(!prs_uint32("unk1", ps, depth, &in->unk1))
1937                 return False;
1938         if(!prs_uint32("unk2", ps, depth, &in->unk2))
1939                 return False;
1940         if(!prs_uint32("unk3", ps, depth, &in->unk3))
1941                 return False;
1942
1943         /* Don't bother to read or write at present... */
1944         return True;
1945 }
1946
1947 /*******************************************************************
1948  Reads or writes an LSA_R_UNK_GET_CONNUSER structure.
1949 ********************************************************************/
1950
1951 bool lsa_io_r_unk_get_connuser(const char *desc, LSA_R_UNK_GET_CONNUSER *out, prs_struct *ps, int depth)
1952 {
1953         prs_debug(ps, depth, desc, "lsa_io_r_unk_get_connuser");
1954         depth++;
1955
1956         if(!prs_align(ps))
1957                 return False;
1958    
1959         if(!prs_uint32("ptr_user_name", ps, depth, &out->ptr_user_name))
1960                 return False;
1961         if(!smb_io_unihdr("hdr_user_name", &out->hdr_user_name, ps, depth))
1962                 return False;
1963         if(!smb_io_unistr2("uni2_user_name", &out->uni2_user_name, out->ptr_user_name, ps, depth))
1964                 return False;
1965
1966         if (!prs_align(ps))
1967           return False;
1968         
1969         if(!prs_uint32("unk1", ps, depth, &out->unk1))
1970                 return False;
1971
1972         if(!prs_uint32("ptr_dom_name", ps, depth, &out->ptr_dom_name))
1973                 return False;
1974         if(!smb_io_unihdr("hdr_dom_name", &out->hdr_dom_name, ps, depth))
1975                 return False;
1976         if(!smb_io_unistr2("uni2_dom_name", &out->uni2_dom_name, out->ptr_dom_name, ps, depth))
1977                 return False;
1978
1979         if (!prs_align(ps))
1980           return False;
1981         
1982         if(!prs_ntstatus("status", ps, depth, &out->status))
1983                 return False;
1984
1985         return True;
1986 }
1987
1988 void init_lsa_q_open_account(LSA_Q_OPENACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1989 {
1990         memcpy(&trn->pol, hnd, sizeof(trn->pol));
1991
1992         init_dom_sid2(&trn->sid, sid);
1993         trn->access = desired_access;
1994 }
1995
1996 /*******************************************************************
1997  Reads or writes an LSA_Q_OPENACCOUNT structure.
1998 ********************************************************************/
1999
2000 bool lsa_io_q_open_account(const char *desc, LSA_Q_OPENACCOUNT *out, prs_struct *ps, int depth)
2001 {
2002         prs_debug(ps, depth, desc, "lsa_io_q_open_account");
2003         depth++;
2004
2005         if(!prs_align(ps))
2006                 return False;
2007  
2008         if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2009                 return False;
2010
2011         if(!smb_io_dom_sid2("sid", &out->sid, ps, depth)) /* domain SID */
2012                 return False;
2013
2014         if(!prs_uint32("access", ps, depth, &out->access))
2015                 return False;
2016   
2017         return True;
2018 }
2019
2020 /*******************************************************************
2021  Reads or writes an LSA_R_OPENACCOUNT structure.
2022 ********************************************************************/
2023
2024 bool lsa_io_r_open_account(const char *desc, LSA_R_OPENACCOUNT  *out, prs_struct *ps, int depth)
2025 {
2026         prs_debug(ps, depth, desc, "lsa_io_r_open_account");
2027         depth++;
2028
2029         if(!prs_align(ps))
2030                 return False;
2031  
2032         if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2033                 return False;
2034
2035         if(!prs_ntstatus("status", ps, depth, &out->status))
2036                 return False;
2037
2038         return True;
2039 }
2040
2041
2042 void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd)
2043 {
2044         memcpy(&trn->pol, hnd, sizeof(trn->pol));
2045
2046 }
2047
2048 /*******************************************************************
2049  Reads or writes an LSA_Q_ENUMPRIVSACCOUNT structure.
2050 ********************************************************************/
2051
2052 bool lsa_io_q_enum_privsaccount(const char *desc, LSA_Q_ENUMPRIVSACCOUNT *out, prs_struct *ps, int depth)
2053 {
2054         prs_debug(ps, depth, desc, "lsa_io_q_enum_privsaccount");
2055         depth++;
2056
2057         if(!prs_align(ps))
2058                 return False;
2059  
2060         if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2061                 return False;
2062
2063         return True;
2064 }
2065
2066 /*******************************************************************
2067  Reads or writes an LUID structure.
2068 ********************************************************************/
2069
2070 static bool lsa_io_luid(const char *desc, LUID *out, prs_struct *ps, int depth)
2071 {
2072         prs_debug(ps, depth, desc, "lsa_io_luid");
2073         depth++;
2074
2075         if(!prs_align(ps))
2076                 return False;
2077  
2078         if(!prs_uint32("low", ps, depth, &out->low))
2079                 return False;
2080
2081         if(!prs_uint32("high", ps, depth, &out->high))
2082                 return False;
2083
2084         return True;
2085 }
2086
2087 /*******************************************************************
2088  Reads or writes an LUID_ATTR structure.
2089 ********************************************************************/
2090
2091 static bool lsa_io_luid_attr(const char *desc, LUID_ATTR *out, prs_struct *ps, int depth)
2092 {
2093         prs_debug(ps, depth, desc, "lsa_io_luid_attr");
2094         depth++;
2095
2096         if(!prs_align(ps))
2097                 return False;
2098  
2099         if (!lsa_io_luid(desc, &out->luid, ps, depth))
2100                 return False;
2101
2102         if(!prs_uint32("attr", ps, depth, &out->attr))
2103                 return False;
2104
2105         return True;
2106 }
2107
2108 /*******************************************************************
2109  Reads or writes an PRIVILEGE_SET structure.
2110 ********************************************************************/
2111
2112 static bool lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *out, prs_struct *ps, int depth)
2113 {
2114         uint32 i, dummy;
2115
2116         prs_debug(ps, depth, desc, "lsa_io_privilege_set");
2117         depth++;
2118
2119         if(!prs_align(ps))
2120                 return False;
2121  
2122         if(!prs_uint32("count", ps, depth, &dummy))
2123                 return False;
2124         if(!prs_uint32("control", ps, depth, &out->control))
2125                 return False;
2126
2127         for (i=0; i<out->count; i++) {
2128                 if (!lsa_io_luid_attr(desc, &out->set[i], ps, depth))
2129                         return False;
2130         }
2131         
2132         return True;
2133 }
2134
2135 NTSTATUS init_lsa_r_enum_privsaccount(TALLOC_CTX *mem_ctx, LSA_R_ENUMPRIVSACCOUNT *out, LUID_ATTR *set, uint32 count, uint32 control)
2136 {
2137         NTSTATUS ret = NT_STATUS_OK;
2138
2139         out->ptr = 1;
2140         out->count = count;
2141
2142         if ( !NT_STATUS_IS_OK(ret = privilege_set_init_by_ctx(mem_ctx, &(out->set))) )
2143                 return ret;
2144         
2145         out->set.count = count;
2146         
2147         if (!NT_STATUS_IS_OK(ret = dup_luid_attr(out->set.mem_ctx, &(out->set.set), set, count)))
2148                 return ret;
2149
2150         DEBUG(10,("init_lsa_r_enum_privsaccount: %d privileges\n", out->count));
2151
2152         return ret;
2153 }
2154
2155 /*******************************************************************
2156  Reads or writes an LSA_R_ENUMPRIVSACCOUNT structure.
2157 ********************************************************************/
2158
2159 bool lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *out, prs_struct *ps, int depth)
2160 {
2161         prs_debug(ps, depth, desc, "lsa_io_r_enum_privsaccount");
2162         depth++;
2163
2164         if(!prs_align(ps))
2165                 return False;
2166  
2167         if(!prs_uint32("ptr", ps, depth, &out->ptr))
2168                 return False;
2169
2170         if (out->ptr!=0) {
2171                 if(!prs_uint32("count", ps, depth, &out->count))
2172                         return False;
2173
2174                 /* malloc memory if unmarshalling here */
2175
2176                 if (UNMARSHALLING(ps) && out->count != 0) {
2177                         if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))
2178                                 return False;
2179
2180                         if (!(out->set.set = PRS_ALLOC_MEM(ps,LUID_ATTR,out->count)))
2181                                 return False;
2182
2183                 }
2184                 
2185                 if(!lsa_io_privilege_set(desc, &out->set, ps, depth))
2186                         return False;
2187         }
2188
2189         if(!prs_ntstatus("status", ps, depth, &out->status))
2190                 return False;
2191
2192         return True;
2193 }
2194
2195
2196
2197 /*******************************************************************
2198  Reads or writes an  LSA_Q_GETSYSTEMACCOUNTstructure.
2199 ********************************************************************/
2200
2201 bool lsa_io_q_getsystemaccount(const char *desc, LSA_Q_GETSYSTEMACCOUNT  *out, prs_struct *ps, int depth)
2202 {
2203         prs_debug(ps, depth, desc, "lsa_io_q_getsystemaccount");
2204         depth++;
2205
2206         if(!prs_align(ps))
2207                 return False;
2208  
2209         if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2210                 return False;
2211
2212         return True;
2213 }
2214
2215 /*******************************************************************
2216  Reads or writes an  LSA_R_GETSYSTEMACCOUNTstructure.
2217 ********************************************************************/
2218
2219 bool lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT  *out, prs_struct *ps, int depth)
2220 {
2221         prs_debug(ps, depth, desc, "lsa_io_r_getsystemaccount");
2222         depth++;
2223
2224         if(!prs_align(ps))
2225                 return False;
2226  
2227         if(!prs_uint32("access", ps, depth, &out->access))
2228                 return False;
2229
2230         if(!prs_ntstatus("status", ps, depth, &out->status))
2231                 return False;
2232
2233         return True;
2234 }
2235
2236
2237 /*******************************************************************
2238  Reads or writes an LSA_Q_SETSYSTEMACCOUNT structure.
2239 ********************************************************************/
2240
2241 bool lsa_io_q_setsystemaccount(const char *desc, LSA_Q_SETSYSTEMACCOUNT  *out, prs_struct *ps, int depth)
2242 {
2243         prs_debug(ps, depth, desc, "lsa_io_q_setsystemaccount");
2244         depth++;
2245
2246         if(!prs_align(ps))
2247                 return False;
2248  
2249         if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2250                 return False;
2251
2252         if(!prs_uint32("access", ps, depth, &out->access))
2253                 return False;
2254
2255         return True;
2256 }
2257
2258 /*******************************************************************
2259  Reads or writes an LSA_R_SETSYSTEMACCOUNT structure.
2260 ********************************************************************/
2261
2262 bool lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT  *out, prs_struct *ps, int depth)
2263 {
2264         prs_debug(ps, depth, desc, "lsa_io_r_setsystemaccount");
2265         depth++;
2266
2267         if(!prs_align(ps))
2268                 return False;
2269  
2270         if(!prs_ntstatus("status", ps, depth, &out->status))
2271                 return False;
2272
2273         return True;
2274 }
2275
2276
2277 void init_lsa_string( LSA_STRING *uni, const char *string )
2278 {
2279         init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE);
2280         init_uni_hdr(&uni->hdr, &uni->unistring);
2281 }
2282
2283 void init_lsa_q_lookup_priv_value(LSA_Q_LOOKUP_PRIV_VALUE *q_u, POLICY_HND *hnd, const char *name)
2284 {
2285         memcpy(&q_u->pol, hnd, sizeof(q_u->pol));
2286         init_lsa_string( &q_u->privname, name );
2287 }
2288
2289 bool smb_io_lsa_string( const char *desc, LSA_STRING *string, prs_struct *ps, int depth )
2290 {
2291         prs_debug(ps, depth, desc, "smb_io_lsa_string");
2292         depth++;
2293
2294         if(!smb_io_unihdr ("hdr", &string->hdr, ps, depth))
2295                 return False;
2296         if(!smb_io_unistr2("unistring", &string->unistring, string->hdr.buffer, ps, depth))
2297                 return False;
2298         
2299         return True;
2300 }
2301
2302 /*******************************************************************
2303  Reads or writes an LSA_Q_LOOKUP_PRIV_VALUE  structure.
2304 ********************************************************************/
2305
2306 bool lsa_io_q_lookup_priv_value(const char *desc, LSA_Q_LOOKUP_PRIV_VALUE  *out, prs_struct *ps, int depth)
2307 {
2308         prs_debug(ps, depth, desc, "lsa_io_q_lookup_priv_value");
2309         depth++;
2310
2311         if(!prs_align(ps))
2312                 return False;
2313  
2314         if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2315                 return False;
2316         if(!smb_io_lsa_string("privname", &out->privname, ps, depth))
2317                 return False;
2318
2319         return True;
2320 }
2321
2322 /*******************************************************************
2323  Reads or writes an  LSA_R_LOOKUP_PRIV_VALUE structure.
2324 ********************************************************************/
2325
2326 bool lsa_io_r_lookup_priv_value(const char *desc, LSA_R_LOOKUP_PRIV_VALUE  *out, prs_struct *ps, int depth)
2327 {
2328         prs_debug(ps, depth, desc, "lsa_io_r_lookup_priv_value");
2329         depth++;
2330
2331         if(!prs_align(ps))
2332                 return False;
2333                 
2334         if(!lsa_io_luid("luid", &out->luid, ps, depth))
2335                 return False;
2336  
2337         if(!prs_ntstatus("status", ps, depth, &out->status))
2338                 return False;
2339
2340         return True;
2341 }
2342
2343
2344 /*******************************************************************
2345  Reads or writes an LSA_Q_ADDPRIVS structure.
2346 ********************************************************************/
2347
2348 bool lsa_io_q_addprivs(const char *desc, LSA_Q_ADDPRIVS *out, prs_struct *ps, int depth)
2349 {
2350         prs_debug(ps, depth, desc, "lsa_io_q_addprivs");
2351         depth++;
2352
2353         if(!prs_align(ps))
2354                 return False;
2355  
2356         if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2357                 return False;
2358         
2359         if(!prs_uint32("count", ps, depth, &out->count))
2360                 return False;
2361
2362         if (UNMARSHALLING(ps) && out->count!=0) {
2363                 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))
2364                         return False;
2365                 
2366                 if (!(out->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, out->count)))
2367                         return False;
2368         }
2369         
2370         if(!lsa_io_privilege_set(desc, &out->set, ps, depth))
2371                 return False;
2372         
2373         return True;
2374 }
2375
2376 /*******************************************************************
2377  Reads or writes an LSA_R_ADDPRIVS structure.
2378 ********************************************************************/
2379
2380 bool lsa_io_r_addprivs(const char *desc, LSA_R_ADDPRIVS *out, prs_struct *ps, int depth)
2381 {
2382         prs_debug(ps, depth, desc, "lsa_io_r_addprivs");
2383         depth++;
2384
2385         if(!prs_align(ps))
2386                 return False;
2387  
2388         if(!prs_ntstatus("status", ps, depth, &out->status))
2389                 return False;
2390
2391         return True;
2392 }
2393
2394 /*******************************************************************
2395  Reads or writes an LSA_Q_REMOVEPRIVS structure.
2396 ********************************************************************/
2397
2398 bool lsa_io_q_removeprivs(const char *desc, LSA_Q_REMOVEPRIVS *out, prs_struct *ps, int depth)
2399 {
2400         prs_debug(ps, depth, desc, "lsa_io_q_removeprivs");
2401         depth++;
2402
2403         if(!prs_align(ps))
2404                 return False;
2405  
2406         if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2407                 return False;
2408         
2409         if(!prs_uint32("allrights", ps, depth, &out->allrights))
2410                 return False;
2411
2412         if(!prs_uint32("ptr", ps, depth, &out->ptr))
2413                 return False;
2414
2415         /* 
2416          * JFM: I'm not sure at all if the count is inside the ptr
2417          * never seen one with ptr=0
2418          */
2419
2420         if (out->ptr!=0) {
2421                 if(!prs_uint32("count", ps, depth, &out->count))
2422                         return False;
2423
2424                 if (UNMARSHALLING(ps) && out->count!=0) {
2425                         if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))
2426                                 return False;
2427
2428                         if (!(out->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, out->count)))
2429                                 return False;
2430                 }
2431
2432                 if(!lsa_io_privilege_set(desc, &out->set, ps, depth))
2433                         return False;
2434         }
2435
2436         return True;
2437 }
2438
2439 /*******************************************************************
2440  Reads or writes an LSA_R_REMOVEPRIVS structure.
2441 ********************************************************************/
2442
2443 bool lsa_io_r_removeprivs(const char *desc, LSA_R_REMOVEPRIVS *out, prs_struct *ps, int depth)
2444 {
2445         prs_debug(ps, depth, desc, "lsa_io_r_removeprivs");
2446         depth++;
2447
2448         if(!prs_align(ps))
2449                 return False;
2450  
2451         if(!prs_ntstatus("status", ps, depth, &out->status))
2452                 return False;
2453
2454         return True;
2455 }
2456
2457 bool policy_handle_is_valid(const POLICY_HND *hnd)
2458 {
2459         POLICY_HND zero_pol;
2460
2461         ZERO_STRUCT(zero_pol);
2462         return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True );
2463 }
2464
2465 /*******************************************************************
2466  Inits an LSA_Q_ENUM_ACCT_RIGHTS structure.
2467 ********************************************************************/
2468 void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS *in, 
2469                              POLICY_HND *hnd, 
2470                              uint32 count, 
2471                              DOM_SID *sid)
2472 {
2473         DEBUG(5, ("init_q_enum_acct_rights\n"));
2474
2475         in->pol = *hnd;
2476         init_dom_sid2(&in->sid, sid);
2477 }
2478
2479 /*******************************************************************
2480 ********************************************************************/
2481 NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *out, PRIVILEGE_SET *privileges )
2482 {
2483         uint32 i;
2484         const char *privname;
2485         const char **privname_array = NULL;
2486         int num_priv = 0;
2487
2488         for ( i=0; i<privileges->count; i++ ) {
2489                 privname = luid_to_privilege_name( &privileges->set[i].luid );
2490                 if ( privname ) {
2491                         if ( !add_string_to_array( talloc_tos(), privname, &privname_array, &num_priv ) )
2492                                 return NT_STATUS_NO_MEMORY;
2493                 }
2494         }
2495
2496         if ( num_priv ) {
2497                 out->rights = TALLOC_P( talloc_tos(), UNISTR4_ARRAY );
2498                 if (!out->rights) {
2499                         return NT_STATUS_NO_MEMORY;
2500                 }
2501
2502                 if ( !init_unistr4_array( out->rights, num_priv, privname_array ) ) 
2503                         return NT_STATUS_NO_MEMORY;
2504
2505                 out->count = num_priv;
2506         }
2507
2508         return NT_STATUS_OK;
2509 }
2510
2511 /*******************************************************************
2512 reads or writes a LSA_Q_ENUM_ACCT_RIGHTS structure.
2513 ********************************************************************/
2514 bool lsa_io_q_enum_acct_rights(const char *desc, LSA_Q_ENUM_ACCT_RIGHTS *in, prs_struct *ps, int depth)
2515 {
2516         
2517         if (in == NULL)
2518                 return False;
2519
2520         prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_rights");
2521         depth++;
2522
2523         if (!smb_io_pol_hnd("", &in->pol, ps, depth))
2524                 return False;
2525
2526         if(!smb_io_dom_sid2("sid", &in->sid, ps, depth))
2527                 return False;
2528
2529         return True;
2530 }
2531
2532
2533 /*******************************************************************
2534 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2535 ********************************************************************/
2536 bool lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *out, prs_struct *ps, int depth)
2537 {
2538         prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_rights");
2539         depth++;
2540
2541         if(!prs_uint32("count   ", ps, depth, &out->count))
2542                 return False;
2543
2544         if ( !prs_pointer("rights", ps, depth, (void*)&out->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2545                 return False;
2546
2547         if(!prs_align(ps))
2548                 return False;
2549
2550         if(!prs_ntstatus("status", ps, depth, &out->status))
2551                 return False;
2552
2553         return True;
2554 }
2555
2556
2557 /*******************************************************************
2558  Inits an LSA_Q_ADD_ACCT_RIGHTS structure.
2559 ********************************************************************/
2560 void init_q_add_acct_rights( LSA_Q_ADD_ACCT_RIGHTS *in, POLICY_HND *hnd, 
2561                              DOM_SID *sid, uint32 count, const char **rights )
2562 {
2563         DEBUG(5, ("init_q_add_acct_rights\n"));
2564
2565         in->pol = *hnd;
2566         init_dom_sid2(&in->sid, sid);
2567         
2568         in->rights = TALLOC_P( talloc_tos(), UNISTR4_ARRAY );
2569         if (!in->rights) {
2570                 smb_panic("init_q_add_acct_rights: talloc fail\n");
2571                 return;
2572         }
2573         init_unistr4_array( in->rights, count, rights );
2574         
2575         in->count = count;
2576 }
2577
2578
2579 /*******************************************************************
2580 reads or writes a LSA_Q_ADD_ACCT_RIGHTS structure.
2581 ********************************************************************/
2582 bool lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *in, prs_struct *ps, int depth)
2583 {
2584         prs_debug(ps, depth, desc, "lsa_io_q_add_acct_rights");
2585         depth++;
2586
2587         if (!smb_io_pol_hnd("", &in->pol, ps, depth))
2588                 return False;
2589
2590         if(!smb_io_dom_sid2("sid", &in->sid, ps, depth))
2591                 return False;
2592
2593         if(!prs_uint32("count", ps, depth, &in->count))
2594                 return False;
2595
2596         if ( !prs_pointer("rights", ps, depth, (void*)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2597                 return False;
2598
2599         return True;
2600 }
2601
2602 /*******************************************************************
2603 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2604 ********************************************************************/
2605 bool lsa_io_r_add_acct_rights(const char *desc, LSA_R_ADD_ACCT_RIGHTS *out, prs_struct *ps, int depth)
2606 {
2607         prs_debug(ps, depth, desc, "lsa_io_r_add_acct_rights");
2608         depth++;
2609
2610         if(!prs_ntstatus("status", ps, depth, &out->status))
2611                 return False;
2612
2613         return True;
2614 }
2615
2616 /*******************************************************************
2617  Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure.
2618 ********************************************************************/
2619
2620 void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *in, 
2621                                POLICY_HND *hnd, 
2622                                DOM_SID *sid,
2623                                uint32 removeall,
2624                                uint32 count, 
2625                                const char **rights)
2626 {
2627         DEBUG(5, ("init_q_remove_acct_rights\n"));
2628
2629         in->pol = *hnd;
2630
2631         init_dom_sid2(&in->sid, sid);
2632
2633         in->removeall = removeall;
2634         in->count = count;
2635
2636         in->rights = TALLOC_P( talloc_tos(), UNISTR4_ARRAY );
2637         if (!in->rights) {
2638                 smb_panic("init_q_remove_acct_rights: talloc fail\n");
2639                 return;
2640         }
2641         init_unistr4_array( in->rights, count, rights );
2642 }
2643
2644 /*******************************************************************
2645 reads or writes a LSA_Q_REMOVE_ACCT_RIGHTS structure.
2646 ********************************************************************/
2647
2648 bool lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *in, prs_struct *ps, int depth)
2649 {
2650         prs_debug(ps, depth, desc, "lsa_io_q_remove_acct_rights");
2651         depth++;
2652
2653         if (!smb_io_pol_hnd("", &in->pol, ps, depth))
2654                 return False;
2655
2656         if(!smb_io_dom_sid2("sid", &in->sid, ps, depth))
2657                 return False;
2658
2659         if(!prs_uint32("removeall", ps, depth, &in->removeall))
2660                 return False;
2661
2662         if(!prs_uint32("count", ps, depth, &in->count))
2663                 return False;
2664
2665         if ( !prs_pointer("rights", ps, depth, (void*)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2666                 return False;
2667
2668         return True;
2669 }
2670
2671 /*******************************************************************
2672 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2673 ********************************************************************/
2674 bool lsa_io_r_remove_acct_rights(const char *desc, LSA_R_REMOVE_ACCT_RIGHTS *out, prs_struct *ps, int depth)
2675 {
2676         prs_debug(ps, depth, desc, "lsa_io_r_remove_acct_rights");
2677         depth++;
2678
2679         if(!prs_ntstatus("status", ps, depth, &out->status))
2680                 return False;
2681
2682         return True;
2683 }