s3/s4:samr.idl - Corrects the "userPwdChangeFailureInformation" structure
[ira/wip.git] / librpc / gen_ndr / cli_samr.c
1 /*
2  * Unix SMB/CIFS implementation.
3  * client auto-generated by pidl. DO NOT MODIFY!
4  */
5
6 #include "includes.h"
7 #include "../librpc/gen_ndr/cli_samr.h"
8
9 struct rpccli_samr_Connect_state {
10         struct samr_Connect orig;
11         struct samr_Connect tmp;
12         TALLOC_CTX *out_mem_ctx;
13         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
14 };
15
16 static void rpccli_samr_Connect_done(struct tevent_req *subreq);
17
18 struct tevent_req *rpccli_samr_Connect_send(TALLOC_CTX *mem_ctx,
19                                             struct tevent_context *ev,
20                                             struct rpc_pipe_client *cli,
21                                             uint16_t *_system_name /* [in] [unique] */,
22                                             uint32_t _access_mask /* [in]  */,
23                                             struct policy_handle *_connect_handle /* [out] [ref] */)
24 {
25         struct tevent_req *req;
26         struct rpccli_samr_Connect_state *state;
27         struct tevent_req *subreq;
28
29         req = tevent_req_create(mem_ctx, &state,
30                                 struct rpccli_samr_Connect_state);
31         if (req == NULL) {
32                 return NULL;
33         }
34         state->out_mem_ctx = NULL;
35         state->dispatch_recv = cli->dispatch_recv;
36
37         /* In parameters */
38         state->orig.in.system_name = _system_name;
39         state->orig.in.access_mask = _access_mask;
40
41         /* Out parameters */
42         state->orig.out.connect_handle = _connect_handle;
43
44         /* Result */
45         ZERO_STRUCT(state->orig.out.result);
46
47         if (DEBUGLEVEL >= 10) {
48                 NDR_PRINT_IN_DEBUG(samr_Connect, &state->orig);
49         }
50
51         state->out_mem_ctx = talloc_named_const(state, 0,
52                              "rpccli_samr_Connect_out_memory");
53         if (tevent_req_nomem(state->out_mem_ctx, req)) {
54                 return tevent_req_post(req, ev);
55         }
56
57         /* make a temporary copy, that we pass to the dispatch function */
58         state->tmp = state->orig;
59
60         subreq = cli->dispatch_send(state, ev, cli,
61                                     &ndr_table_samr,
62                                     NDR_SAMR_CONNECT,
63                                     &state->tmp);
64         if (tevent_req_nomem(subreq, req)) {
65                 return tevent_req_post(req, ev);
66         }
67         tevent_req_set_callback(subreq, rpccli_samr_Connect_done, req);
68         return req;
69 }
70
71 static void rpccli_samr_Connect_done(struct tevent_req *subreq)
72 {
73         struct tevent_req *req = tevent_req_callback_data(
74                 subreq, struct tevent_req);
75         struct rpccli_samr_Connect_state *state = tevent_req_data(
76                 req, struct rpccli_samr_Connect_state);
77         NTSTATUS status;
78         TALLOC_CTX *mem_ctx;
79
80         if (state->out_mem_ctx) {
81                 mem_ctx = state->out_mem_ctx;
82         } else {
83                 mem_ctx = state;
84         }
85
86         status = state->dispatch_recv(subreq, mem_ctx);
87         TALLOC_FREE(subreq);
88         if (!NT_STATUS_IS_OK(status)) {
89                 tevent_req_nterror(req, status);
90                 return;
91         }
92
93         /* Copy out parameters */
94         *state->orig.out.connect_handle = *state->tmp.out.connect_handle;
95
96         /* Copy result */
97         state->orig.out.result = state->tmp.out.result;
98
99         /* Reset temporary structure */
100         ZERO_STRUCT(state->tmp);
101
102         if (DEBUGLEVEL >= 10) {
103                 NDR_PRINT_OUT_DEBUG(samr_Connect, &state->orig);
104         }
105
106         tevent_req_done(req);
107 }
108
109 NTSTATUS rpccli_samr_Connect_recv(struct tevent_req *req,
110                                   TALLOC_CTX *mem_ctx,
111                                   NTSTATUS *result)
112 {
113         struct rpccli_samr_Connect_state *state = tevent_req_data(
114                 req, struct rpccli_samr_Connect_state);
115         NTSTATUS status;
116
117         if (tevent_req_is_nterror(req, &status)) {
118                 tevent_req_received(req);
119                 return status;
120         }
121
122         /* Steal possbile out parameters to the callers context */
123         talloc_steal(mem_ctx, state->out_mem_ctx);
124
125         /* Return result */
126         *result = state->orig.out.result;
127
128         tevent_req_received(req);
129         return NT_STATUS_OK;
130 }
131
132 NTSTATUS rpccli_samr_Connect(struct rpc_pipe_client *cli,
133                              TALLOC_CTX *mem_ctx,
134                              uint16_t *system_name /* [in] [unique] */,
135                              uint32_t access_mask /* [in]  */,
136                              struct policy_handle *connect_handle /* [out] [ref] */)
137 {
138         struct samr_Connect r;
139         NTSTATUS status;
140
141         /* In parameters */
142         r.in.system_name = system_name;
143         r.in.access_mask = access_mask;
144
145         if (DEBUGLEVEL >= 10) {
146                 NDR_PRINT_IN_DEBUG(samr_Connect, &r);
147         }
148
149         status = cli->dispatch(cli,
150                                 mem_ctx,
151                                 &ndr_table_samr,
152                                 NDR_SAMR_CONNECT,
153                                 &r);
154
155         if (!NT_STATUS_IS_OK(status)) {
156                 return status;
157         }
158
159         if (DEBUGLEVEL >= 10) {
160                 NDR_PRINT_OUT_DEBUG(samr_Connect, &r);
161         }
162
163         if (NT_STATUS_IS_ERR(status)) {
164                 return status;
165         }
166
167         /* Return variables */
168         *connect_handle = *r.out.connect_handle;
169
170         /* Return result */
171         return r.out.result;
172 }
173
174 struct rpccli_samr_Close_state {
175         struct samr_Close orig;
176         struct samr_Close tmp;
177         TALLOC_CTX *out_mem_ctx;
178         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
179 };
180
181 static void rpccli_samr_Close_done(struct tevent_req *subreq);
182
183 struct tevent_req *rpccli_samr_Close_send(TALLOC_CTX *mem_ctx,
184                                           struct tevent_context *ev,
185                                           struct rpc_pipe_client *cli,
186                                           struct policy_handle *_handle /* [in,out] [ref] */)
187 {
188         struct tevent_req *req;
189         struct rpccli_samr_Close_state *state;
190         struct tevent_req *subreq;
191
192         req = tevent_req_create(mem_ctx, &state,
193                                 struct rpccli_samr_Close_state);
194         if (req == NULL) {
195                 return NULL;
196         }
197         state->out_mem_ctx = NULL;
198         state->dispatch_recv = cli->dispatch_recv;
199
200         /* In parameters */
201         state->orig.in.handle = _handle;
202
203         /* Out parameters */
204         state->orig.out.handle = _handle;
205
206         /* Result */
207         ZERO_STRUCT(state->orig.out.result);
208
209         if (DEBUGLEVEL >= 10) {
210                 NDR_PRINT_IN_DEBUG(samr_Close, &state->orig);
211         }
212
213         state->out_mem_ctx = talloc_named_const(state, 0,
214                              "rpccli_samr_Close_out_memory");
215         if (tevent_req_nomem(state->out_mem_ctx, req)) {
216                 return tevent_req_post(req, ev);
217         }
218
219         /* make a temporary copy, that we pass to the dispatch function */
220         state->tmp = state->orig;
221
222         subreq = cli->dispatch_send(state, ev, cli,
223                                     &ndr_table_samr,
224                                     NDR_SAMR_CLOSE,
225                                     &state->tmp);
226         if (tevent_req_nomem(subreq, req)) {
227                 return tevent_req_post(req, ev);
228         }
229         tevent_req_set_callback(subreq, rpccli_samr_Close_done, req);
230         return req;
231 }
232
233 static void rpccli_samr_Close_done(struct tevent_req *subreq)
234 {
235         struct tevent_req *req = tevent_req_callback_data(
236                 subreq, struct tevent_req);
237         struct rpccli_samr_Close_state *state = tevent_req_data(
238                 req, struct rpccli_samr_Close_state);
239         NTSTATUS status;
240         TALLOC_CTX *mem_ctx;
241
242         if (state->out_mem_ctx) {
243                 mem_ctx = state->out_mem_ctx;
244         } else {
245                 mem_ctx = state;
246         }
247
248         status = state->dispatch_recv(subreq, mem_ctx);
249         TALLOC_FREE(subreq);
250         if (!NT_STATUS_IS_OK(status)) {
251                 tevent_req_nterror(req, status);
252                 return;
253         }
254
255         /* Copy out parameters */
256         *state->orig.out.handle = *state->tmp.out.handle;
257
258         /* Copy result */
259         state->orig.out.result = state->tmp.out.result;
260
261         /* Reset temporary structure */
262         ZERO_STRUCT(state->tmp);
263
264         if (DEBUGLEVEL >= 10) {
265                 NDR_PRINT_OUT_DEBUG(samr_Close, &state->orig);
266         }
267
268         tevent_req_done(req);
269 }
270
271 NTSTATUS rpccli_samr_Close_recv(struct tevent_req *req,
272                                 TALLOC_CTX *mem_ctx,
273                                 NTSTATUS *result)
274 {
275         struct rpccli_samr_Close_state *state = tevent_req_data(
276                 req, struct rpccli_samr_Close_state);
277         NTSTATUS status;
278
279         if (tevent_req_is_nterror(req, &status)) {
280                 tevent_req_received(req);
281                 return status;
282         }
283
284         /* Steal possbile out parameters to the callers context */
285         talloc_steal(mem_ctx, state->out_mem_ctx);
286
287         /* Return result */
288         *result = state->orig.out.result;
289
290         tevent_req_received(req);
291         return NT_STATUS_OK;
292 }
293
294 NTSTATUS rpccli_samr_Close(struct rpc_pipe_client *cli,
295                            TALLOC_CTX *mem_ctx,
296                            struct policy_handle *handle /* [in,out] [ref] */)
297 {
298         struct samr_Close r;
299         NTSTATUS status;
300
301         /* In parameters */
302         r.in.handle = handle;
303
304         if (DEBUGLEVEL >= 10) {
305                 NDR_PRINT_IN_DEBUG(samr_Close, &r);
306         }
307
308         status = cli->dispatch(cli,
309                                 mem_ctx,
310                                 &ndr_table_samr,
311                                 NDR_SAMR_CLOSE,
312                                 &r);
313
314         if (!NT_STATUS_IS_OK(status)) {
315                 return status;
316         }
317
318         if (DEBUGLEVEL >= 10) {
319                 NDR_PRINT_OUT_DEBUG(samr_Close, &r);
320         }
321
322         if (NT_STATUS_IS_ERR(status)) {
323                 return status;
324         }
325
326         /* Return variables */
327         *handle = *r.out.handle;
328
329         /* Return result */
330         return r.out.result;
331 }
332
333 struct rpccli_samr_SetSecurity_state {
334         struct samr_SetSecurity orig;
335         struct samr_SetSecurity tmp;
336         TALLOC_CTX *out_mem_ctx;
337         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
338 };
339
340 static void rpccli_samr_SetSecurity_done(struct tevent_req *subreq);
341
342 struct tevent_req *rpccli_samr_SetSecurity_send(TALLOC_CTX *mem_ctx,
343                                                 struct tevent_context *ev,
344                                                 struct rpc_pipe_client *cli,
345                                                 struct policy_handle *_handle /* [in] [ref] */,
346                                                 uint32_t _sec_info /* [in]  */,
347                                                 struct sec_desc_buf *_sdbuf /* [in] [ref] */)
348 {
349         struct tevent_req *req;
350         struct rpccli_samr_SetSecurity_state *state;
351         struct tevent_req *subreq;
352
353         req = tevent_req_create(mem_ctx, &state,
354                                 struct rpccli_samr_SetSecurity_state);
355         if (req == NULL) {
356                 return NULL;
357         }
358         state->out_mem_ctx = NULL;
359         state->dispatch_recv = cli->dispatch_recv;
360
361         /* In parameters */
362         state->orig.in.handle = _handle;
363         state->orig.in.sec_info = _sec_info;
364         state->orig.in.sdbuf = _sdbuf;
365
366         /* Out parameters */
367
368         /* Result */
369         ZERO_STRUCT(state->orig.out.result);
370
371         if (DEBUGLEVEL >= 10) {
372                 NDR_PRINT_IN_DEBUG(samr_SetSecurity, &state->orig);
373         }
374
375         /* make a temporary copy, that we pass to the dispatch function */
376         state->tmp = state->orig;
377
378         subreq = cli->dispatch_send(state, ev, cli,
379                                     &ndr_table_samr,
380                                     NDR_SAMR_SETSECURITY,
381                                     &state->tmp);
382         if (tevent_req_nomem(subreq, req)) {
383                 return tevent_req_post(req, ev);
384         }
385         tevent_req_set_callback(subreq, rpccli_samr_SetSecurity_done, req);
386         return req;
387 }
388
389 static void rpccli_samr_SetSecurity_done(struct tevent_req *subreq)
390 {
391         struct tevent_req *req = tevent_req_callback_data(
392                 subreq, struct tevent_req);
393         struct rpccli_samr_SetSecurity_state *state = tevent_req_data(
394                 req, struct rpccli_samr_SetSecurity_state);
395         NTSTATUS status;
396         TALLOC_CTX *mem_ctx;
397
398         if (state->out_mem_ctx) {
399                 mem_ctx = state->out_mem_ctx;
400         } else {
401                 mem_ctx = state;
402         }
403
404         status = state->dispatch_recv(subreq, mem_ctx);
405         TALLOC_FREE(subreq);
406         if (!NT_STATUS_IS_OK(status)) {
407                 tevent_req_nterror(req, status);
408                 return;
409         }
410
411         /* Copy out parameters */
412
413         /* Copy result */
414         state->orig.out.result = state->tmp.out.result;
415
416         /* Reset temporary structure */
417         ZERO_STRUCT(state->tmp);
418
419         if (DEBUGLEVEL >= 10) {
420                 NDR_PRINT_OUT_DEBUG(samr_SetSecurity, &state->orig);
421         }
422
423         tevent_req_done(req);
424 }
425
426 NTSTATUS rpccli_samr_SetSecurity_recv(struct tevent_req *req,
427                                       TALLOC_CTX *mem_ctx,
428                                       NTSTATUS *result)
429 {
430         struct rpccli_samr_SetSecurity_state *state = tevent_req_data(
431                 req, struct rpccli_samr_SetSecurity_state);
432         NTSTATUS status;
433
434         if (tevent_req_is_nterror(req, &status)) {
435                 tevent_req_received(req);
436                 return status;
437         }
438
439         /* Steal possbile out parameters to the callers context */
440         talloc_steal(mem_ctx, state->out_mem_ctx);
441
442         /* Return result */
443         *result = state->orig.out.result;
444
445         tevent_req_received(req);
446         return NT_STATUS_OK;
447 }
448
449 NTSTATUS rpccli_samr_SetSecurity(struct rpc_pipe_client *cli,
450                                  TALLOC_CTX *mem_ctx,
451                                  struct policy_handle *handle /* [in] [ref] */,
452                                  uint32_t sec_info /* [in]  */,
453                                  struct sec_desc_buf *sdbuf /* [in] [ref] */)
454 {
455         struct samr_SetSecurity r;
456         NTSTATUS status;
457
458         /* In parameters */
459         r.in.handle = handle;
460         r.in.sec_info = sec_info;
461         r.in.sdbuf = sdbuf;
462
463         if (DEBUGLEVEL >= 10) {
464                 NDR_PRINT_IN_DEBUG(samr_SetSecurity, &r);
465         }
466
467         status = cli->dispatch(cli,
468                                 mem_ctx,
469                                 &ndr_table_samr,
470                                 NDR_SAMR_SETSECURITY,
471                                 &r);
472
473         if (!NT_STATUS_IS_OK(status)) {
474                 return status;
475         }
476
477         if (DEBUGLEVEL >= 10) {
478                 NDR_PRINT_OUT_DEBUG(samr_SetSecurity, &r);
479         }
480
481         if (NT_STATUS_IS_ERR(status)) {
482                 return status;
483         }
484
485         /* Return variables */
486
487         /* Return result */
488         return r.out.result;
489 }
490
491 struct rpccli_samr_QuerySecurity_state {
492         struct samr_QuerySecurity orig;
493         struct samr_QuerySecurity tmp;
494         TALLOC_CTX *out_mem_ctx;
495         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
496 };
497
498 static void rpccli_samr_QuerySecurity_done(struct tevent_req *subreq);
499
500 struct tevent_req *rpccli_samr_QuerySecurity_send(TALLOC_CTX *mem_ctx,
501                                                   struct tevent_context *ev,
502                                                   struct rpc_pipe_client *cli,
503                                                   struct policy_handle *_handle /* [in] [ref] */,
504                                                   uint32_t _sec_info /* [in]  */,
505                                                   struct sec_desc_buf **_sdbuf /* [out] [ref] */)
506 {
507         struct tevent_req *req;
508         struct rpccli_samr_QuerySecurity_state *state;
509         struct tevent_req *subreq;
510
511         req = tevent_req_create(mem_ctx, &state,
512                                 struct rpccli_samr_QuerySecurity_state);
513         if (req == NULL) {
514                 return NULL;
515         }
516         state->out_mem_ctx = NULL;
517         state->dispatch_recv = cli->dispatch_recv;
518
519         /* In parameters */
520         state->orig.in.handle = _handle;
521         state->orig.in.sec_info = _sec_info;
522
523         /* Out parameters */
524         state->orig.out.sdbuf = _sdbuf;
525
526         /* Result */
527         ZERO_STRUCT(state->orig.out.result);
528
529         if (DEBUGLEVEL >= 10) {
530                 NDR_PRINT_IN_DEBUG(samr_QuerySecurity, &state->orig);
531         }
532
533         state->out_mem_ctx = talloc_named_const(state, 0,
534                              "rpccli_samr_QuerySecurity_out_memory");
535         if (tevent_req_nomem(state->out_mem_ctx, req)) {
536                 return tevent_req_post(req, ev);
537         }
538
539         /* make a temporary copy, that we pass to the dispatch function */
540         state->tmp = state->orig;
541
542         subreq = cli->dispatch_send(state, ev, cli,
543                                     &ndr_table_samr,
544                                     NDR_SAMR_QUERYSECURITY,
545                                     &state->tmp);
546         if (tevent_req_nomem(subreq, req)) {
547                 return tevent_req_post(req, ev);
548         }
549         tevent_req_set_callback(subreq, rpccli_samr_QuerySecurity_done, req);
550         return req;
551 }
552
553 static void rpccli_samr_QuerySecurity_done(struct tevent_req *subreq)
554 {
555         struct tevent_req *req = tevent_req_callback_data(
556                 subreq, struct tevent_req);
557         struct rpccli_samr_QuerySecurity_state *state = tevent_req_data(
558                 req, struct rpccli_samr_QuerySecurity_state);
559         NTSTATUS status;
560         TALLOC_CTX *mem_ctx;
561
562         if (state->out_mem_ctx) {
563                 mem_ctx = state->out_mem_ctx;
564         } else {
565                 mem_ctx = state;
566         }
567
568         status = state->dispatch_recv(subreq, mem_ctx);
569         TALLOC_FREE(subreq);
570         if (!NT_STATUS_IS_OK(status)) {
571                 tevent_req_nterror(req, status);
572                 return;
573         }
574
575         /* Copy out parameters */
576         *state->orig.out.sdbuf = *state->tmp.out.sdbuf;
577
578         /* Copy result */
579         state->orig.out.result = state->tmp.out.result;
580
581         /* Reset temporary structure */
582         ZERO_STRUCT(state->tmp);
583
584         if (DEBUGLEVEL >= 10) {
585                 NDR_PRINT_OUT_DEBUG(samr_QuerySecurity, &state->orig);
586         }
587
588         tevent_req_done(req);
589 }
590
591 NTSTATUS rpccli_samr_QuerySecurity_recv(struct tevent_req *req,
592                                         TALLOC_CTX *mem_ctx,
593                                         NTSTATUS *result)
594 {
595         struct rpccli_samr_QuerySecurity_state *state = tevent_req_data(
596                 req, struct rpccli_samr_QuerySecurity_state);
597         NTSTATUS status;
598
599         if (tevent_req_is_nterror(req, &status)) {
600                 tevent_req_received(req);
601                 return status;
602         }
603
604         /* Steal possbile out parameters to the callers context */
605         talloc_steal(mem_ctx, state->out_mem_ctx);
606
607         /* Return result */
608         *result = state->orig.out.result;
609
610         tevent_req_received(req);
611         return NT_STATUS_OK;
612 }
613
614 NTSTATUS rpccli_samr_QuerySecurity(struct rpc_pipe_client *cli,
615                                    TALLOC_CTX *mem_ctx,
616                                    struct policy_handle *handle /* [in] [ref] */,
617                                    uint32_t sec_info /* [in]  */,
618                                    struct sec_desc_buf **sdbuf /* [out] [ref] */)
619 {
620         struct samr_QuerySecurity r;
621         NTSTATUS status;
622
623         /* In parameters */
624         r.in.handle = handle;
625         r.in.sec_info = sec_info;
626
627         if (DEBUGLEVEL >= 10) {
628                 NDR_PRINT_IN_DEBUG(samr_QuerySecurity, &r);
629         }
630
631         status = cli->dispatch(cli,
632                                 mem_ctx,
633                                 &ndr_table_samr,
634                                 NDR_SAMR_QUERYSECURITY,
635                                 &r);
636
637         if (!NT_STATUS_IS_OK(status)) {
638                 return status;
639         }
640
641         if (DEBUGLEVEL >= 10) {
642                 NDR_PRINT_OUT_DEBUG(samr_QuerySecurity, &r);
643         }
644
645         if (NT_STATUS_IS_ERR(status)) {
646                 return status;
647         }
648
649         /* Return variables */
650         *sdbuf = *r.out.sdbuf;
651
652         /* Return result */
653         return r.out.result;
654 }
655
656 struct rpccli_samr_Shutdown_state {
657         struct samr_Shutdown orig;
658         struct samr_Shutdown tmp;
659         TALLOC_CTX *out_mem_ctx;
660         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
661 };
662
663 static void rpccli_samr_Shutdown_done(struct tevent_req *subreq);
664
665 struct tevent_req *rpccli_samr_Shutdown_send(TALLOC_CTX *mem_ctx,
666                                              struct tevent_context *ev,
667                                              struct rpc_pipe_client *cli,
668                                              struct policy_handle *_connect_handle /* [in] [ref] */)
669 {
670         struct tevent_req *req;
671         struct rpccli_samr_Shutdown_state *state;
672         struct tevent_req *subreq;
673
674         req = tevent_req_create(mem_ctx, &state,
675                                 struct rpccli_samr_Shutdown_state);
676         if (req == NULL) {
677                 return NULL;
678         }
679         state->out_mem_ctx = NULL;
680         state->dispatch_recv = cli->dispatch_recv;
681
682         /* In parameters */
683         state->orig.in.connect_handle = _connect_handle;
684
685         /* Out parameters */
686
687         /* Result */
688         ZERO_STRUCT(state->orig.out.result);
689
690         if (DEBUGLEVEL >= 10) {
691                 NDR_PRINT_IN_DEBUG(samr_Shutdown, &state->orig);
692         }
693
694         /* make a temporary copy, that we pass to the dispatch function */
695         state->tmp = state->orig;
696
697         subreq = cli->dispatch_send(state, ev, cli,
698                                     &ndr_table_samr,
699                                     NDR_SAMR_SHUTDOWN,
700                                     &state->tmp);
701         if (tevent_req_nomem(subreq, req)) {
702                 return tevent_req_post(req, ev);
703         }
704         tevent_req_set_callback(subreq, rpccli_samr_Shutdown_done, req);
705         return req;
706 }
707
708 static void rpccli_samr_Shutdown_done(struct tevent_req *subreq)
709 {
710         struct tevent_req *req = tevent_req_callback_data(
711                 subreq, struct tevent_req);
712         struct rpccli_samr_Shutdown_state *state = tevent_req_data(
713                 req, struct rpccli_samr_Shutdown_state);
714         NTSTATUS status;
715         TALLOC_CTX *mem_ctx;
716
717         if (state->out_mem_ctx) {
718                 mem_ctx = state->out_mem_ctx;
719         } else {
720                 mem_ctx = state;
721         }
722
723         status = state->dispatch_recv(subreq, mem_ctx);
724         TALLOC_FREE(subreq);
725         if (!NT_STATUS_IS_OK(status)) {
726                 tevent_req_nterror(req, status);
727                 return;
728         }
729
730         /* Copy out parameters */
731
732         /* Copy result */
733         state->orig.out.result = state->tmp.out.result;
734
735         /* Reset temporary structure */
736         ZERO_STRUCT(state->tmp);
737
738         if (DEBUGLEVEL >= 10) {
739                 NDR_PRINT_OUT_DEBUG(samr_Shutdown, &state->orig);
740         }
741
742         tevent_req_done(req);
743 }
744
745 NTSTATUS rpccli_samr_Shutdown_recv(struct tevent_req *req,
746                                    TALLOC_CTX *mem_ctx,
747                                    NTSTATUS *result)
748 {
749         struct rpccli_samr_Shutdown_state *state = tevent_req_data(
750                 req, struct rpccli_samr_Shutdown_state);
751         NTSTATUS status;
752
753         if (tevent_req_is_nterror(req, &status)) {
754                 tevent_req_received(req);
755                 return status;
756         }
757
758         /* Steal possbile out parameters to the callers context */
759         talloc_steal(mem_ctx, state->out_mem_ctx);
760
761         /* Return result */
762         *result = state->orig.out.result;
763
764         tevent_req_received(req);
765         return NT_STATUS_OK;
766 }
767
768 NTSTATUS rpccli_samr_Shutdown(struct rpc_pipe_client *cli,
769                               TALLOC_CTX *mem_ctx,
770                               struct policy_handle *connect_handle /* [in] [ref] */)
771 {
772         struct samr_Shutdown r;
773         NTSTATUS status;
774
775         /* In parameters */
776         r.in.connect_handle = connect_handle;
777
778         if (DEBUGLEVEL >= 10) {
779                 NDR_PRINT_IN_DEBUG(samr_Shutdown, &r);
780         }
781
782         status = cli->dispatch(cli,
783                                 mem_ctx,
784                                 &ndr_table_samr,
785                                 NDR_SAMR_SHUTDOWN,
786                                 &r);
787
788         if (!NT_STATUS_IS_OK(status)) {
789                 return status;
790         }
791
792         if (DEBUGLEVEL >= 10) {
793                 NDR_PRINT_OUT_DEBUG(samr_Shutdown, &r);
794         }
795
796         if (NT_STATUS_IS_ERR(status)) {
797                 return status;
798         }
799
800         /* Return variables */
801
802         /* Return result */
803         return r.out.result;
804 }
805
806 struct rpccli_samr_LookupDomain_state {
807         struct samr_LookupDomain orig;
808         struct samr_LookupDomain tmp;
809         TALLOC_CTX *out_mem_ctx;
810         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
811 };
812
813 static void rpccli_samr_LookupDomain_done(struct tevent_req *subreq);
814
815 struct tevent_req *rpccli_samr_LookupDomain_send(TALLOC_CTX *mem_ctx,
816                                                  struct tevent_context *ev,
817                                                  struct rpc_pipe_client *cli,
818                                                  struct policy_handle *_connect_handle /* [in] [ref] */,
819                                                  struct lsa_String *_domain_name /* [in] [ref] */,
820                                                  struct dom_sid2 **_sid /* [out] [ref] */)
821 {
822         struct tevent_req *req;
823         struct rpccli_samr_LookupDomain_state *state;
824         struct tevent_req *subreq;
825
826         req = tevent_req_create(mem_ctx, &state,
827                                 struct rpccli_samr_LookupDomain_state);
828         if (req == NULL) {
829                 return NULL;
830         }
831         state->out_mem_ctx = NULL;
832         state->dispatch_recv = cli->dispatch_recv;
833
834         /* In parameters */
835         state->orig.in.connect_handle = _connect_handle;
836         state->orig.in.domain_name = _domain_name;
837
838         /* Out parameters */
839         state->orig.out.sid = _sid;
840
841         /* Result */
842         ZERO_STRUCT(state->orig.out.result);
843
844         if (DEBUGLEVEL >= 10) {
845                 NDR_PRINT_IN_DEBUG(samr_LookupDomain, &state->orig);
846         }
847
848         state->out_mem_ctx = talloc_named_const(state, 0,
849                              "rpccli_samr_LookupDomain_out_memory");
850         if (tevent_req_nomem(state->out_mem_ctx, req)) {
851                 return tevent_req_post(req, ev);
852         }
853
854         /* make a temporary copy, that we pass to the dispatch function */
855         state->tmp = state->orig;
856
857         subreq = cli->dispatch_send(state, ev, cli,
858                                     &ndr_table_samr,
859                                     NDR_SAMR_LOOKUPDOMAIN,
860                                     &state->tmp);
861         if (tevent_req_nomem(subreq, req)) {
862                 return tevent_req_post(req, ev);
863         }
864         tevent_req_set_callback(subreq, rpccli_samr_LookupDomain_done, req);
865         return req;
866 }
867
868 static void rpccli_samr_LookupDomain_done(struct tevent_req *subreq)
869 {
870         struct tevent_req *req = tevent_req_callback_data(
871                 subreq, struct tevent_req);
872         struct rpccli_samr_LookupDomain_state *state = tevent_req_data(
873                 req, struct rpccli_samr_LookupDomain_state);
874         NTSTATUS status;
875         TALLOC_CTX *mem_ctx;
876
877         if (state->out_mem_ctx) {
878                 mem_ctx = state->out_mem_ctx;
879         } else {
880                 mem_ctx = state;
881         }
882
883         status = state->dispatch_recv(subreq, mem_ctx);
884         TALLOC_FREE(subreq);
885         if (!NT_STATUS_IS_OK(status)) {
886                 tevent_req_nterror(req, status);
887                 return;
888         }
889
890         /* Copy out parameters */
891         *state->orig.out.sid = *state->tmp.out.sid;
892
893         /* Copy result */
894         state->orig.out.result = state->tmp.out.result;
895
896         /* Reset temporary structure */
897         ZERO_STRUCT(state->tmp);
898
899         if (DEBUGLEVEL >= 10) {
900                 NDR_PRINT_OUT_DEBUG(samr_LookupDomain, &state->orig);
901         }
902
903         tevent_req_done(req);
904 }
905
906 NTSTATUS rpccli_samr_LookupDomain_recv(struct tevent_req *req,
907                                        TALLOC_CTX *mem_ctx,
908                                        NTSTATUS *result)
909 {
910         struct rpccli_samr_LookupDomain_state *state = tevent_req_data(
911                 req, struct rpccli_samr_LookupDomain_state);
912         NTSTATUS status;
913
914         if (tevent_req_is_nterror(req, &status)) {
915                 tevent_req_received(req);
916                 return status;
917         }
918
919         /* Steal possbile out parameters to the callers context */
920         talloc_steal(mem_ctx, state->out_mem_ctx);
921
922         /* Return result */
923         *result = state->orig.out.result;
924
925         tevent_req_received(req);
926         return NT_STATUS_OK;
927 }
928
929 NTSTATUS rpccli_samr_LookupDomain(struct rpc_pipe_client *cli,
930                                   TALLOC_CTX *mem_ctx,
931                                   struct policy_handle *connect_handle /* [in] [ref] */,
932                                   struct lsa_String *domain_name /* [in] [ref] */,
933                                   struct dom_sid2 **sid /* [out] [ref] */)
934 {
935         struct samr_LookupDomain r;
936         NTSTATUS status;
937
938         /* In parameters */
939         r.in.connect_handle = connect_handle;
940         r.in.domain_name = domain_name;
941
942         if (DEBUGLEVEL >= 10) {
943                 NDR_PRINT_IN_DEBUG(samr_LookupDomain, &r);
944         }
945
946         status = cli->dispatch(cli,
947                                 mem_ctx,
948                                 &ndr_table_samr,
949                                 NDR_SAMR_LOOKUPDOMAIN,
950                                 &r);
951
952         if (!NT_STATUS_IS_OK(status)) {
953                 return status;
954         }
955
956         if (DEBUGLEVEL >= 10) {
957                 NDR_PRINT_OUT_DEBUG(samr_LookupDomain, &r);
958         }
959
960         if (NT_STATUS_IS_ERR(status)) {
961                 return status;
962         }
963
964         /* Return variables */
965         *sid = *r.out.sid;
966
967         /* Return result */
968         return r.out.result;
969 }
970
971 struct rpccli_samr_EnumDomains_state {
972         struct samr_EnumDomains orig;
973         struct samr_EnumDomains tmp;
974         TALLOC_CTX *out_mem_ctx;
975         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
976 };
977
978 static void rpccli_samr_EnumDomains_done(struct tevent_req *subreq);
979
980 struct tevent_req *rpccli_samr_EnumDomains_send(TALLOC_CTX *mem_ctx,
981                                                 struct tevent_context *ev,
982                                                 struct rpc_pipe_client *cli,
983                                                 struct policy_handle *_connect_handle /* [in] [ref] */,
984                                                 uint32_t *_resume_handle /* [in,out] [ref] */,
985                                                 struct samr_SamArray **_sam /* [out] [ref] */,
986                                                 uint32_t _buf_size /* [in]  */,
987                                                 uint32_t *_num_entries /* [out] [ref] */)
988 {
989         struct tevent_req *req;
990         struct rpccli_samr_EnumDomains_state *state;
991         struct tevent_req *subreq;
992
993         req = tevent_req_create(mem_ctx, &state,
994                                 struct rpccli_samr_EnumDomains_state);
995         if (req == NULL) {
996                 return NULL;
997         }
998         state->out_mem_ctx = NULL;
999         state->dispatch_recv = cli->dispatch_recv;
1000
1001         /* In parameters */
1002         state->orig.in.connect_handle = _connect_handle;
1003         state->orig.in.resume_handle = _resume_handle;
1004         state->orig.in.buf_size = _buf_size;
1005
1006         /* Out parameters */
1007         state->orig.out.resume_handle = _resume_handle;
1008         state->orig.out.sam = _sam;
1009         state->orig.out.num_entries = _num_entries;
1010
1011         /* Result */
1012         ZERO_STRUCT(state->orig.out.result);
1013
1014         if (DEBUGLEVEL >= 10) {
1015                 NDR_PRINT_IN_DEBUG(samr_EnumDomains, &state->orig);
1016         }
1017
1018         state->out_mem_ctx = talloc_named_const(state, 0,
1019                              "rpccli_samr_EnumDomains_out_memory");
1020         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1021                 return tevent_req_post(req, ev);
1022         }
1023
1024         /* make a temporary copy, that we pass to the dispatch function */
1025         state->tmp = state->orig;
1026
1027         subreq = cli->dispatch_send(state, ev, cli,
1028                                     &ndr_table_samr,
1029                                     NDR_SAMR_ENUMDOMAINS,
1030                                     &state->tmp);
1031         if (tevent_req_nomem(subreq, req)) {
1032                 return tevent_req_post(req, ev);
1033         }
1034         tevent_req_set_callback(subreq, rpccli_samr_EnumDomains_done, req);
1035         return req;
1036 }
1037
1038 static void rpccli_samr_EnumDomains_done(struct tevent_req *subreq)
1039 {
1040         struct tevent_req *req = tevent_req_callback_data(
1041                 subreq, struct tevent_req);
1042         struct rpccli_samr_EnumDomains_state *state = tevent_req_data(
1043                 req, struct rpccli_samr_EnumDomains_state);
1044         NTSTATUS status;
1045         TALLOC_CTX *mem_ctx;
1046
1047         if (state->out_mem_ctx) {
1048                 mem_ctx = state->out_mem_ctx;
1049         } else {
1050                 mem_ctx = state;
1051         }
1052
1053         status = state->dispatch_recv(subreq, mem_ctx);
1054         TALLOC_FREE(subreq);
1055         if (!NT_STATUS_IS_OK(status)) {
1056                 tevent_req_nterror(req, status);
1057                 return;
1058         }
1059
1060         /* Copy out parameters */
1061         *state->orig.out.resume_handle = *state->tmp.out.resume_handle;
1062         *state->orig.out.sam = *state->tmp.out.sam;
1063         *state->orig.out.num_entries = *state->tmp.out.num_entries;
1064
1065         /* Copy result */
1066         state->orig.out.result = state->tmp.out.result;
1067
1068         /* Reset temporary structure */
1069         ZERO_STRUCT(state->tmp);
1070
1071         if (DEBUGLEVEL >= 10) {
1072                 NDR_PRINT_OUT_DEBUG(samr_EnumDomains, &state->orig);
1073         }
1074
1075         tevent_req_done(req);
1076 }
1077
1078 NTSTATUS rpccli_samr_EnumDomains_recv(struct tevent_req *req,
1079                                       TALLOC_CTX *mem_ctx,
1080                                       NTSTATUS *result)
1081 {
1082         struct rpccli_samr_EnumDomains_state *state = tevent_req_data(
1083                 req, struct rpccli_samr_EnumDomains_state);
1084         NTSTATUS status;
1085
1086         if (tevent_req_is_nterror(req, &status)) {
1087                 tevent_req_received(req);
1088                 return status;
1089         }
1090
1091         /* Steal possbile out parameters to the callers context */
1092         talloc_steal(mem_ctx, state->out_mem_ctx);
1093
1094         /* Return result */
1095         *result = state->orig.out.result;
1096
1097         tevent_req_received(req);
1098         return NT_STATUS_OK;
1099 }
1100
1101 NTSTATUS rpccli_samr_EnumDomains(struct rpc_pipe_client *cli,
1102                                  TALLOC_CTX *mem_ctx,
1103                                  struct policy_handle *connect_handle /* [in] [ref] */,
1104                                  uint32_t *resume_handle /* [in,out] [ref] */,
1105                                  struct samr_SamArray **sam /* [out] [ref] */,
1106                                  uint32_t buf_size /* [in]  */,
1107                                  uint32_t *num_entries /* [out] [ref] */)
1108 {
1109         struct samr_EnumDomains r;
1110         NTSTATUS status;
1111
1112         /* In parameters */
1113         r.in.connect_handle = connect_handle;
1114         r.in.resume_handle = resume_handle;
1115         r.in.buf_size = buf_size;
1116
1117         if (DEBUGLEVEL >= 10) {
1118                 NDR_PRINT_IN_DEBUG(samr_EnumDomains, &r);
1119         }
1120
1121         status = cli->dispatch(cli,
1122                                 mem_ctx,
1123                                 &ndr_table_samr,
1124                                 NDR_SAMR_ENUMDOMAINS,
1125                                 &r);
1126
1127         if (!NT_STATUS_IS_OK(status)) {
1128                 return status;
1129         }
1130
1131         if (DEBUGLEVEL >= 10) {
1132                 NDR_PRINT_OUT_DEBUG(samr_EnumDomains, &r);
1133         }
1134
1135         if (NT_STATUS_IS_ERR(status)) {
1136                 return status;
1137         }
1138
1139         /* Return variables */
1140         *resume_handle = *r.out.resume_handle;
1141         *sam = *r.out.sam;
1142         *num_entries = *r.out.num_entries;
1143
1144         /* Return result */
1145         return r.out.result;
1146 }
1147
1148 struct rpccli_samr_OpenDomain_state {
1149         struct samr_OpenDomain orig;
1150         struct samr_OpenDomain tmp;
1151         TALLOC_CTX *out_mem_ctx;
1152         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1153 };
1154
1155 static void rpccli_samr_OpenDomain_done(struct tevent_req *subreq);
1156
1157 struct tevent_req *rpccli_samr_OpenDomain_send(TALLOC_CTX *mem_ctx,
1158                                                struct tevent_context *ev,
1159                                                struct rpc_pipe_client *cli,
1160                                                struct policy_handle *_connect_handle /* [in] [ref] */,
1161                                                uint32_t _access_mask /* [in]  */,
1162                                                struct dom_sid2 *_sid /* [in] [ref] */,
1163                                                struct policy_handle *_domain_handle /* [out] [ref] */)
1164 {
1165         struct tevent_req *req;
1166         struct rpccli_samr_OpenDomain_state *state;
1167         struct tevent_req *subreq;
1168
1169         req = tevent_req_create(mem_ctx, &state,
1170                                 struct rpccli_samr_OpenDomain_state);
1171         if (req == NULL) {
1172                 return NULL;
1173         }
1174         state->out_mem_ctx = NULL;
1175         state->dispatch_recv = cli->dispatch_recv;
1176
1177         /* In parameters */
1178         state->orig.in.connect_handle = _connect_handle;
1179         state->orig.in.access_mask = _access_mask;
1180         state->orig.in.sid = _sid;
1181
1182         /* Out parameters */
1183         state->orig.out.domain_handle = _domain_handle;
1184
1185         /* Result */
1186         ZERO_STRUCT(state->orig.out.result);
1187
1188         if (DEBUGLEVEL >= 10) {
1189                 NDR_PRINT_IN_DEBUG(samr_OpenDomain, &state->orig);
1190         }
1191
1192         state->out_mem_ctx = talloc_named_const(state, 0,
1193                              "rpccli_samr_OpenDomain_out_memory");
1194         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1195                 return tevent_req_post(req, ev);
1196         }
1197
1198         /* make a temporary copy, that we pass to the dispatch function */
1199         state->tmp = state->orig;
1200
1201         subreq = cli->dispatch_send(state, ev, cli,
1202                                     &ndr_table_samr,
1203                                     NDR_SAMR_OPENDOMAIN,
1204                                     &state->tmp);
1205         if (tevent_req_nomem(subreq, req)) {
1206                 return tevent_req_post(req, ev);
1207         }
1208         tevent_req_set_callback(subreq, rpccli_samr_OpenDomain_done, req);
1209         return req;
1210 }
1211
1212 static void rpccli_samr_OpenDomain_done(struct tevent_req *subreq)
1213 {
1214         struct tevent_req *req = tevent_req_callback_data(
1215                 subreq, struct tevent_req);
1216         struct rpccli_samr_OpenDomain_state *state = tevent_req_data(
1217                 req, struct rpccli_samr_OpenDomain_state);
1218         NTSTATUS status;
1219         TALLOC_CTX *mem_ctx;
1220
1221         if (state->out_mem_ctx) {
1222                 mem_ctx = state->out_mem_ctx;
1223         } else {
1224                 mem_ctx = state;
1225         }
1226
1227         status = state->dispatch_recv(subreq, mem_ctx);
1228         TALLOC_FREE(subreq);
1229         if (!NT_STATUS_IS_OK(status)) {
1230                 tevent_req_nterror(req, status);
1231                 return;
1232         }
1233
1234         /* Copy out parameters */
1235         *state->orig.out.domain_handle = *state->tmp.out.domain_handle;
1236
1237         /* Copy result */
1238         state->orig.out.result = state->tmp.out.result;
1239
1240         /* Reset temporary structure */
1241         ZERO_STRUCT(state->tmp);
1242
1243         if (DEBUGLEVEL >= 10) {
1244                 NDR_PRINT_OUT_DEBUG(samr_OpenDomain, &state->orig);
1245         }
1246
1247         tevent_req_done(req);
1248 }
1249
1250 NTSTATUS rpccli_samr_OpenDomain_recv(struct tevent_req *req,
1251                                      TALLOC_CTX *mem_ctx,
1252                                      NTSTATUS *result)
1253 {
1254         struct rpccli_samr_OpenDomain_state *state = tevent_req_data(
1255                 req, struct rpccli_samr_OpenDomain_state);
1256         NTSTATUS status;
1257
1258         if (tevent_req_is_nterror(req, &status)) {
1259                 tevent_req_received(req);
1260                 return status;
1261         }
1262
1263         /* Steal possbile out parameters to the callers context */
1264         talloc_steal(mem_ctx, state->out_mem_ctx);
1265
1266         /* Return result */
1267         *result = state->orig.out.result;
1268
1269         tevent_req_received(req);
1270         return NT_STATUS_OK;
1271 }
1272
1273 NTSTATUS rpccli_samr_OpenDomain(struct rpc_pipe_client *cli,
1274                                 TALLOC_CTX *mem_ctx,
1275                                 struct policy_handle *connect_handle /* [in] [ref] */,
1276                                 uint32_t access_mask /* [in]  */,
1277                                 struct dom_sid2 *sid /* [in] [ref] */,
1278                                 struct policy_handle *domain_handle /* [out] [ref] */)
1279 {
1280         struct samr_OpenDomain r;
1281         NTSTATUS status;
1282
1283         /* In parameters */
1284         r.in.connect_handle = connect_handle;
1285         r.in.access_mask = access_mask;
1286         r.in.sid = sid;
1287
1288         if (DEBUGLEVEL >= 10) {
1289                 NDR_PRINT_IN_DEBUG(samr_OpenDomain, &r);
1290         }
1291
1292         status = cli->dispatch(cli,
1293                                 mem_ctx,
1294                                 &ndr_table_samr,
1295                                 NDR_SAMR_OPENDOMAIN,
1296                                 &r);
1297
1298         if (!NT_STATUS_IS_OK(status)) {
1299                 return status;
1300         }
1301
1302         if (DEBUGLEVEL >= 10) {
1303                 NDR_PRINT_OUT_DEBUG(samr_OpenDomain, &r);
1304         }
1305
1306         if (NT_STATUS_IS_ERR(status)) {
1307                 return status;
1308         }
1309
1310         /* Return variables */
1311         *domain_handle = *r.out.domain_handle;
1312
1313         /* Return result */
1314         return r.out.result;
1315 }
1316
1317 struct rpccli_samr_QueryDomainInfo_state {
1318         struct samr_QueryDomainInfo orig;
1319         struct samr_QueryDomainInfo tmp;
1320         TALLOC_CTX *out_mem_ctx;
1321         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1322 };
1323
1324 static void rpccli_samr_QueryDomainInfo_done(struct tevent_req *subreq);
1325
1326 struct tevent_req *rpccli_samr_QueryDomainInfo_send(TALLOC_CTX *mem_ctx,
1327                                                     struct tevent_context *ev,
1328                                                     struct rpc_pipe_client *cli,
1329                                                     struct policy_handle *_domain_handle /* [in] [ref] */,
1330                                                     enum samr_DomainInfoClass _level /* [in]  */,
1331                                                     union samr_DomainInfo **_info /* [out] [ref,switch_is(level)] */)
1332 {
1333         struct tevent_req *req;
1334         struct rpccli_samr_QueryDomainInfo_state *state;
1335         struct tevent_req *subreq;
1336
1337         req = tevent_req_create(mem_ctx, &state,
1338                                 struct rpccli_samr_QueryDomainInfo_state);
1339         if (req == NULL) {
1340                 return NULL;
1341         }
1342         state->out_mem_ctx = NULL;
1343         state->dispatch_recv = cli->dispatch_recv;
1344
1345         /* In parameters */
1346         state->orig.in.domain_handle = _domain_handle;
1347         state->orig.in.level = _level;
1348
1349         /* Out parameters */
1350         state->orig.out.info = _info;
1351
1352         /* Result */
1353         ZERO_STRUCT(state->orig.out.result);
1354
1355         if (DEBUGLEVEL >= 10) {
1356                 NDR_PRINT_IN_DEBUG(samr_QueryDomainInfo, &state->orig);
1357         }
1358
1359         state->out_mem_ctx = talloc_named_const(state, 0,
1360                              "rpccli_samr_QueryDomainInfo_out_memory");
1361         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1362                 return tevent_req_post(req, ev);
1363         }
1364
1365         /* make a temporary copy, that we pass to the dispatch function */
1366         state->tmp = state->orig;
1367
1368         subreq = cli->dispatch_send(state, ev, cli,
1369                                     &ndr_table_samr,
1370                                     NDR_SAMR_QUERYDOMAININFO,
1371                                     &state->tmp);
1372         if (tevent_req_nomem(subreq, req)) {
1373                 return tevent_req_post(req, ev);
1374         }
1375         tevent_req_set_callback(subreq, rpccli_samr_QueryDomainInfo_done, req);
1376         return req;
1377 }
1378
1379 static void rpccli_samr_QueryDomainInfo_done(struct tevent_req *subreq)
1380 {
1381         struct tevent_req *req = tevent_req_callback_data(
1382                 subreq, struct tevent_req);
1383         struct rpccli_samr_QueryDomainInfo_state *state = tevent_req_data(
1384                 req, struct rpccli_samr_QueryDomainInfo_state);
1385         NTSTATUS status;
1386         TALLOC_CTX *mem_ctx;
1387
1388         if (state->out_mem_ctx) {
1389                 mem_ctx = state->out_mem_ctx;
1390         } else {
1391                 mem_ctx = state;
1392         }
1393
1394         status = state->dispatch_recv(subreq, mem_ctx);
1395         TALLOC_FREE(subreq);
1396         if (!NT_STATUS_IS_OK(status)) {
1397                 tevent_req_nterror(req, status);
1398                 return;
1399         }
1400
1401         /* Copy out parameters */
1402         *state->orig.out.info = *state->tmp.out.info;
1403
1404         /* Copy result */
1405         state->orig.out.result = state->tmp.out.result;
1406
1407         /* Reset temporary structure */
1408         ZERO_STRUCT(state->tmp);
1409
1410         if (DEBUGLEVEL >= 10) {
1411                 NDR_PRINT_OUT_DEBUG(samr_QueryDomainInfo, &state->orig);
1412         }
1413
1414         tevent_req_done(req);
1415 }
1416
1417 NTSTATUS rpccli_samr_QueryDomainInfo_recv(struct tevent_req *req,
1418                                           TALLOC_CTX *mem_ctx,
1419                                           NTSTATUS *result)
1420 {
1421         struct rpccli_samr_QueryDomainInfo_state *state = tevent_req_data(
1422                 req, struct rpccli_samr_QueryDomainInfo_state);
1423         NTSTATUS status;
1424
1425         if (tevent_req_is_nterror(req, &status)) {
1426                 tevent_req_received(req);
1427                 return status;
1428         }
1429
1430         /* Steal possbile out parameters to the callers context */
1431         talloc_steal(mem_ctx, state->out_mem_ctx);
1432
1433         /* Return result */
1434         *result = state->orig.out.result;
1435
1436         tevent_req_received(req);
1437         return NT_STATUS_OK;
1438 }
1439
1440 NTSTATUS rpccli_samr_QueryDomainInfo(struct rpc_pipe_client *cli,
1441                                      TALLOC_CTX *mem_ctx,
1442                                      struct policy_handle *domain_handle /* [in] [ref] */,
1443                                      enum samr_DomainInfoClass level /* [in]  */,
1444                                      union samr_DomainInfo **info /* [out] [ref,switch_is(level)] */)
1445 {
1446         struct samr_QueryDomainInfo r;
1447         NTSTATUS status;
1448
1449         /* In parameters */
1450         r.in.domain_handle = domain_handle;
1451         r.in.level = level;
1452
1453         if (DEBUGLEVEL >= 10) {
1454                 NDR_PRINT_IN_DEBUG(samr_QueryDomainInfo, &r);
1455         }
1456
1457         status = cli->dispatch(cli,
1458                                 mem_ctx,
1459                                 &ndr_table_samr,
1460                                 NDR_SAMR_QUERYDOMAININFO,
1461                                 &r);
1462
1463         if (!NT_STATUS_IS_OK(status)) {
1464                 return status;
1465         }
1466
1467         if (DEBUGLEVEL >= 10) {
1468                 NDR_PRINT_OUT_DEBUG(samr_QueryDomainInfo, &r);
1469         }
1470
1471         if (NT_STATUS_IS_ERR(status)) {
1472                 return status;
1473         }
1474
1475         /* Return variables */
1476         *info = *r.out.info;
1477
1478         /* Return result */
1479         return r.out.result;
1480 }
1481
1482 struct rpccli_samr_SetDomainInfo_state {
1483         struct samr_SetDomainInfo orig;
1484         struct samr_SetDomainInfo tmp;
1485         TALLOC_CTX *out_mem_ctx;
1486         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1487 };
1488
1489 static void rpccli_samr_SetDomainInfo_done(struct tevent_req *subreq);
1490
1491 struct tevent_req *rpccli_samr_SetDomainInfo_send(TALLOC_CTX *mem_ctx,
1492                                                   struct tevent_context *ev,
1493                                                   struct rpc_pipe_client *cli,
1494                                                   struct policy_handle *_domain_handle /* [in] [ref] */,
1495                                                   enum samr_DomainInfoClass _level /* [in]  */,
1496                                                   union samr_DomainInfo *_info /* [in] [ref,switch_is(level)] */)
1497 {
1498         struct tevent_req *req;
1499         struct rpccli_samr_SetDomainInfo_state *state;
1500         struct tevent_req *subreq;
1501
1502         req = tevent_req_create(mem_ctx, &state,
1503                                 struct rpccli_samr_SetDomainInfo_state);
1504         if (req == NULL) {
1505                 return NULL;
1506         }
1507         state->out_mem_ctx = NULL;
1508         state->dispatch_recv = cli->dispatch_recv;
1509
1510         /* In parameters */
1511         state->orig.in.domain_handle = _domain_handle;
1512         state->orig.in.level = _level;
1513         state->orig.in.info = _info;
1514
1515         /* Out parameters */
1516
1517         /* Result */
1518         ZERO_STRUCT(state->orig.out.result);
1519
1520         if (DEBUGLEVEL >= 10) {
1521                 NDR_PRINT_IN_DEBUG(samr_SetDomainInfo, &state->orig);
1522         }
1523
1524         /* make a temporary copy, that we pass to the dispatch function */
1525         state->tmp = state->orig;
1526
1527         subreq = cli->dispatch_send(state, ev, cli,
1528                                     &ndr_table_samr,
1529                                     NDR_SAMR_SETDOMAININFO,
1530                                     &state->tmp);
1531         if (tevent_req_nomem(subreq, req)) {
1532                 return tevent_req_post(req, ev);
1533         }
1534         tevent_req_set_callback(subreq, rpccli_samr_SetDomainInfo_done, req);
1535         return req;
1536 }
1537
1538 static void rpccli_samr_SetDomainInfo_done(struct tevent_req *subreq)
1539 {
1540         struct tevent_req *req = tevent_req_callback_data(
1541                 subreq, struct tevent_req);
1542         struct rpccli_samr_SetDomainInfo_state *state = tevent_req_data(
1543                 req, struct rpccli_samr_SetDomainInfo_state);
1544         NTSTATUS status;
1545         TALLOC_CTX *mem_ctx;
1546
1547         if (state->out_mem_ctx) {
1548                 mem_ctx = state->out_mem_ctx;
1549         } else {
1550                 mem_ctx = state;
1551         }
1552
1553         status = state->dispatch_recv(subreq, mem_ctx);
1554         TALLOC_FREE(subreq);
1555         if (!NT_STATUS_IS_OK(status)) {
1556                 tevent_req_nterror(req, status);
1557                 return;
1558         }
1559
1560         /* Copy out parameters */
1561
1562         /* Copy result */
1563         state->orig.out.result = state->tmp.out.result;
1564
1565         /* Reset temporary structure */
1566         ZERO_STRUCT(state->tmp);
1567
1568         if (DEBUGLEVEL >= 10) {
1569                 NDR_PRINT_OUT_DEBUG(samr_SetDomainInfo, &state->orig);
1570         }
1571
1572         tevent_req_done(req);
1573 }
1574
1575 NTSTATUS rpccli_samr_SetDomainInfo_recv(struct tevent_req *req,
1576                                         TALLOC_CTX *mem_ctx,
1577                                         NTSTATUS *result)
1578 {
1579         struct rpccli_samr_SetDomainInfo_state *state = tevent_req_data(
1580                 req, struct rpccli_samr_SetDomainInfo_state);
1581         NTSTATUS status;
1582
1583         if (tevent_req_is_nterror(req, &status)) {
1584                 tevent_req_received(req);
1585                 return status;
1586         }
1587
1588         /* Steal possbile out parameters to the callers context */
1589         talloc_steal(mem_ctx, state->out_mem_ctx);
1590
1591         /* Return result */
1592         *result = state->orig.out.result;
1593
1594         tevent_req_received(req);
1595         return NT_STATUS_OK;
1596 }
1597
1598 NTSTATUS rpccli_samr_SetDomainInfo(struct rpc_pipe_client *cli,
1599                                    TALLOC_CTX *mem_ctx,
1600                                    struct policy_handle *domain_handle /* [in] [ref] */,
1601                                    enum samr_DomainInfoClass level /* [in]  */,
1602                                    union samr_DomainInfo *info /* [in] [ref,switch_is(level)] */)
1603 {
1604         struct samr_SetDomainInfo r;
1605         NTSTATUS status;
1606
1607         /* In parameters */
1608         r.in.domain_handle = domain_handle;
1609         r.in.level = level;
1610         r.in.info = info;
1611
1612         if (DEBUGLEVEL >= 10) {
1613                 NDR_PRINT_IN_DEBUG(samr_SetDomainInfo, &r);
1614         }
1615
1616         status = cli->dispatch(cli,
1617                                 mem_ctx,
1618                                 &ndr_table_samr,
1619                                 NDR_SAMR_SETDOMAININFO,
1620                                 &r);
1621
1622         if (!NT_STATUS_IS_OK(status)) {
1623                 return status;
1624         }
1625
1626         if (DEBUGLEVEL >= 10) {
1627                 NDR_PRINT_OUT_DEBUG(samr_SetDomainInfo, &r);
1628         }
1629
1630         if (NT_STATUS_IS_ERR(status)) {
1631                 return status;
1632         }
1633
1634         /* Return variables */
1635
1636         /* Return result */
1637         return r.out.result;
1638 }
1639
1640 struct rpccli_samr_CreateDomainGroup_state {
1641         struct samr_CreateDomainGroup orig;
1642         struct samr_CreateDomainGroup tmp;
1643         TALLOC_CTX *out_mem_ctx;
1644         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1645 };
1646
1647 static void rpccli_samr_CreateDomainGroup_done(struct tevent_req *subreq);
1648
1649 struct tevent_req *rpccli_samr_CreateDomainGroup_send(TALLOC_CTX *mem_ctx,
1650                                                       struct tevent_context *ev,
1651                                                       struct rpc_pipe_client *cli,
1652                                                       struct policy_handle *_domain_handle /* [in] [ref] */,
1653                                                       struct lsa_String *_name /* [in] [ref] */,
1654                                                       uint32_t _access_mask /* [in]  */,
1655                                                       struct policy_handle *_group_handle /* [out] [ref] */,
1656                                                       uint32_t *_rid /* [out] [ref] */)
1657 {
1658         struct tevent_req *req;
1659         struct rpccli_samr_CreateDomainGroup_state *state;
1660         struct tevent_req *subreq;
1661
1662         req = tevent_req_create(mem_ctx, &state,
1663                                 struct rpccli_samr_CreateDomainGroup_state);
1664         if (req == NULL) {
1665                 return NULL;
1666         }
1667         state->out_mem_ctx = NULL;
1668         state->dispatch_recv = cli->dispatch_recv;
1669
1670         /* In parameters */
1671         state->orig.in.domain_handle = _domain_handle;
1672         state->orig.in.name = _name;
1673         state->orig.in.access_mask = _access_mask;
1674
1675         /* Out parameters */
1676         state->orig.out.group_handle = _group_handle;
1677         state->orig.out.rid = _rid;
1678
1679         /* Result */
1680         ZERO_STRUCT(state->orig.out.result);
1681
1682         if (DEBUGLEVEL >= 10) {
1683                 NDR_PRINT_IN_DEBUG(samr_CreateDomainGroup, &state->orig);
1684         }
1685
1686         state->out_mem_ctx = talloc_named_const(state, 0,
1687                              "rpccli_samr_CreateDomainGroup_out_memory");
1688         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1689                 return tevent_req_post(req, ev);
1690         }
1691
1692         /* make a temporary copy, that we pass to the dispatch function */
1693         state->tmp = state->orig;
1694
1695         subreq = cli->dispatch_send(state, ev, cli,
1696                                     &ndr_table_samr,
1697                                     NDR_SAMR_CREATEDOMAINGROUP,
1698                                     &state->tmp);
1699         if (tevent_req_nomem(subreq, req)) {
1700                 return tevent_req_post(req, ev);
1701         }
1702         tevent_req_set_callback(subreq, rpccli_samr_CreateDomainGroup_done, req);
1703         return req;
1704 }
1705
1706 static void rpccli_samr_CreateDomainGroup_done(struct tevent_req *subreq)
1707 {
1708         struct tevent_req *req = tevent_req_callback_data(
1709                 subreq, struct tevent_req);
1710         struct rpccli_samr_CreateDomainGroup_state *state = tevent_req_data(
1711                 req, struct rpccli_samr_CreateDomainGroup_state);
1712         NTSTATUS status;
1713         TALLOC_CTX *mem_ctx;
1714
1715         if (state->out_mem_ctx) {
1716                 mem_ctx = state->out_mem_ctx;
1717         } else {
1718                 mem_ctx = state;
1719         }
1720
1721         status = state->dispatch_recv(subreq, mem_ctx);
1722         TALLOC_FREE(subreq);
1723         if (!NT_STATUS_IS_OK(status)) {
1724                 tevent_req_nterror(req, status);
1725                 return;
1726         }
1727
1728         /* Copy out parameters */
1729         *state->orig.out.group_handle = *state->tmp.out.group_handle;
1730         *state->orig.out.rid = *state->tmp.out.rid;
1731
1732         /* Copy result */
1733         state->orig.out.result = state->tmp.out.result;
1734
1735         /* Reset temporary structure */
1736         ZERO_STRUCT(state->tmp);
1737
1738         if (DEBUGLEVEL >= 10) {
1739                 NDR_PRINT_OUT_DEBUG(samr_CreateDomainGroup, &state->orig);
1740         }
1741
1742         tevent_req_done(req);
1743 }
1744
1745 NTSTATUS rpccli_samr_CreateDomainGroup_recv(struct tevent_req *req,
1746                                             TALLOC_CTX *mem_ctx,
1747                                             NTSTATUS *result)
1748 {
1749         struct rpccli_samr_CreateDomainGroup_state *state = tevent_req_data(
1750                 req, struct rpccli_samr_CreateDomainGroup_state);
1751         NTSTATUS status;
1752
1753         if (tevent_req_is_nterror(req, &status)) {
1754                 tevent_req_received(req);
1755                 return status;
1756         }
1757
1758         /* Steal possbile out parameters to the callers context */
1759         talloc_steal(mem_ctx, state->out_mem_ctx);
1760
1761         /* Return result */
1762         *result = state->orig.out.result;
1763
1764         tevent_req_received(req);
1765         return NT_STATUS_OK;
1766 }
1767
1768 NTSTATUS rpccli_samr_CreateDomainGroup(struct rpc_pipe_client *cli,
1769                                        TALLOC_CTX *mem_ctx,
1770                                        struct policy_handle *domain_handle /* [in] [ref] */,
1771                                        struct lsa_String *name /* [in] [ref] */,
1772                                        uint32_t access_mask /* [in]  */,
1773                                        struct policy_handle *group_handle /* [out] [ref] */,
1774                                        uint32_t *rid /* [out] [ref] */)
1775 {
1776         struct samr_CreateDomainGroup r;
1777         NTSTATUS status;
1778
1779         /* In parameters */
1780         r.in.domain_handle = domain_handle;
1781         r.in.name = name;
1782         r.in.access_mask = access_mask;
1783
1784         if (DEBUGLEVEL >= 10) {
1785                 NDR_PRINT_IN_DEBUG(samr_CreateDomainGroup, &r);
1786         }
1787
1788         status = cli->dispatch(cli,
1789                                 mem_ctx,
1790                                 &ndr_table_samr,
1791                                 NDR_SAMR_CREATEDOMAINGROUP,
1792                                 &r);
1793
1794         if (!NT_STATUS_IS_OK(status)) {
1795                 return status;
1796         }
1797
1798         if (DEBUGLEVEL >= 10) {
1799                 NDR_PRINT_OUT_DEBUG(samr_CreateDomainGroup, &r);
1800         }
1801
1802         if (NT_STATUS_IS_ERR(status)) {
1803                 return status;
1804         }
1805
1806         /* Return variables */
1807         *group_handle = *r.out.group_handle;
1808         *rid = *r.out.rid;
1809
1810         /* Return result */
1811         return r.out.result;
1812 }
1813
1814 struct rpccli_samr_EnumDomainGroups_state {
1815         struct samr_EnumDomainGroups orig;
1816         struct samr_EnumDomainGroups tmp;
1817         TALLOC_CTX *out_mem_ctx;
1818         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1819 };
1820
1821 static void rpccli_samr_EnumDomainGroups_done(struct tevent_req *subreq);
1822
1823 struct tevent_req *rpccli_samr_EnumDomainGroups_send(TALLOC_CTX *mem_ctx,
1824                                                      struct tevent_context *ev,
1825                                                      struct rpc_pipe_client *cli,
1826                                                      struct policy_handle *_domain_handle /* [in] [ref] */,
1827                                                      uint32_t *_resume_handle /* [in,out] [ref] */,
1828                                                      struct samr_SamArray **_sam /* [out] [ref] */,
1829                                                      uint32_t _max_size /* [in]  */,
1830                                                      uint32_t *_num_entries /* [out] [ref] */)
1831 {
1832         struct tevent_req *req;
1833         struct rpccli_samr_EnumDomainGroups_state *state;
1834         struct tevent_req *subreq;
1835
1836         req = tevent_req_create(mem_ctx, &state,
1837                                 struct rpccli_samr_EnumDomainGroups_state);
1838         if (req == NULL) {
1839                 return NULL;
1840         }
1841         state->out_mem_ctx = NULL;
1842         state->dispatch_recv = cli->dispatch_recv;
1843
1844         /* In parameters */
1845         state->orig.in.domain_handle = _domain_handle;
1846         state->orig.in.resume_handle = _resume_handle;
1847         state->orig.in.max_size = _max_size;
1848
1849         /* Out parameters */
1850         state->orig.out.resume_handle = _resume_handle;
1851         state->orig.out.sam = _sam;
1852         state->orig.out.num_entries = _num_entries;
1853
1854         /* Result */
1855         ZERO_STRUCT(state->orig.out.result);
1856
1857         if (DEBUGLEVEL >= 10) {
1858                 NDR_PRINT_IN_DEBUG(samr_EnumDomainGroups, &state->orig);
1859         }
1860
1861         state->out_mem_ctx = talloc_named_const(state, 0,
1862                              "rpccli_samr_EnumDomainGroups_out_memory");
1863         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1864                 return tevent_req_post(req, ev);
1865         }
1866
1867         /* make a temporary copy, that we pass to the dispatch function */
1868         state->tmp = state->orig;
1869
1870         subreq = cli->dispatch_send(state, ev, cli,
1871                                     &ndr_table_samr,
1872                                     NDR_SAMR_ENUMDOMAINGROUPS,
1873                                     &state->tmp);
1874         if (tevent_req_nomem(subreq, req)) {
1875                 return tevent_req_post(req, ev);
1876         }
1877         tevent_req_set_callback(subreq, rpccli_samr_EnumDomainGroups_done, req);
1878         return req;
1879 }
1880
1881 static void rpccli_samr_EnumDomainGroups_done(struct tevent_req *subreq)
1882 {
1883         struct tevent_req *req = tevent_req_callback_data(
1884                 subreq, struct tevent_req);
1885         struct rpccli_samr_EnumDomainGroups_state *state = tevent_req_data(
1886                 req, struct rpccli_samr_EnumDomainGroups_state);
1887         NTSTATUS status;
1888         TALLOC_CTX *mem_ctx;
1889
1890         if (state->out_mem_ctx) {
1891                 mem_ctx = state->out_mem_ctx;
1892         } else {
1893                 mem_ctx = state;
1894         }
1895
1896         status = state->dispatch_recv(subreq, mem_ctx);
1897         TALLOC_FREE(subreq);
1898         if (!NT_STATUS_IS_OK(status)) {
1899                 tevent_req_nterror(req, status);
1900                 return;
1901         }
1902
1903         /* Copy out parameters */
1904         *state->orig.out.resume_handle = *state->tmp.out.resume_handle;
1905         *state->orig.out.sam = *state->tmp.out.sam;
1906         *state->orig.out.num_entries = *state->tmp.out.num_entries;
1907
1908         /* Copy result */
1909         state->orig.out.result = state->tmp.out.result;
1910
1911         /* Reset temporary structure */
1912         ZERO_STRUCT(state->tmp);
1913
1914         if (DEBUGLEVEL >= 10) {
1915                 NDR_PRINT_OUT_DEBUG(samr_EnumDomainGroups, &state->orig);
1916         }
1917
1918         tevent_req_done(req);
1919 }
1920
1921 NTSTATUS rpccli_samr_EnumDomainGroups_recv(struct tevent_req *req,
1922                                            TALLOC_CTX *mem_ctx,
1923                                            NTSTATUS *result)
1924 {
1925         struct rpccli_samr_EnumDomainGroups_state *state = tevent_req_data(
1926                 req, struct rpccli_samr_EnumDomainGroups_state);
1927         NTSTATUS status;
1928
1929         if (tevent_req_is_nterror(req, &status)) {
1930                 tevent_req_received(req);
1931                 return status;
1932         }
1933
1934         /* Steal possbile out parameters to the callers context */
1935         talloc_steal(mem_ctx, state->out_mem_ctx);
1936
1937         /* Return result */
1938         *result = state->orig.out.result;
1939
1940         tevent_req_received(req);
1941         return NT_STATUS_OK;
1942 }
1943
1944 NTSTATUS rpccli_samr_EnumDomainGroups(struct rpc_pipe_client *cli,
1945                                       TALLOC_CTX *mem_ctx,
1946                                       struct policy_handle *domain_handle /* [in] [ref] */,
1947                                       uint32_t *resume_handle /* [in,out] [ref] */,
1948                                       struct samr_SamArray **sam /* [out] [ref] */,
1949                                       uint32_t max_size /* [in]  */,
1950                                       uint32_t *num_entries /* [out] [ref] */)
1951 {
1952         struct samr_EnumDomainGroups r;
1953         NTSTATUS status;
1954
1955         /* In parameters */
1956         r.in.domain_handle = domain_handle;
1957         r.in.resume_handle = resume_handle;
1958         r.in.max_size = max_size;
1959
1960         if (DEBUGLEVEL >= 10) {
1961                 NDR_PRINT_IN_DEBUG(samr_EnumDomainGroups, &r);
1962         }
1963
1964         status = cli->dispatch(cli,
1965                                 mem_ctx,
1966                                 &ndr_table_samr,
1967                                 NDR_SAMR_ENUMDOMAINGROUPS,
1968                                 &r);
1969
1970         if (!NT_STATUS_IS_OK(status)) {
1971                 return status;
1972         }
1973
1974         if (DEBUGLEVEL >= 10) {
1975                 NDR_PRINT_OUT_DEBUG(samr_EnumDomainGroups, &r);
1976         }
1977
1978         if (NT_STATUS_IS_ERR(status)) {
1979                 return status;
1980         }
1981
1982         /* Return variables */
1983         *resume_handle = *r.out.resume_handle;
1984         *sam = *r.out.sam;
1985         *num_entries = *r.out.num_entries;
1986
1987         /* Return result */
1988         return r.out.result;
1989 }
1990
1991 struct rpccli_samr_CreateUser_state {
1992         struct samr_CreateUser orig;
1993         struct samr_CreateUser tmp;
1994         TALLOC_CTX *out_mem_ctx;
1995         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1996 };
1997
1998 static void rpccli_samr_CreateUser_done(struct tevent_req *subreq);
1999
2000 struct tevent_req *rpccli_samr_CreateUser_send(TALLOC_CTX *mem_ctx,
2001                                                struct tevent_context *ev,
2002                                                struct rpc_pipe_client *cli,
2003                                                struct policy_handle *_domain_handle /* [in] [ref] */,
2004                                                struct lsa_String *_account_name /* [in] [ref] */,
2005                                                uint32_t _access_mask /* [in]  */,
2006                                                struct policy_handle *_user_handle /* [out] [ref] */,
2007                                                uint32_t *_rid /* [out] [ref] */)
2008 {
2009         struct tevent_req *req;
2010         struct rpccli_samr_CreateUser_state *state;
2011         struct tevent_req *subreq;
2012
2013         req = tevent_req_create(mem_ctx, &state,
2014                                 struct rpccli_samr_CreateUser_state);
2015         if (req == NULL) {
2016                 return NULL;
2017         }
2018         state->out_mem_ctx = NULL;
2019         state->dispatch_recv = cli->dispatch_recv;
2020
2021         /* In parameters */
2022         state->orig.in.domain_handle = _domain_handle;
2023         state->orig.in.account_name = _account_name;
2024         state->orig.in.access_mask = _access_mask;
2025
2026         /* Out parameters */
2027         state->orig.out.user_handle = _user_handle;
2028         state->orig.out.rid = _rid;
2029
2030         /* Result */
2031         ZERO_STRUCT(state->orig.out.result);
2032
2033         if (DEBUGLEVEL >= 10) {
2034                 NDR_PRINT_IN_DEBUG(samr_CreateUser, &state->orig);
2035         }
2036
2037         state->out_mem_ctx = talloc_named_const(state, 0,
2038                              "rpccli_samr_CreateUser_out_memory");
2039         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2040                 return tevent_req_post(req, ev);
2041         }
2042
2043         /* make a temporary copy, that we pass to the dispatch function */
2044         state->tmp = state->orig;
2045
2046         subreq = cli->dispatch_send(state, ev, cli,
2047                                     &ndr_table_samr,
2048                                     NDR_SAMR_CREATEUSER,
2049                                     &state->tmp);
2050         if (tevent_req_nomem(subreq, req)) {
2051                 return tevent_req_post(req, ev);
2052         }
2053         tevent_req_set_callback(subreq, rpccli_samr_CreateUser_done, req);
2054         return req;
2055 }
2056
2057 static void rpccli_samr_CreateUser_done(struct tevent_req *subreq)
2058 {
2059         struct tevent_req *req = tevent_req_callback_data(
2060                 subreq, struct tevent_req);
2061         struct rpccli_samr_CreateUser_state *state = tevent_req_data(
2062                 req, struct rpccli_samr_CreateUser_state);
2063         NTSTATUS status;
2064         TALLOC_CTX *mem_ctx;
2065
2066         if (state->out_mem_ctx) {
2067                 mem_ctx = state->out_mem_ctx;
2068         } else {
2069                 mem_ctx = state;
2070         }
2071
2072         status = state->dispatch_recv(subreq, mem_ctx);
2073         TALLOC_FREE(subreq);
2074         if (!NT_STATUS_IS_OK(status)) {
2075                 tevent_req_nterror(req, status);
2076                 return;
2077         }
2078
2079         /* Copy out parameters */
2080         *state->orig.out.user_handle = *state->tmp.out.user_handle;
2081         *state->orig.out.rid = *state->tmp.out.rid;
2082
2083         /* Copy result */
2084         state->orig.out.result = state->tmp.out.result;
2085
2086         /* Reset temporary structure */
2087         ZERO_STRUCT(state->tmp);
2088
2089         if (DEBUGLEVEL >= 10) {
2090                 NDR_PRINT_OUT_DEBUG(samr_CreateUser, &state->orig);
2091         }
2092
2093         tevent_req_done(req);
2094 }
2095
2096 NTSTATUS rpccli_samr_CreateUser_recv(struct tevent_req *req,
2097                                      TALLOC_CTX *mem_ctx,
2098                                      NTSTATUS *result)
2099 {
2100         struct rpccli_samr_CreateUser_state *state = tevent_req_data(
2101                 req, struct rpccli_samr_CreateUser_state);
2102         NTSTATUS status;
2103
2104         if (tevent_req_is_nterror(req, &status)) {
2105                 tevent_req_received(req);
2106                 return status;
2107         }
2108
2109         /* Steal possbile out parameters to the callers context */
2110         talloc_steal(mem_ctx, state->out_mem_ctx);
2111
2112         /* Return result */
2113         *result = state->orig.out.result;
2114
2115         tevent_req_received(req);
2116         return NT_STATUS_OK;
2117 }
2118
2119 NTSTATUS rpccli_samr_CreateUser(struct rpc_pipe_client *cli,
2120                                 TALLOC_CTX *mem_ctx,
2121                                 struct policy_handle *domain_handle /* [in] [ref] */,
2122                                 struct lsa_String *account_name /* [in] [ref] */,
2123                                 uint32_t access_mask /* [in]  */,
2124                                 struct policy_handle *user_handle /* [out] [ref] */,
2125                                 uint32_t *rid /* [out] [ref] */)
2126 {
2127         struct samr_CreateUser r;
2128         NTSTATUS status;
2129
2130         /* In parameters */
2131         r.in.domain_handle = domain_handle;
2132         r.in.account_name = account_name;
2133         r.in.access_mask = access_mask;
2134
2135         if (DEBUGLEVEL >= 10) {
2136                 NDR_PRINT_IN_DEBUG(samr_CreateUser, &r);
2137         }
2138
2139         status = cli->dispatch(cli,
2140                                 mem_ctx,
2141                                 &ndr_table_samr,
2142                                 NDR_SAMR_CREATEUSER,
2143                                 &r);
2144
2145         if (!NT_STATUS_IS_OK(status)) {
2146                 return status;
2147         }
2148
2149         if (DEBUGLEVEL >= 10) {
2150                 NDR_PRINT_OUT_DEBUG(samr_CreateUser, &r);
2151         }
2152
2153         if (NT_STATUS_IS_ERR(status)) {
2154                 return status;
2155         }
2156
2157         /* Return variables */
2158         *user_handle = *r.out.user_handle;
2159         *rid = *r.out.rid;
2160
2161         /* Return result */
2162         return r.out.result;
2163 }
2164
2165 struct rpccli_samr_EnumDomainUsers_state {
2166         struct samr_EnumDomainUsers orig;
2167         struct samr_EnumDomainUsers tmp;
2168         TALLOC_CTX *out_mem_ctx;
2169         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2170 };
2171
2172 static void rpccli_samr_EnumDomainUsers_done(struct tevent_req *subreq);
2173
2174 struct tevent_req *rpccli_samr_EnumDomainUsers_send(TALLOC_CTX *mem_ctx,
2175                                                     struct tevent_context *ev,
2176                                                     struct rpc_pipe_client *cli,
2177                                                     struct policy_handle *_domain_handle /* [in] [ref] */,
2178                                                     uint32_t *_resume_handle /* [in,out] [ref] */,
2179                                                     uint32_t _acct_flags /* [in]  */,
2180                                                     struct samr_SamArray **_sam /* [out] [ref] */,
2181                                                     uint32_t _max_size /* [in]  */,
2182                                                     uint32_t *_num_entries /* [out] [ref] */)
2183 {
2184         struct tevent_req *req;
2185         struct rpccli_samr_EnumDomainUsers_state *state;
2186         struct tevent_req *subreq;
2187
2188         req = tevent_req_create(mem_ctx, &state,
2189                                 struct rpccli_samr_EnumDomainUsers_state);
2190         if (req == NULL) {
2191                 return NULL;
2192         }
2193         state->out_mem_ctx = NULL;
2194         state->dispatch_recv = cli->dispatch_recv;
2195
2196         /* In parameters */
2197         state->orig.in.domain_handle = _domain_handle;
2198         state->orig.in.resume_handle = _resume_handle;
2199         state->orig.in.acct_flags = _acct_flags;
2200         state->orig.in.max_size = _max_size;
2201
2202         /* Out parameters */
2203         state->orig.out.resume_handle = _resume_handle;
2204         state->orig.out.sam = _sam;
2205         state->orig.out.num_entries = _num_entries;
2206
2207         /* Result */
2208         ZERO_STRUCT(state->orig.out.result);
2209
2210         if (DEBUGLEVEL >= 10) {
2211                 NDR_PRINT_IN_DEBUG(samr_EnumDomainUsers, &state->orig);
2212         }
2213
2214         state->out_mem_ctx = talloc_named_const(state, 0,
2215                              "rpccli_samr_EnumDomainUsers_out_memory");
2216         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2217                 return tevent_req_post(req, ev);
2218         }
2219
2220         /* make a temporary copy, that we pass to the dispatch function */
2221         state->tmp = state->orig;
2222
2223         subreq = cli->dispatch_send(state, ev, cli,
2224                                     &ndr_table_samr,
2225                                     NDR_SAMR_ENUMDOMAINUSERS,
2226                                     &state->tmp);
2227         if (tevent_req_nomem(subreq, req)) {
2228                 return tevent_req_post(req, ev);
2229         }
2230         tevent_req_set_callback(subreq, rpccli_samr_EnumDomainUsers_done, req);
2231         return req;
2232 }
2233
2234 static void rpccli_samr_EnumDomainUsers_done(struct tevent_req *subreq)
2235 {
2236         struct tevent_req *req = tevent_req_callback_data(
2237                 subreq, struct tevent_req);
2238         struct rpccli_samr_EnumDomainUsers_state *state = tevent_req_data(
2239                 req, struct rpccli_samr_EnumDomainUsers_state);
2240         NTSTATUS status;
2241         TALLOC_CTX *mem_ctx;
2242
2243         if (state->out_mem_ctx) {
2244                 mem_ctx = state->out_mem_ctx;
2245         } else {
2246                 mem_ctx = state;
2247         }
2248
2249         status = state->dispatch_recv(subreq, mem_ctx);
2250         TALLOC_FREE(subreq);
2251         if (!NT_STATUS_IS_OK(status)) {
2252                 tevent_req_nterror(req, status);
2253                 return;
2254         }
2255
2256         /* Copy out parameters */
2257         *state->orig.out.resume_handle = *state->tmp.out.resume_handle;
2258         *state->orig.out.sam = *state->tmp.out.sam;
2259         *state->orig.out.num_entries = *state->tmp.out.num_entries;
2260
2261         /* Copy result */
2262         state->orig.out.result = state->tmp.out.result;
2263
2264         /* Reset temporary structure */
2265         ZERO_STRUCT(state->tmp);
2266
2267         if (DEBUGLEVEL >= 10) {
2268                 NDR_PRINT_OUT_DEBUG(samr_EnumDomainUsers, &state->orig);
2269         }
2270
2271         tevent_req_done(req);
2272 }
2273
2274 NTSTATUS rpccli_samr_EnumDomainUsers_recv(struct tevent_req *req,
2275                                           TALLOC_CTX *mem_ctx,
2276                                           NTSTATUS *result)
2277 {
2278         struct rpccli_samr_EnumDomainUsers_state *state = tevent_req_data(
2279                 req, struct rpccli_samr_EnumDomainUsers_state);
2280         NTSTATUS status;
2281
2282         if (tevent_req_is_nterror(req, &status)) {
2283                 tevent_req_received(req);
2284                 return status;
2285         }
2286
2287         /* Steal possbile out parameters to the callers context */
2288         talloc_steal(mem_ctx, state->out_mem_ctx);
2289
2290         /* Return result */
2291         *result = state->orig.out.result;
2292
2293         tevent_req_received(req);
2294         return NT_STATUS_OK;
2295 }
2296
2297 NTSTATUS rpccli_samr_EnumDomainUsers(struct rpc_pipe_client *cli,
2298                                      TALLOC_CTX *mem_ctx,
2299                                      struct policy_handle *domain_handle /* [in] [ref] */,
2300                                      uint32_t *resume_handle /* [in,out] [ref] */,
2301                                      uint32_t acct_flags /* [in]  */,
2302                                      struct samr_SamArray **sam /* [out] [ref] */,
2303                                      uint32_t max_size /* [in]  */,
2304                                      uint32_t *num_entries /* [out] [ref] */)
2305 {
2306         struct samr_EnumDomainUsers r;
2307         NTSTATUS status;
2308
2309         /* In parameters */
2310         r.in.domain_handle = domain_handle;
2311         r.in.resume_handle = resume_handle;
2312         r.in.acct_flags = acct_flags;
2313         r.in.max_size = max_size;
2314
2315         if (DEBUGLEVEL >= 10) {
2316                 NDR_PRINT_IN_DEBUG(samr_EnumDomainUsers, &r);
2317         }
2318
2319         status = cli->dispatch(cli,
2320                                 mem_ctx,
2321                                 &ndr_table_samr,
2322                                 NDR_SAMR_ENUMDOMAINUSERS,
2323                                 &r);
2324
2325         if (!NT_STATUS_IS_OK(status)) {
2326                 return status;
2327         }
2328
2329         if (DEBUGLEVEL >= 10) {
2330                 NDR_PRINT_OUT_DEBUG(samr_EnumDomainUsers, &r);
2331         }
2332
2333         if (NT_STATUS_IS_ERR(status)) {
2334                 return status;
2335         }
2336
2337         /* Return variables */
2338         *resume_handle = *r.out.resume_handle;
2339         *sam = *r.out.sam;
2340         *num_entries = *r.out.num_entries;
2341
2342         /* Return result */
2343         return r.out.result;
2344 }
2345
2346 struct rpccli_samr_CreateDomAlias_state {
2347         struct samr_CreateDomAlias orig;
2348         struct samr_CreateDomAlias tmp;
2349         TALLOC_CTX *out_mem_ctx;
2350         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2351 };
2352
2353 static void rpccli_samr_CreateDomAlias_done(struct tevent_req *subreq);
2354
2355 struct tevent_req *rpccli_samr_CreateDomAlias_send(TALLOC_CTX *mem_ctx,
2356                                                    struct tevent_context *ev,
2357                                                    struct rpc_pipe_client *cli,
2358                                                    struct policy_handle *_domain_handle /* [in] [ref] */,
2359                                                    struct lsa_String *_alias_name /* [in] [ref] */,
2360                                                    uint32_t _access_mask /* [in]  */,
2361                                                    struct policy_handle *_alias_handle /* [out] [ref] */,
2362                                                    uint32_t *_rid /* [out] [ref] */)
2363 {
2364         struct tevent_req *req;
2365         struct rpccli_samr_CreateDomAlias_state *state;
2366         struct tevent_req *subreq;
2367
2368         req = tevent_req_create(mem_ctx, &state,
2369                                 struct rpccli_samr_CreateDomAlias_state);
2370         if (req == NULL) {
2371                 return NULL;
2372         }
2373         state->out_mem_ctx = NULL;
2374         state->dispatch_recv = cli->dispatch_recv;
2375
2376         /* In parameters */
2377         state->orig.in.domain_handle = _domain_handle;
2378         state->orig.in.alias_name = _alias_name;
2379         state->orig.in.access_mask = _access_mask;
2380
2381         /* Out parameters */
2382         state->orig.out.alias_handle = _alias_handle;
2383         state->orig.out.rid = _rid;
2384
2385         /* Result */
2386         ZERO_STRUCT(state->orig.out.result);
2387
2388         if (DEBUGLEVEL >= 10) {
2389                 NDR_PRINT_IN_DEBUG(samr_CreateDomAlias, &state->orig);
2390         }
2391
2392         state->out_mem_ctx = talloc_named_const(state, 0,
2393                              "rpccli_samr_CreateDomAlias_out_memory");
2394         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2395                 return tevent_req_post(req, ev);
2396         }
2397
2398         /* make a temporary copy, that we pass to the dispatch function */
2399         state->tmp = state->orig;
2400
2401         subreq = cli->dispatch_send(state, ev, cli,
2402                                     &ndr_table_samr,
2403                                     NDR_SAMR_CREATEDOMALIAS,
2404                                     &state->tmp);
2405         if (tevent_req_nomem(subreq, req)) {
2406                 return tevent_req_post(req, ev);
2407         }
2408         tevent_req_set_callback(subreq, rpccli_samr_CreateDomAlias_done, req);
2409         return req;
2410 }
2411
2412 static void rpccli_samr_CreateDomAlias_done(struct tevent_req *subreq)
2413 {
2414         struct tevent_req *req = tevent_req_callback_data(
2415                 subreq, struct tevent_req);
2416         struct rpccli_samr_CreateDomAlias_state *state = tevent_req_data(
2417                 req, struct rpccli_samr_CreateDomAlias_state);
2418         NTSTATUS status;
2419         TALLOC_CTX *mem_ctx;
2420
2421         if (state->out_mem_ctx) {
2422                 mem_ctx = state->out_mem_ctx;
2423         } else {
2424                 mem_ctx = state;
2425         }
2426
2427         status = state->dispatch_recv(subreq, mem_ctx);
2428         TALLOC_FREE(subreq);
2429         if (!NT_STATUS_IS_OK(status)) {
2430                 tevent_req_nterror(req, status);
2431                 return;
2432         }
2433
2434         /* Copy out parameters */
2435         *state->orig.out.alias_handle = *state->tmp.out.alias_handle;
2436         *state->orig.out.rid = *state->tmp.out.rid;
2437
2438         /* Copy result */
2439         state->orig.out.result = state->tmp.out.result;
2440
2441         /* Reset temporary structure */
2442         ZERO_STRUCT(state->tmp);
2443
2444         if (DEBUGLEVEL >= 10) {
2445                 NDR_PRINT_OUT_DEBUG(samr_CreateDomAlias, &state->orig);
2446         }
2447
2448         tevent_req_done(req);
2449 }
2450
2451 NTSTATUS rpccli_samr_CreateDomAlias_recv(struct tevent_req *req,
2452                                          TALLOC_CTX *mem_ctx,
2453                                          NTSTATUS *result)
2454 {
2455         struct rpccli_samr_CreateDomAlias_state *state = tevent_req_data(
2456                 req, struct rpccli_samr_CreateDomAlias_state);
2457         NTSTATUS status;
2458
2459         if (tevent_req_is_nterror(req, &status)) {
2460                 tevent_req_received(req);
2461                 return status;
2462         }
2463
2464         /* Steal possbile out parameters to the callers context */
2465         talloc_steal(mem_ctx, state->out_mem_ctx);
2466
2467         /* Return result */
2468         *result = state->orig.out.result;
2469
2470         tevent_req_received(req);
2471         return NT_STATUS_OK;
2472 }
2473
2474 NTSTATUS rpccli_samr_CreateDomAlias(struct rpc_pipe_client *cli,
2475                                     TALLOC_CTX *mem_ctx,
2476                                     struct policy_handle *domain_handle /* [in] [ref] */,
2477                                     struct lsa_String *alias_name /* [in] [ref] */,
2478                                     uint32_t access_mask /* [in]  */,
2479                                     struct policy_handle *alias_handle /* [out] [ref] */,
2480                                     uint32_t *rid /* [out] [ref] */)
2481 {
2482         struct samr_CreateDomAlias r;
2483         NTSTATUS status;
2484
2485         /* In parameters */
2486         r.in.domain_handle = domain_handle;
2487         r.in.alias_name = alias_name;
2488         r.in.access_mask = access_mask;
2489
2490         if (DEBUGLEVEL >= 10) {
2491                 NDR_PRINT_IN_DEBUG(samr_CreateDomAlias, &r);
2492         }
2493
2494         status = cli->dispatch(cli,
2495                                 mem_ctx,
2496                                 &ndr_table_samr,
2497                                 NDR_SAMR_CREATEDOMALIAS,
2498                                 &r);
2499
2500         if (!NT_STATUS_IS_OK(status)) {
2501                 return status;
2502         }
2503
2504         if (DEBUGLEVEL >= 10) {
2505                 NDR_PRINT_OUT_DEBUG(samr_CreateDomAlias, &r);
2506         }
2507
2508         if (NT_STATUS_IS_ERR(status)) {
2509                 return status;
2510         }
2511
2512         /* Return variables */
2513         *alias_handle = *r.out.alias_handle;
2514         *rid = *r.out.rid;
2515
2516         /* Return result */
2517         return r.out.result;
2518 }
2519
2520 struct rpccli_samr_EnumDomainAliases_state {
2521         struct samr_EnumDomainAliases orig;
2522         struct samr_EnumDomainAliases tmp;
2523         TALLOC_CTX *out_mem_ctx;
2524         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2525 };
2526
2527 static void rpccli_samr_EnumDomainAliases_done(struct tevent_req *subreq);
2528
2529 struct tevent_req *rpccli_samr_EnumDomainAliases_send(TALLOC_CTX *mem_ctx,
2530                                                       struct tevent_context *ev,
2531                                                       struct rpc_pipe_client *cli,
2532                                                       struct policy_handle *_domain_handle /* [in] [ref] */,
2533                                                       uint32_t *_resume_handle /* [in,out] [ref] */,
2534                                                       struct samr_SamArray **_sam /* [out] [ref] */,
2535                                                       uint32_t _max_size /* [in]  */,
2536                                                       uint32_t *_num_entries /* [out] [ref] */)
2537 {
2538         struct tevent_req *req;
2539         struct rpccli_samr_EnumDomainAliases_state *state;
2540         struct tevent_req *subreq;
2541
2542         req = tevent_req_create(mem_ctx, &state,
2543                                 struct rpccli_samr_EnumDomainAliases_state);
2544         if (req == NULL) {
2545                 return NULL;
2546         }
2547         state->out_mem_ctx = NULL;
2548         state->dispatch_recv = cli->dispatch_recv;
2549
2550         /* In parameters */
2551         state->orig.in.domain_handle = _domain_handle;
2552         state->orig.in.resume_handle = _resume_handle;
2553         state->orig.in.max_size = _max_size;
2554
2555         /* Out parameters */
2556         state->orig.out.resume_handle = _resume_handle;
2557         state->orig.out.sam = _sam;
2558         state->orig.out.num_entries = _num_entries;
2559
2560         /* Result */
2561         ZERO_STRUCT(state->orig.out.result);
2562
2563         if (DEBUGLEVEL >= 10) {
2564                 NDR_PRINT_IN_DEBUG(samr_EnumDomainAliases, &state->orig);
2565         }
2566
2567         state->out_mem_ctx = talloc_named_const(state, 0,
2568                              "rpccli_samr_EnumDomainAliases_out_memory");
2569         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2570                 return tevent_req_post(req, ev);
2571         }
2572
2573         /* make a temporary copy, that we pass to the dispatch function */
2574         state->tmp = state->orig;
2575
2576         subreq = cli->dispatch_send(state, ev, cli,
2577                                     &ndr_table_samr,
2578                                     NDR_SAMR_ENUMDOMAINALIASES,
2579                                     &state->tmp);
2580         if (tevent_req_nomem(subreq, req)) {
2581                 return tevent_req_post(req, ev);
2582         }
2583         tevent_req_set_callback(subreq, rpccli_samr_EnumDomainAliases_done, req);
2584         return req;
2585 }
2586
2587 static void rpccli_samr_EnumDomainAliases_done(struct tevent_req *subreq)
2588 {
2589         struct tevent_req *req = tevent_req_callback_data(
2590                 subreq, struct tevent_req);
2591         struct rpccli_samr_EnumDomainAliases_state *state = tevent_req_data(
2592                 req, struct rpccli_samr_EnumDomainAliases_state);
2593         NTSTATUS status;
2594         TALLOC_CTX *mem_ctx;
2595
2596         if (state->out_mem_ctx) {
2597                 mem_ctx = state->out_mem_ctx;
2598         } else {
2599                 mem_ctx = state;
2600         }
2601
2602         status = state->dispatch_recv(subreq, mem_ctx);
2603         TALLOC_FREE(subreq);
2604         if (!NT_STATUS_IS_OK(status)) {
2605                 tevent_req_nterror(req, status);
2606                 return;
2607         }
2608
2609         /* Copy out parameters */
2610         *state->orig.out.resume_handle = *state->tmp.out.resume_handle;
2611         *state->orig.out.sam = *state->tmp.out.sam;
2612         *state->orig.out.num_entries = *state->tmp.out.num_entries;
2613
2614         /* Copy result */
2615         state->orig.out.result = state->tmp.out.result;
2616
2617         /* Reset temporary structure */
2618         ZERO_STRUCT(state->tmp);
2619
2620         if (DEBUGLEVEL >= 10) {
2621                 NDR_PRINT_OUT_DEBUG(samr_EnumDomainAliases, &state->orig);
2622         }
2623
2624         tevent_req_done(req);
2625 }
2626
2627 NTSTATUS rpccli_samr_EnumDomainAliases_recv(struct tevent_req *req,
2628                                             TALLOC_CTX *mem_ctx,
2629                                             NTSTATUS *result)
2630 {
2631         struct rpccli_samr_EnumDomainAliases_state *state = tevent_req_data(
2632                 req, struct rpccli_samr_EnumDomainAliases_state);
2633         NTSTATUS status;
2634
2635         if (tevent_req_is_nterror(req, &status)) {
2636                 tevent_req_received(req);
2637                 return status;
2638         }
2639
2640         /* Steal possbile out parameters to the callers context */
2641         talloc_steal(mem_ctx, state->out_mem_ctx);
2642
2643         /* Return result */
2644         *result = state->orig.out.result;
2645
2646         tevent_req_received(req);
2647         return NT_STATUS_OK;
2648 }
2649
2650 NTSTATUS rpccli_samr_EnumDomainAliases(struct rpc_pipe_client *cli,
2651                                        TALLOC_CTX *mem_ctx,
2652                                        struct policy_handle *domain_handle /* [in] [ref] */,
2653                                        uint32_t *resume_handle /* [in,out] [ref] */,
2654                                        struct samr_SamArray **sam /* [out] [ref] */,
2655                                        uint32_t max_size /* [in]  */,
2656                                        uint32_t *num_entries /* [out] [ref] */)
2657 {
2658         struct samr_EnumDomainAliases r;
2659         NTSTATUS status;
2660
2661         /* In parameters */
2662         r.in.domain_handle = domain_handle;
2663         r.in.resume_handle = resume_handle;
2664         r.in.max_size = max_size;
2665
2666         if (DEBUGLEVEL >= 10) {
2667                 NDR_PRINT_IN_DEBUG(samr_EnumDomainAliases, &r);
2668         }
2669
2670         status = cli->dispatch(cli,
2671                                 mem_ctx,
2672                                 &ndr_table_samr,
2673                                 NDR_SAMR_ENUMDOMAINALIASES,
2674                                 &r);
2675
2676         if (!NT_STATUS_IS_OK(status)) {
2677                 return status;
2678         }
2679
2680         if (DEBUGLEVEL >= 10) {
2681                 NDR_PRINT_OUT_DEBUG(samr_EnumDomainAliases, &r);
2682         }
2683
2684         if (NT_STATUS_IS_ERR(status)) {
2685                 return status;
2686         }
2687
2688         /* Return variables */
2689         *resume_handle = *r.out.resume_handle;
2690         *sam = *r.out.sam;
2691         *num_entries = *r.out.num_entries;
2692
2693         /* Return result */
2694         return r.out.result;
2695 }
2696
2697 struct rpccli_samr_GetAliasMembership_state {
2698         struct samr_GetAliasMembership orig;
2699         struct samr_GetAliasMembership tmp;
2700         TALLOC_CTX *out_mem_ctx;
2701         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2702 };
2703
2704 static void rpccli_samr_GetAliasMembership_done(struct tevent_req *subreq);
2705
2706 struct tevent_req *rpccli_samr_GetAliasMembership_send(TALLOC_CTX *mem_ctx,
2707                                                        struct tevent_context *ev,
2708                                                        struct rpc_pipe_client *cli,
2709                                                        struct policy_handle *_domain_handle /* [in] [ref] */,
2710                                                        struct lsa_SidArray *_sids /* [in] [ref] */,
2711                                                        struct samr_Ids *_rids /* [out] [ref] */)
2712 {
2713         struct tevent_req *req;
2714         struct rpccli_samr_GetAliasMembership_state *state;
2715         struct tevent_req *subreq;
2716
2717         req = tevent_req_create(mem_ctx, &state,
2718                                 struct rpccli_samr_GetAliasMembership_state);
2719         if (req == NULL) {
2720                 return NULL;
2721         }
2722         state->out_mem_ctx = NULL;
2723         state->dispatch_recv = cli->dispatch_recv;
2724
2725         /* In parameters */
2726         state->orig.in.domain_handle = _domain_handle;
2727         state->orig.in.sids = _sids;
2728
2729         /* Out parameters */
2730         state->orig.out.rids = _rids;
2731
2732         /* Result */
2733         ZERO_STRUCT(state->orig.out.result);
2734
2735         if (DEBUGLEVEL >= 10) {
2736                 NDR_PRINT_IN_DEBUG(samr_GetAliasMembership, &state->orig);
2737         }
2738
2739         state->out_mem_ctx = talloc_named_const(state, 0,
2740                              "rpccli_samr_GetAliasMembership_out_memory");
2741         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2742                 return tevent_req_post(req, ev);
2743         }
2744
2745         /* make a temporary copy, that we pass to the dispatch function */
2746         state->tmp = state->orig;
2747
2748         subreq = cli->dispatch_send(state, ev, cli,
2749                                     &ndr_table_samr,
2750                                     NDR_SAMR_GETALIASMEMBERSHIP,
2751                                     &state->tmp);
2752         if (tevent_req_nomem(subreq, req)) {
2753                 return tevent_req_post(req, ev);
2754         }
2755         tevent_req_set_callback(subreq, rpccli_samr_GetAliasMembership_done, req);
2756         return req;
2757 }
2758
2759 static void rpccli_samr_GetAliasMembership_done(struct tevent_req *subreq)
2760 {
2761         struct tevent_req *req = tevent_req_callback_data(
2762                 subreq, struct tevent_req);
2763         struct rpccli_samr_GetAliasMembership_state *state = tevent_req_data(
2764                 req, struct rpccli_samr_GetAliasMembership_state);
2765         NTSTATUS status;
2766         TALLOC_CTX *mem_ctx;
2767
2768         if (state->out_mem_ctx) {
2769                 mem_ctx = state->out_mem_ctx;
2770         } else {
2771                 mem_ctx = state;
2772         }
2773
2774         status = state->dispatch_recv(subreq, mem_ctx);
2775         TALLOC_FREE(subreq);
2776         if (!NT_STATUS_IS_OK(status)) {
2777                 tevent_req_nterror(req, status);
2778                 return;
2779         }
2780
2781         /* Copy out parameters */
2782         *state->orig.out.rids = *state->tmp.out.rids;
2783
2784         /* Copy result */
2785         state->orig.out.result = state->tmp.out.result;
2786
2787         /* Reset temporary structure */
2788         ZERO_STRUCT(state->tmp);
2789
2790         if (DEBUGLEVEL >= 10) {
2791                 NDR_PRINT_OUT_DEBUG(samr_GetAliasMembership, &state->orig);
2792         }
2793
2794         tevent_req_done(req);
2795 }
2796
2797 NTSTATUS rpccli_samr_GetAliasMembership_recv(struct tevent_req *req,
2798                                              TALLOC_CTX *mem_ctx,
2799                                              NTSTATUS *result)
2800 {
2801         struct rpccli_samr_GetAliasMembership_state *state = tevent_req_data(
2802                 req, struct rpccli_samr_GetAliasMembership_state);
2803         NTSTATUS status;
2804
2805         if (tevent_req_is_nterror(req, &status)) {
2806                 tevent_req_received(req);
2807                 return status;
2808         }
2809
2810         /* Steal possbile out parameters to the callers context */
2811         talloc_steal(mem_ctx, state->out_mem_ctx);
2812
2813         /* Return result */
2814         *result = state->orig.out.result;
2815
2816         tevent_req_received(req);
2817         return NT_STATUS_OK;
2818 }
2819
2820 NTSTATUS rpccli_samr_GetAliasMembership(struct rpc_pipe_client *cli,
2821                                         TALLOC_CTX *mem_ctx,
2822                                         struct policy_handle *domain_handle /* [in] [ref] */,
2823                                         struct lsa_SidArray *sids /* [in] [ref] */,
2824                                         struct samr_Ids *rids /* [out] [ref] */)
2825 {
2826         struct samr_GetAliasMembership r;
2827         NTSTATUS status;
2828
2829         /* In parameters */
2830         r.in.domain_handle = domain_handle;
2831         r.in.sids = sids;
2832
2833         if (DEBUGLEVEL >= 10) {
2834                 NDR_PRINT_IN_DEBUG(samr_GetAliasMembership, &r);
2835         }
2836
2837         status = cli->dispatch(cli,
2838                                 mem_ctx,
2839                                 &ndr_table_samr,
2840                                 NDR_SAMR_GETALIASMEMBERSHIP,
2841                                 &r);
2842
2843         if (!NT_STATUS_IS_OK(status)) {
2844                 return status;
2845         }
2846
2847         if (DEBUGLEVEL >= 10) {
2848                 NDR_PRINT_OUT_DEBUG(samr_GetAliasMembership, &r);
2849         }
2850
2851         if (NT_STATUS_IS_ERR(status)) {
2852                 return status;
2853         }
2854
2855         /* Return variables */
2856         *rids = *r.out.rids;
2857
2858         /* Return result */
2859         return r.out.result;
2860 }
2861
2862 struct rpccli_samr_LookupNames_state {
2863         struct samr_LookupNames orig;
2864         struct samr_LookupNames tmp;
2865         TALLOC_CTX *out_mem_ctx;
2866         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2867 };
2868
2869 static void rpccli_samr_LookupNames_done(struct tevent_req *subreq);
2870
2871 struct tevent_req *rpccli_samr_LookupNames_send(TALLOC_CTX *mem_ctx,
2872                                                 struct tevent_context *ev,
2873                                                 struct rpc_pipe_client *cli,
2874                                                 struct policy_handle *_domain_handle /* [in] [ref] */,
2875                                                 uint32_t _num_names /* [in] [range(0,1000)] */,
2876                                                 struct lsa_String *_names /* [in] [length_is(num_names),size_is(1000)] */,
2877                                                 struct samr_Ids *_rids /* [out] [ref] */,
2878                                                 struct samr_Ids *_types /* [out] [ref] */)
2879 {
2880         struct tevent_req *req;
2881         struct rpccli_samr_LookupNames_state *state;
2882         struct tevent_req *subreq;
2883
2884         req = tevent_req_create(mem_ctx, &state,
2885                                 struct rpccli_samr_LookupNames_state);
2886         if (req == NULL) {
2887                 return NULL;
2888         }
2889         state->out_mem_ctx = NULL;
2890         state->dispatch_recv = cli->dispatch_recv;
2891
2892         /* In parameters */
2893         state->orig.in.domain_handle = _domain_handle;
2894         state->orig.in.num_names = _num_names;
2895         state->orig.in.names = _names;
2896
2897         /* Out parameters */
2898         state->orig.out.rids = _rids;
2899         state->orig.out.types = _types;
2900
2901         /* Result */
2902         ZERO_STRUCT(state->orig.out.result);
2903
2904         if (DEBUGLEVEL >= 10) {
2905                 NDR_PRINT_IN_DEBUG(samr_LookupNames, &state->orig);
2906         }
2907
2908         state->out_mem_ctx = talloc_named_const(state, 0,
2909                              "rpccli_samr_LookupNames_out_memory");
2910         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2911                 return tevent_req_post(req, ev);
2912         }
2913
2914         /* make a temporary copy, that we pass to the dispatch function */
2915         state->tmp = state->orig;
2916
2917         subreq = cli->dispatch_send(state, ev, cli,
2918                                     &ndr_table_samr,
2919                                     NDR_SAMR_LOOKUPNAMES,
2920                                     &state->tmp);
2921         if (tevent_req_nomem(subreq, req)) {
2922                 return tevent_req_post(req, ev);
2923         }
2924         tevent_req_set_callback(subreq, rpccli_samr_LookupNames_done, req);
2925         return req;
2926 }
2927
2928 static void rpccli_samr_LookupNames_done(struct tevent_req *subreq)
2929 {
2930         struct tevent_req *req = tevent_req_callback_data(
2931                 subreq, struct tevent_req);
2932         struct rpccli_samr_LookupNames_state *state = tevent_req_data(
2933                 req, struct rpccli_samr_LookupNames_state);
2934         NTSTATUS status;
2935         TALLOC_CTX *mem_ctx;
2936
2937         if (state->out_mem_ctx) {
2938                 mem_ctx = state->out_mem_ctx;
2939         } else {
2940                 mem_ctx = state;
2941         }
2942
2943         status = state->dispatch_recv(subreq, mem_ctx);
2944         TALLOC_FREE(subreq);
2945         if (!NT_STATUS_IS_OK(status)) {
2946                 tevent_req_nterror(req, status);
2947                 return;
2948         }
2949
2950         /* Copy out parameters */
2951         *state->orig.out.rids = *state->tmp.out.rids;
2952         *state->orig.out.types = *state->tmp.out.types;
2953
2954         /* Copy result */
2955         state->orig.out.result = state->tmp.out.result;
2956
2957         /* Reset temporary structure */
2958         ZERO_STRUCT(state->tmp);
2959
2960         if (DEBUGLEVEL >= 10) {
2961                 NDR_PRINT_OUT_DEBUG(samr_LookupNames, &state->orig);
2962         }
2963
2964         tevent_req_done(req);
2965 }
2966
2967 NTSTATUS rpccli_samr_LookupNames_recv(struct tevent_req *req,
2968                                       TALLOC_CTX *mem_ctx,
2969                                       NTSTATUS *result)
2970 {
2971         struct rpccli_samr_LookupNames_state *state = tevent_req_data(
2972                 req, struct rpccli_samr_LookupNames_state);
2973         NTSTATUS status;
2974
2975         if (tevent_req_is_nterror(req, &status)) {
2976                 tevent_req_received(req);
2977                 return status;
2978         }
2979
2980         /* Steal possbile out parameters to the callers context */
2981         talloc_steal(mem_ctx, state->out_mem_ctx);
2982
2983         /* Return result */
2984         *result = state->orig.out.result;
2985
2986         tevent_req_received(req);
2987         return NT_STATUS_OK;
2988 }
2989
2990 NTSTATUS rpccli_samr_LookupNames(struct rpc_pipe_client *cli,
2991                                  TALLOC_CTX *mem_ctx,
2992                                  struct policy_handle *domain_handle /* [in] [ref] */,
2993                                  uint32_t num_names /* [in] [range(0,1000)] */,
2994                                  struct lsa_String *names /* [in] [length_is(num_names),size_is(1000)] */,
2995                                  struct samr_Ids *rids /* [out] [ref] */,
2996                                  struct samr_Ids *types /* [out] [ref] */)
2997 {
2998         struct samr_LookupNames r;
2999         NTSTATUS status;
3000
3001         /* In parameters */
3002         r.in.domain_handle = domain_handle;
3003         r.in.num_names = num_names;
3004         r.in.names = names;
3005
3006         if (DEBUGLEVEL >= 10) {
3007                 NDR_PRINT_IN_DEBUG(samr_LookupNames, &r);
3008         }
3009
3010         status = cli->dispatch(cli,
3011                                 mem_ctx,
3012                                 &ndr_table_samr,
3013                                 NDR_SAMR_LOOKUPNAMES,
3014                                 &r);
3015
3016         if (!NT_STATUS_IS_OK(status)) {
3017                 return status;
3018         }
3019
3020         if (DEBUGLEVEL >= 10) {
3021                 NDR_PRINT_OUT_DEBUG(samr_LookupNames, &r);
3022         }
3023
3024         if (NT_STATUS_IS_ERR(status)) {
3025                 return status;
3026         }
3027
3028         /* Return variables */
3029         *rids = *r.out.rids;
3030         *types = *r.out.types;
3031
3032         /* Return result */
3033         return r.out.result;
3034 }
3035
3036 struct rpccli_samr_LookupRids_state {
3037         struct samr_LookupRids orig;
3038         struct samr_LookupRids tmp;
3039         TALLOC_CTX *out_mem_ctx;
3040         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3041 };
3042
3043 static void rpccli_samr_LookupRids_done(struct tevent_req *subreq);
3044
3045 struct tevent_req *rpccli_samr_LookupRids_send(TALLOC_CTX *mem_ctx,
3046                                                struct tevent_context *ev,
3047                                                struct rpc_pipe_client *cli,
3048                                                struct policy_handle *_domain_handle /* [in] [ref] */,
3049                                                uint32_t _num_rids /* [in] [range(0,1000)] */,
3050                                                uint32_t *_rids /* [in] [length_is(num_rids),size_is(1000)] */,
3051                                                struct lsa_Strings *_names /* [out] [ref] */,
3052                                                struct samr_Ids *_types /* [out] [ref] */)
3053 {
3054         struct tevent_req *req;
3055         struct rpccli_samr_LookupRids_state *state;
3056         struct tevent_req *subreq;
3057
3058         req = tevent_req_create(mem_ctx, &state,
3059                                 struct rpccli_samr_LookupRids_state);
3060         if (req == NULL) {
3061                 return NULL;
3062         }
3063         state->out_mem_ctx = NULL;
3064         state->dispatch_recv = cli->dispatch_recv;
3065
3066         /* In parameters */
3067         state->orig.in.domain_handle = _domain_handle;
3068         state->orig.in.num_rids = _num_rids;
3069         state->orig.in.rids = _rids;
3070
3071         /* Out parameters */
3072         state->orig.out.names = _names;
3073         state->orig.out.types = _types;
3074
3075         /* Result */
3076         ZERO_STRUCT(state->orig.out.result);
3077
3078         if (DEBUGLEVEL >= 10) {
3079                 NDR_PRINT_IN_DEBUG(samr_LookupRids, &state->orig);
3080         }
3081
3082         state->out_mem_ctx = talloc_named_const(state, 0,
3083                              "rpccli_samr_LookupRids_out_memory");
3084         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3085                 return tevent_req_post(req, ev);
3086         }
3087
3088         /* make a temporary copy, that we pass to the dispatch function */
3089         state->tmp = state->orig;
3090
3091         subreq = cli->dispatch_send(state, ev, cli,
3092                                     &ndr_table_samr,
3093                                     NDR_SAMR_LOOKUPRIDS,
3094                                     &state->tmp);
3095         if (tevent_req_nomem(subreq, req)) {
3096                 return tevent_req_post(req, ev);
3097         }
3098         tevent_req_set_callback(subreq, rpccli_samr_LookupRids_done, req);
3099         return req;
3100 }
3101
3102 static void rpccli_samr_LookupRids_done(struct tevent_req *subreq)
3103 {
3104         struct tevent_req *req = tevent_req_callback_data(
3105                 subreq, struct tevent_req);
3106         struct rpccli_samr_LookupRids_state *state = tevent_req_data(
3107                 req, struct rpccli_samr_LookupRids_state);
3108         NTSTATUS status;
3109         TALLOC_CTX *mem_ctx;
3110
3111         if (state->out_mem_ctx) {
3112                 mem_ctx = state->out_mem_ctx;
3113         } else {
3114                 mem_ctx = state;
3115         }
3116
3117         status = state->dispatch_recv(subreq, mem_ctx);
3118         TALLOC_FREE(subreq);
3119         if (!NT_STATUS_IS_OK(status)) {
3120                 tevent_req_nterror(req, status);
3121                 return;
3122         }
3123
3124         /* Copy out parameters */
3125         *state->orig.out.names = *state->tmp.out.names;
3126         *state->orig.out.types = *state->tmp.out.types;
3127
3128         /* Copy result */
3129         state->orig.out.result = state->tmp.out.result;
3130
3131         /* Reset temporary structure */
3132         ZERO_STRUCT(state->tmp);
3133
3134         if (DEBUGLEVEL >= 10) {
3135                 NDR_PRINT_OUT_DEBUG(samr_LookupRids, &state->orig);
3136         }
3137
3138         tevent_req_done(req);
3139 }
3140
3141 NTSTATUS rpccli_samr_LookupRids_recv(struct tevent_req *req,
3142                                      TALLOC_CTX *mem_ctx,
3143                                      NTSTATUS *result)
3144 {
3145         struct rpccli_samr_LookupRids_state *state = tevent_req_data(
3146                 req, struct rpccli_samr_LookupRids_state);
3147         NTSTATUS status;
3148
3149         if (tevent_req_is_nterror(req, &status)) {
3150                 tevent_req_received(req);
3151                 return status;
3152         }
3153
3154         /* Steal possbile out parameters to the callers context */
3155         talloc_steal(mem_ctx, state->out_mem_ctx);
3156
3157         /* Return result */
3158         *result = state->orig.out.result;
3159
3160         tevent_req_received(req);
3161         return NT_STATUS_OK;
3162 }
3163
3164 NTSTATUS rpccli_samr_LookupRids(struct rpc_pipe_client *cli,
3165                                 TALLOC_CTX *mem_ctx,
3166                                 struct policy_handle *domain_handle /* [in] [ref] */,
3167                                 uint32_t num_rids /* [in] [range(0,1000)] */,
3168                                 uint32_t *rids /* [in] [length_is(num_rids),size_is(1000)] */,
3169                                 struct lsa_Strings *names /* [out] [ref] */,
3170                                 struct samr_Ids *types /* [out] [ref] */)
3171 {
3172         struct samr_LookupRids r;
3173         NTSTATUS status;
3174
3175         /* In parameters */
3176         r.in.domain_handle = domain_handle;
3177         r.in.num_rids = num_rids;
3178         r.in.rids = rids;
3179
3180         if (DEBUGLEVEL >= 10) {
3181                 NDR_PRINT_IN_DEBUG(samr_LookupRids, &r);
3182         }
3183
3184         status = cli->dispatch(cli,
3185                                 mem_ctx,
3186                                 &ndr_table_samr,
3187                                 NDR_SAMR_LOOKUPRIDS,
3188                                 &r);
3189
3190         if (!NT_STATUS_IS_OK(status)) {
3191                 return status;
3192         }
3193
3194         if (DEBUGLEVEL >= 10) {
3195                 NDR_PRINT_OUT_DEBUG(samr_LookupRids, &r);
3196         }
3197
3198         if (NT_STATUS_IS_ERR(status)) {
3199                 return status;
3200         }
3201
3202         /* Return variables */
3203         *names = *r.out.names;
3204         *types = *r.out.types;
3205
3206         /* Return result */
3207         return r.out.result;
3208 }
3209
3210 struct rpccli_samr_OpenGroup_state {
3211         struct samr_OpenGroup orig;
3212         struct samr_OpenGroup tmp;
3213         TALLOC_CTX *out_mem_ctx;
3214         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3215 };
3216
3217 static void rpccli_samr_OpenGroup_done(struct tevent_req *subreq);
3218
3219 struct tevent_req *rpccli_samr_OpenGroup_send(TALLOC_CTX *mem_ctx,
3220                                               struct tevent_context *ev,
3221                                               struct rpc_pipe_client *cli,
3222                                               struct policy_handle *_domain_handle /* [in] [ref] */,
3223                                               uint32_t _access_mask /* [in]  */,
3224                                               uint32_t _rid /* [in]  */,
3225                                               struct policy_handle *_group_handle /* [out] [ref] */)
3226 {
3227         struct tevent_req *req;
3228         struct rpccli_samr_OpenGroup_state *state;
3229         struct tevent_req *subreq;
3230
3231         req = tevent_req_create(mem_ctx, &state,
3232                                 struct rpccli_samr_OpenGroup_state);
3233         if (req == NULL) {
3234                 return NULL;
3235         }
3236         state->out_mem_ctx = NULL;
3237         state->dispatch_recv = cli->dispatch_recv;
3238
3239         /* In parameters */
3240         state->orig.in.domain_handle = _domain_handle;
3241         state->orig.in.access_mask = _access_mask;
3242         state->orig.in.rid = _rid;
3243
3244         /* Out parameters */
3245         state->orig.out.group_handle = _group_handle;
3246
3247         /* Result */
3248         ZERO_STRUCT(state->orig.out.result);
3249
3250         if (DEBUGLEVEL >= 10) {
3251                 NDR_PRINT_IN_DEBUG(samr_OpenGroup, &state->orig);
3252         }
3253
3254         state->out_mem_ctx = talloc_named_const(state, 0,
3255                              "rpccli_samr_OpenGroup_out_memory");
3256         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3257                 return tevent_req_post(req, ev);
3258         }
3259
3260         /* make a temporary copy, that we pass to the dispatch function */
3261         state->tmp = state->orig;
3262
3263         subreq = cli->dispatch_send(state, ev, cli,
3264                                     &ndr_table_samr,
3265                                     NDR_SAMR_OPENGROUP,
3266                                     &state->tmp);
3267         if (tevent_req_nomem(subreq, req)) {
3268                 return tevent_req_post(req, ev);
3269         }
3270         tevent_req_set_callback(subreq, rpccli_samr_OpenGroup_done, req);
3271         return req;
3272 }
3273
3274 static void rpccli_samr_OpenGroup_done(struct tevent_req *subreq)
3275 {
3276         struct tevent_req *req = tevent_req_callback_data(
3277                 subreq, struct tevent_req);
3278         struct rpccli_samr_OpenGroup_state *state = tevent_req_data(
3279                 req, struct rpccli_samr_OpenGroup_state);
3280         NTSTATUS status;
3281         TALLOC_CTX *mem_ctx;
3282
3283         if (state->out_mem_ctx) {
3284                 mem_ctx = state->out_mem_ctx;
3285         } else {
3286                 mem_ctx = state;
3287         }
3288
3289         status = state->dispatch_recv(subreq, mem_ctx);
3290         TALLOC_FREE(subreq);
3291         if (!NT_STATUS_IS_OK(status)) {
3292                 tevent_req_nterror(req, status);
3293                 return;
3294         }
3295
3296         /* Copy out parameters */
3297         *state->orig.out.group_handle = *state->tmp.out.group_handle;
3298
3299         /* Copy result */
3300         state->orig.out.result = state->tmp.out.result;