netlogon: document some more MSVC flags.
[metze/samba/wip.git] / librpc / gen_ndr / cli_drsuapi.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_drsuapi.h"
8
9 struct rpccli_drsuapi_DsBind_state {
10         struct drsuapi_DsBind orig;
11         struct drsuapi_DsBind 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_drsuapi_DsBind_done(struct tevent_req *subreq);
17
18 struct tevent_req *rpccli_drsuapi_DsBind_send(TALLOC_CTX *mem_ctx,
19                                               struct tevent_context *ev,
20                                               struct rpc_pipe_client *cli,
21                                               struct GUID *_bind_guid /* [in] [unique] */,
22                                               struct drsuapi_DsBindInfoCtr *_bind_info /* [in,out] [unique] */,
23                                               struct policy_handle *_bind_handle /* [out] [ref] */)
24 {
25         struct tevent_req *req;
26         struct rpccli_drsuapi_DsBind_state *state;
27         struct tevent_req *subreq;
28
29         req = tevent_req_create(mem_ctx, &state,
30                                 struct rpccli_drsuapi_DsBind_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.bind_guid = _bind_guid;
39         state->orig.in.bind_info = _bind_info;
40
41         /* Out parameters */
42         state->orig.out.bind_info = _bind_info;
43         state->orig.out.bind_handle = _bind_handle;
44
45         /* Result */
46         ZERO_STRUCT(state->orig.out.result);
47
48         if (DEBUGLEVEL >= 10) {
49                 NDR_PRINT_IN_DEBUG(drsuapi_DsBind, &state->orig);
50         }
51
52         state->out_mem_ctx = talloc_named_const(state, 0,
53                              "rpccli_drsuapi_DsBind_out_memory");
54         if (tevent_req_nomem(state->out_mem_ctx, req)) {
55                 return tevent_req_post(req, ev);
56         }
57
58         /* make a temporary copy, that we pass to the dispatch function */
59         state->tmp = state->orig;
60
61         subreq = cli->dispatch_send(state, ev, cli,
62                                     &ndr_table_drsuapi,
63                                     NDR_DRSUAPI_DSBIND,
64                                     &state->tmp);
65         if (tevent_req_nomem(subreq, req)) {
66                 return tevent_req_post(req, ev);
67         }
68         tevent_req_set_callback(subreq, rpccli_drsuapi_DsBind_done, req);
69         return req;
70 }
71
72 static void rpccli_drsuapi_DsBind_done(struct tevent_req *subreq)
73 {
74         struct tevent_req *req = tevent_req_callback_data(
75                 subreq, struct tevent_req);
76         struct rpccli_drsuapi_DsBind_state *state = tevent_req_data(
77                 req, struct rpccli_drsuapi_DsBind_state);
78         NTSTATUS status;
79         TALLOC_CTX *mem_ctx;
80
81         if (state->out_mem_ctx) {
82                 mem_ctx = state->out_mem_ctx;
83         } else {
84                 mem_ctx = state;
85         }
86
87         status = state->dispatch_recv(subreq, mem_ctx);
88         TALLOC_FREE(subreq);
89         if (!NT_STATUS_IS_OK(status)) {
90                 tevent_req_nterror(req, status);
91                 return;
92         }
93
94         /* Copy out parameters */
95         if (state->orig.out.bind_info && state->tmp.out.bind_info) {
96                 *state->orig.out.bind_info = *state->tmp.out.bind_info;
97         }
98         *state->orig.out.bind_handle = *state->tmp.out.bind_handle;
99
100         /* Copy result */
101         state->orig.out.result = state->tmp.out.result;
102
103         /* Reset temporary structure */
104         ZERO_STRUCT(state->tmp);
105
106         if (DEBUGLEVEL >= 10) {
107                 NDR_PRINT_OUT_DEBUG(drsuapi_DsBind, &state->orig);
108         }
109
110         tevent_req_done(req);
111 }
112
113 NTSTATUS rpccli_drsuapi_DsBind_recv(struct tevent_req *req,
114                                     TALLOC_CTX *mem_ctx,
115                                     WERROR *result)
116 {
117         struct rpccli_drsuapi_DsBind_state *state = tevent_req_data(
118                 req, struct rpccli_drsuapi_DsBind_state);
119         NTSTATUS status;
120
121         if (tevent_req_is_nterror(req, &status)) {
122                 tevent_req_received(req);
123                 return status;
124         }
125
126         /* Steal possbile out parameters to the callers context */
127         talloc_steal(mem_ctx, state->out_mem_ctx);
128
129         /* Return result */
130         *result = state->orig.out.result;
131
132         tevent_req_received(req);
133         return NT_STATUS_OK;
134 }
135
136 NTSTATUS rpccli_drsuapi_DsBind(struct rpc_pipe_client *cli,
137                                TALLOC_CTX *mem_ctx,
138                                struct GUID *bind_guid /* [in] [unique] */,
139                                struct drsuapi_DsBindInfoCtr *bind_info /* [in,out] [unique] */,
140                                struct policy_handle *bind_handle /* [out] [ref] */,
141                                WERROR *werror)
142 {
143         struct drsuapi_DsBind r;
144         NTSTATUS status;
145
146         /* In parameters */
147         r.in.bind_guid = bind_guid;
148         r.in.bind_info = bind_info;
149
150         if (DEBUGLEVEL >= 10) {
151                 NDR_PRINT_IN_DEBUG(drsuapi_DsBind, &r);
152         }
153
154         status = cli->dispatch(cli,
155                                 mem_ctx,
156                                 &ndr_table_drsuapi,
157                                 NDR_DRSUAPI_DSBIND,
158                                 &r);
159
160         if (!NT_STATUS_IS_OK(status)) {
161                 return status;
162         }
163
164         if (DEBUGLEVEL >= 10) {
165                 NDR_PRINT_OUT_DEBUG(drsuapi_DsBind, &r);
166         }
167
168         if (NT_STATUS_IS_ERR(status)) {
169                 return status;
170         }
171
172         /* Return variables */
173         if (bind_info && r.out.bind_info) {
174                 *bind_info = *r.out.bind_info;
175         }
176         *bind_handle = *r.out.bind_handle;
177
178         /* Return result */
179         if (werror) {
180                 *werror = r.out.result;
181         }
182
183         return werror_to_ntstatus(r.out.result);
184 }
185
186 struct rpccli_drsuapi_DsUnbind_state {
187         struct drsuapi_DsUnbind orig;
188         struct drsuapi_DsUnbind tmp;
189         TALLOC_CTX *out_mem_ctx;
190         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
191 };
192
193 static void rpccli_drsuapi_DsUnbind_done(struct tevent_req *subreq);
194
195 struct tevent_req *rpccli_drsuapi_DsUnbind_send(TALLOC_CTX *mem_ctx,
196                                                 struct tevent_context *ev,
197                                                 struct rpc_pipe_client *cli,
198                                                 struct policy_handle *_bind_handle /* [in,out] [ref] */)
199 {
200         struct tevent_req *req;
201         struct rpccli_drsuapi_DsUnbind_state *state;
202         struct tevent_req *subreq;
203
204         req = tevent_req_create(mem_ctx, &state,
205                                 struct rpccli_drsuapi_DsUnbind_state);
206         if (req == NULL) {
207                 return NULL;
208         }
209         state->out_mem_ctx = NULL;
210         state->dispatch_recv = cli->dispatch_recv;
211
212         /* In parameters */
213         state->orig.in.bind_handle = _bind_handle;
214
215         /* Out parameters */
216         state->orig.out.bind_handle = _bind_handle;
217
218         /* Result */
219         ZERO_STRUCT(state->orig.out.result);
220
221         if (DEBUGLEVEL >= 10) {
222                 NDR_PRINT_IN_DEBUG(drsuapi_DsUnbind, &state->orig);
223         }
224
225         state->out_mem_ctx = talloc_named_const(state, 0,
226                              "rpccli_drsuapi_DsUnbind_out_memory");
227         if (tevent_req_nomem(state->out_mem_ctx, req)) {
228                 return tevent_req_post(req, ev);
229         }
230
231         /* make a temporary copy, that we pass to the dispatch function */
232         state->tmp = state->orig;
233
234         subreq = cli->dispatch_send(state, ev, cli,
235                                     &ndr_table_drsuapi,
236                                     NDR_DRSUAPI_DSUNBIND,
237                                     &state->tmp);
238         if (tevent_req_nomem(subreq, req)) {
239                 return tevent_req_post(req, ev);
240         }
241         tevent_req_set_callback(subreq, rpccli_drsuapi_DsUnbind_done, req);
242         return req;
243 }
244
245 static void rpccli_drsuapi_DsUnbind_done(struct tevent_req *subreq)
246 {
247         struct tevent_req *req = tevent_req_callback_data(
248                 subreq, struct tevent_req);
249         struct rpccli_drsuapi_DsUnbind_state *state = tevent_req_data(
250                 req, struct rpccli_drsuapi_DsUnbind_state);
251         NTSTATUS status;
252         TALLOC_CTX *mem_ctx;
253
254         if (state->out_mem_ctx) {
255                 mem_ctx = state->out_mem_ctx;
256         } else {
257                 mem_ctx = state;
258         }
259
260         status = state->dispatch_recv(subreq, mem_ctx);
261         TALLOC_FREE(subreq);
262         if (!NT_STATUS_IS_OK(status)) {
263                 tevent_req_nterror(req, status);
264                 return;
265         }
266
267         /* Copy out parameters */
268         *state->orig.out.bind_handle = *state->tmp.out.bind_handle;
269
270         /* Copy result */
271         state->orig.out.result = state->tmp.out.result;
272
273         /* Reset temporary structure */
274         ZERO_STRUCT(state->tmp);
275
276         if (DEBUGLEVEL >= 10) {
277                 NDR_PRINT_OUT_DEBUG(drsuapi_DsUnbind, &state->orig);
278         }
279
280         tevent_req_done(req);
281 }
282
283 NTSTATUS rpccli_drsuapi_DsUnbind_recv(struct tevent_req *req,
284                                       TALLOC_CTX *mem_ctx,
285                                       WERROR *result)
286 {
287         struct rpccli_drsuapi_DsUnbind_state *state = tevent_req_data(
288                 req, struct rpccli_drsuapi_DsUnbind_state);
289         NTSTATUS status;
290
291         if (tevent_req_is_nterror(req, &status)) {
292                 tevent_req_received(req);
293                 return status;
294         }
295
296         /* Steal possbile out parameters to the callers context */
297         talloc_steal(mem_ctx, state->out_mem_ctx);
298
299         /* Return result */
300         *result = state->orig.out.result;
301
302         tevent_req_received(req);
303         return NT_STATUS_OK;
304 }
305
306 NTSTATUS rpccli_drsuapi_DsUnbind(struct rpc_pipe_client *cli,
307                                  TALLOC_CTX *mem_ctx,
308                                  struct policy_handle *bind_handle /* [in,out] [ref] */,
309                                  WERROR *werror)
310 {
311         struct drsuapi_DsUnbind r;
312         NTSTATUS status;
313
314         /* In parameters */
315         r.in.bind_handle = bind_handle;
316
317         if (DEBUGLEVEL >= 10) {
318                 NDR_PRINT_IN_DEBUG(drsuapi_DsUnbind, &r);
319         }
320
321         status = cli->dispatch(cli,
322                                 mem_ctx,
323                                 &ndr_table_drsuapi,
324                                 NDR_DRSUAPI_DSUNBIND,
325                                 &r);
326
327         if (!NT_STATUS_IS_OK(status)) {
328                 return status;
329         }
330
331         if (DEBUGLEVEL >= 10) {
332                 NDR_PRINT_OUT_DEBUG(drsuapi_DsUnbind, &r);
333         }
334
335         if (NT_STATUS_IS_ERR(status)) {
336                 return status;
337         }
338
339         /* Return variables */
340         *bind_handle = *r.out.bind_handle;
341
342         /* Return result */
343         if (werror) {
344                 *werror = r.out.result;
345         }
346
347         return werror_to_ntstatus(r.out.result);
348 }
349
350 struct rpccli_drsuapi_DsReplicaSync_state {
351         struct drsuapi_DsReplicaSync orig;
352         struct drsuapi_DsReplicaSync tmp;
353         TALLOC_CTX *out_mem_ctx;
354         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
355 };
356
357 static void rpccli_drsuapi_DsReplicaSync_done(struct tevent_req *subreq);
358
359 struct tevent_req *rpccli_drsuapi_DsReplicaSync_send(TALLOC_CTX *mem_ctx,
360                                                      struct tevent_context *ev,
361                                                      struct rpc_pipe_client *cli,
362                                                      struct policy_handle *_bind_handle /* [in] [ref] */,
363                                                      int32_t _level /* [in]  */,
364                                                      union drsuapi_DsReplicaSyncRequest _req /* [in] [switch_is(level)] */)
365 {
366         struct tevent_req *req;
367         struct rpccli_drsuapi_DsReplicaSync_state *state;
368         struct tevent_req *subreq;
369
370         req = tevent_req_create(mem_ctx, &state,
371                                 struct rpccli_drsuapi_DsReplicaSync_state);
372         if (req == NULL) {
373                 return NULL;
374         }
375         state->out_mem_ctx = NULL;
376         state->dispatch_recv = cli->dispatch_recv;
377
378         /* In parameters */
379         state->orig.in.bind_handle = _bind_handle;
380         state->orig.in.level = _level;
381         state->orig.in.req = _req;
382
383         /* Out parameters */
384
385         /* Result */
386         ZERO_STRUCT(state->orig.out.result);
387
388         if (DEBUGLEVEL >= 10) {
389                 NDR_PRINT_IN_DEBUG(drsuapi_DsReplicaSync, &state->orig);
390         }
391
392         /* make a temporary copy, that we pass to the dispatch function */
393         state->tmp = state->orig;
394
395         subreq = cli->dispatch_send(state, ev, cli,
396                                     &ndr_table_drsuapi,
397                                     NDR_DRSUAPI_DSREPLICASYNC,
398                                     &state->tmp);
399         if (tevent_req_nomem(subreq, req)) {
400                 return tevent_req_post(req, ev);
401         }
402         tevent_req_set_callback(subreq, rpccli_drsuapi_DsReplicaSync_done, req);
403         return req;
404 }
405
406 static void rpccli_drsuapi_DsReplicaSync_done(struct tevent_req *subreq)
407 {
408         struct tevent_req *req = tevent_req_callback_data(
409                 subreq, struct tevent_req);
410         struct rpccli_drsuapi_DsReplicaSync_state *state = tevent_req_data(
411                 req, struct rpccli_drsuapi_DsReplicaSync_state);
412         NTSTATUS status;
413         TALLOC_CTX *mem_ctx;
414
415         if (state->out_mem_ctx) {
416                 mem_ctx = state->out_mem_ctx;
417         } else {
418                 mem_ctx = state;
419         }
420
421         status = state->dispatch_recv(subreq, mem_ctx);
422         TALLOC_FREE(subreq);
423         if (!NT_STATUS_IS_OK(status)) {
424                 tevent_req_nterror(req, status);
425                 return;
426         }
427
428         /* Copy out parameters */
429
430         /* Copy result */
431         state->orig.out.result = state->tmp.out.result;
432
433         /* Reset temporary structure */
434         ZERO_STRUCT(state->tmp);
435
436         if (DEBUGLEVEL >= 10) {
437                 NDR_PRINT_OUT_DEBUG(drsuapi_DsReplicaSync, &state->orig);
438         }
439
440         tevent_req_done(req);
441 }
442
443 NTSTATUS rpccli_drsuapi_DsReplicaSync_recv(struct tevent_req *req,
444                                            TALLOC_CTX *mem_ctx,
445                                            WERROR *result)
446 {
447         struct rpccli_drsuapi_DsReplicaSync_state *state = tevent_req_data(
448                 req, struct rpccli_drsuapi_DsReplicaSync_state);
449         NTSTATUS status;
450
451         if (tevent_req_is_nterror(req, &status)) {
452                 tevent_req_received(req);
453                 return status;
454         }
455
456         /* Steal possbile out parameters to the callers context */
457         talloc_steal(mem_ctx, state->out_mem_ctx);
458
459         /* Return result */
460         *result = state->orig.out.result;
461
462         tevent_req_received(req);
463         return NT_STATUS_OK;
464 }
465
466 NTSTATUS rpccli_drsuapi_DsReplicaSync(struct rpc_pipe_client *cli,
467                                       TALLOC_CTX *mem_ctx,
468                                       struct policy_handle *bind_handle /* [in] [ref] */,
469                                       int32_t level /* [in]  */,
470                                       union drsuapi_DsReplicaSyncRequest req /* [in] [switch_is(level)] */,
471                                       WERROR *werror)
472 {
473         struct drsuapi_DsReplicaSync r;
474         NTSTATUS status;
475
476         /* In parameters */
477         r.in.bind_handle = bind_handle;
478         r.in.level = level;
479         r.in.req = req;
480
481         if (DEBUGLEVEL >= 10) {
482                 NDR_PRINT_IN_DEBUG(drsuapi_DsReplicaSync, &r);
483         }
484
485         status = cli->dispatch(cli,
486                                 mem_ctx,
487                                 &ndr_table_drsuapi,
488                                 NDR_DRSUAPI_DSREPLICASYNC,
489                                 &r);
490
491         if (!NT_STATUS_IS_OK(status)) {
492                 return status;
493         }
494
495         if (DEBUGLEVEL >= 10) {
496                 NDR_PRINT_OUT_DEBUG(drsuapi_DsReplicaSync, &r);
497         }
498
499         if (NT_STATUS_IS_ERR(status)) {
500                 return status;
501         }
502
503         /* Return variables */
504
505         /* Return result */
506         if (werror) {
507                 *werror = r.out.result;
508         }
509
510         return werror_to_ntstatus(r.out.result);
511 }
512
513 struct rpccli_drsuapi_DsGetNCChanges_state {
514         struct drsuapi_DsGetNCChanges orig;
515         struct drsuapi_DsGetNCChanges tmp;
516         TALLOC_CTX *out_mem_ctx;
517         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
518 };
519
520 static void rpccli_drsuapi_DsGetNCChanges_done(struct tevent_req *subreq);
521
522 struct tevent_req *rpccli_drsuapi_DsGetNCChanges_send(TALLOC_CTX *mem_ctx,
523                                                       struct tevent_context *ev,
524                                                       struct rpc_pipe_client *cli,
525                                                       struct policy_handle *_bind_handle /* [in] [ref] */,
526                                                       int32_t _level /* [in]  */,
527                                                       union drsuapi_DsGetNCChangesRequest *_req /* [in] [ref,switch_is(level)] */,
528                                                       int32_t *_level_out /* [out] [ref] */,
529                                                       union drsuapi_DsGetNCChangesCtr *_ctr /* [out] [ref,switch_is(*level_out)] */)
530 {
531         struct tevent_req *req;
532         struct rpccli_drsuapi_DsGetNCChanges_state *state;
533         struct tevent_req *subreq;
534
535         req = tevent_req_create(mem_ctx, &state,
536                                 struct rpccli_drsuapi_DsGetNCChanges_state);
537         if (req == NULL) {
538                 return NULL;
539         }
540         state->out_mem_ctx = NULL;
541         state->dispatch_recv = cli->dispatch_recv;
542
543         /* In parameters */
544         state->orig.in.bind_handle = _bind_handle;
545         state->orig.in.level = _level;
546         state->orig.in.req = _req;
547
548         /* Out parameters */
549         state->orig.out.level_out = _level_out;
550         state->orig.out.ctr = _ctr;
551
552         /* Result */
553         ZERO_STRUCT(state->orig.out.result);
554
555         if (DEBUGLEVEL >= 10) {
556                 NDR_PRINT_IN_DEBUG(drsuapi_DsGetNCChanges, &state->orig);
557         }
558
559         state->out_mem_ctx = talloc_named_const(state, 0,
560                              "rpccli_drsuapi_DsGetNCChanges_out_memory");
561         if (tevent_req_nomem(state->out_mem_ctx, req)) {
562                 return tevent_req_post(req, ev);
563         }
564
565         /* make a temporary copy, that we pass to the dispatch function */
566         state->tmp = state->orig;
567
568         subreq = cli->dispatch_send(state, ev, cli,
569                                     &ndr_table_drsuapi,
570                                     NDR_DRSUAPI_DSGETNCCHANGES,
571                                     &state->tmp);
572         if (tevent_req_nomem(subreq, req)) {
573                 return tevent_req_post(req, ev);
574         }
575         tevent_req_set_callback(subreq, rpccli_drsuapi_DsGetNCChanges_done, req);
576         return req;
577 }
578
579 static void rpccli_drsuapi_DsGetNCChanges_done(struct tevent_req *subreq)
580 {
581         struct tevent_req *req = tevent_req_callback_data(
582                 subreq, struct tevent_req);
583         struct rpccli_drsuapi_DsGetNCChanges_state *state = tevent_req_data(
584                 req, struct rpccli_drsuapi_DsGetNCChanges_state);
585         NTSTATUS status;
586         TALLOC_CTX *mem_ctx;
587
588         if (state->out_mem_ctx) {
589                 mem_ctx = state->out_mem_ctx;
590         } else {
591                 mem_ctx = state;
592         }
593
594         status = state->dispatch_recv(subreq, mem_ctx);
595         TALLOC_FREE(subreq);
596         if (!NT_STATUS_IS_OK(status)) {
597                 tevent_req_nterror(req, status);
598                 return;
599         }
600
601         /* Copy out parameters */
602         *state->orig.out.level_out = *state->tmp.out.level_out;
603         *state->orig.out.ctr = *state->tmp.out.ctr;
604
605         /* Copy result */
606         state->orig.out.result = state->tmp.out.result;
607
608         /* Reset temporary structure */
609         ZERO_STRUCT(state->tmp);
610
611         if (DEBUGLEVEL >= 10) {
612                 NDR_PRINT_OUT_DEBUG(drsuapi_DsGetNCChanges, &state->orig);
613         }
614
615         tevent_req_done(req);
616 }
617
618 NTSTATUS rpccli_drsuapi_DsGetNCChanges_recv(struct tevent_req *req,
619                                             TALLOC_CTX *mem_ctx,
620                                             WERROR *result)
621 {
622         struct rpccli_drsuapi_DsGetNCChanges_state *state = tevent_req_data(
623                 req, struct rpccli_drsuapi_DsGetNCChanges_state);
624         NTSTATUS status;
625
626         if (tevent_req_is_nterror(req, &status)) {
627                 tevent_req_received(req);
628                 return status;
629         }
630
631         /* Steal possbile out parameters to the callers context */
632         talloc_steal(mem_ctx, state->out_mem_ctx);
633
634         /* Return result */
635         *result = state->orig.out.result;
636
637         tevent_req_received(req);
638         return NT_STATUS_OK;
639 }
640
641 NTSTATUS rpccli_drsuapi_DsGetNCChanges(struct rpc_pipe_client *cli,
642                                        TALLOC_CTX *mem_ctx,
643                                        struct policy_handle *bind_handle /* [in] [ref] */,
644                                        int32_t level /* [in]  */,
645                                        union drsuapi_DsGetNCChangesRequest *req /* [in] [ref,switch_is(level)] */,
646                                        int32_t *level_out /* [out] [ref] */,
647                                        union drsuapi_DsGetNCChangesCtr *ctr /* [out] [ref,switch_is(*level_out)] */,
648                                        WERROR *werror)
649 {
650         struct drsuapi_DsGetNCChanges r;
651         NTSTATUS status;
652
653         /* In parameters */
654         r.in.bind_handle = bind_handle;
655         r.in.level = level;
656         r.in.req = req;
657
658         if (DEBUGLEVEL >= 10) {
659                 NDR_PRINT_IN_DEBUG(drsuapi_DsGetNCChanges, &r);
660         }
661
662         status = cli->dispatch(cli,
663                                 mem_ctx,
664                                 &ndr_table_drsuapi,
665                                 NDR_DRSUAPI_DSGETNCCHANGES,
666                                 &r);
667
668         if (!NT_STATUS_IS_OK(status)) {
669                 return status;
670         }
671
672         if (DEBUGLEVEL >= 10) {
673                 NDR_PRINT_OUT_DEBUG(drsuapi_DsGetNCChanges, &r);
674         }
675
676         if (NT_STATUS_IS_ERR(status)) {
677                 return status;
678         }
679
680         /* Return variables */
681         *level_out = *r.out.level_out;
682         *ctr = *r.out.ctr;
683
684         /* Return result */
685         if (werror) {
686                 *werror = r.out.result;
687         }
688
689         return werror_to_ntstatus(r.out.result);
690 }
691
692 struct rpccli_drsuapi_DsReplicaUpdateRefs_state {
693         struct drsuapi_DsReplicaUpdateRefs orig;
694         struct drsuapi_DsReplicaUpdateRefs tmp;
695         TALLOC_CTX *out_mem_ctx;
696         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
697 };
698
699 static void rpccli_drsuapi_DsReplicaUpdateRefs_done(struct tevent_req *subreq);
700
701 struct tevent_req *rpccli_drsuapi_DsReplicaUpdateRefs_send(TALLOC_CTX *mem_ctx,
702                                                            struct tevent_context *ev,
703                                                            struct rpc_pipe_client *cli,
704                                                            struct policy_handle *_bind_handle /* [in] [ref] */,
705                                                            int32_t _level /* [in]  */,
706                                                            union drsuapi_DsReplicaUpdateRefsRequest _req /* [in] [switch_is(level)] */)
707 {
708         struct tevent_req *req;
709         struct rpccli_drsuapi_DsReplicaUpdateRefs_state *state;
710         struct tevent_req *subreq;
711
712         req = tevent_req_create(mem_ctx, &state,
713                                 struct rpccli_drsuapi_DsReplicaUpdateRefs_state);
714         if (req == NULL) {
715                 return NULL;
716         }
717         state->out_mem_ctx = NULL;
718         state->dispatch_recv = cli->dispatch_recv;
719
720         /* In parameters */
721         state->orig.in.bind_handle = _bind_handle;
722         state->orig.in.level = _level;
723         state->orig.in.req = _req;
724
725         /* Out parameters */
726
727         /* Result */
728         ZERO_STRUCT(state->orig.out.result);
729
730         if (DEBUGLEVEL >= 10) {
731                 NDR_PRINT_IN_DEBUG(drsuapi_DsReplicaUpdateRefs, &state->orig);
732         }
733
734         /* make a temporary copy, that we pass to the dispatch function */
735         state->tmp = state->orig;
736
737         subreq = cli->dispatch_send(state, ev, cli,
738                                     &ndr_table_drsuapi,
739                                     NDR_DRSUAPI_DSREPLICAUPDATEREFS,
740                                     &state->tmp);
741         if (tevent_req_nomem(subreq, req)) {
742                 return tevent_req_post(req, ev);
743         }
744         tevent_req_set_callback(subreq, rpccli_drsuapi_DsReplicaUpdateRefs_done, req);
745         return req;
746 }
747
748 static void rpccli_drsuapi_DsReplicaUpdateRefs_done(struct tevent_req *subreq)
749 {
750         struct tevent_req *req = tevent_req_callback_data(
751                 subreq, struct tevent_req);
752         struct rpccli_drsuapi_DsReplicaUpdateRefs_state *state = tevent_req_data(
753                 req, struct rpccli_drsuapi_DsReplicaUpdateRefs_state);
754         NTSTATUS status;
755         TALLOC_CTX *mem_ctx;
756
757         if (state->out_mem_ctx) {
758                 mem_ctx = state->out_mem_ctx;
759         } else {
760                 mem_ctx = state;
761         }
762
763         status = state->dispatch_recv(subreq, mem_ctx);
764         TALLOC_FREE(subreq);
765         if (!NT_STATUS_IS_OK(status)) {
766                 tevent_req_nterror(req, status);
767                 return;
768         }
769
770         /* Copy out parameters */
771
772         /* Copy result */
773         state->orig.out.result = state->tmp.out.result;
774
775         /* Reset temporary structure */
776         ZERO_STRUCT(state->tmp);
777
778         if (DEBUGLEVEL >= 10) {
779                 NDR_PRINT_OUT_DEBUG(drsuapi_DsReplicaUpdateRefs, &state->orig);
780         }
781
782         tevent_req_done(req);
783 }
784
785 NTSTATUS rpccli_drsuapi_DsReplicaUpdateRefs_recv(struct tevent_req *req,
786                                                  TALLOC_CTX *mem_ctx,
787                                                  WERROR *result)
788 {
789         struct rpccli_drsuapi_DsReplicaUpdateRefs_state *state = tevent_req_data(
790                 req, struct rpccli_drsuapi_DsReplicaUpdateRefs_state);
791         NTSTATUS status;
792
793         if (tevent_req_is_nterror(req, &status)) {
794                 tevent_req_received(req);
795                 return status;
796         }
797
798         /* Steal possbile out parameters to the callers context */
799         talloc_steal(mem_ctx, state->out_mem_ctx);
800
801         /* Return result */
802         *result = state->orig.out.result;
803
804         tevent_req_received(req);
805         return NT_STATUS_OK;
806 }
807
808 NTSTATUS rpccli_drsuapi_DsReplicaUpdateRefs(struct rpc_pipe_client *cli,
809                                             TALLOC_CTX *mem_ctx,
810                                             struct policy_handle *bind_handle /* [in] [ref] */,
811                                             int32_t level /* [in]  */,
812                                             union drsuapi_DsReplicaUpdateRefsRequest req /* [in] [switch_is(level)] */,
813                                             WERROR *werror)
814 {
815         struct drsuapi_DsReplicaUpdateRefs r;
816         NTSTATUS status;
817
818         /* In parameters */
819         r.in.bind_handle = bind_handle;
820         r.in.level = level;
821         r.in.req = req;
822
823         if (DEBUGLEVEL >= 10) {
824                 NDR_PRINT_IN_DEBUG(drsuapi_DsReplicaUpdateRefs, &r);
825         }
826
827         status = cli->dispatch(cli,
828                                 mem_ctx,
829                                 &ndr_table_drsuapi,
830                                 NDR_DRSUAPI_DSREPLICAUPDATEREFS,
831                                 &r);
832
833         if (!NT_STATUS_IS_OK(status)) {
834                 return status;
835         }
836
837         if (DEBUGLEVEL >= 10) {
838                 NDR_PRINT_OUT_DEBUG(drsuapi_DsReplicaUpdateRefs, &r);
839         }
840
841         if (NT_STATUS_IS_ERR(status)) {
842                 return status;
843         }
844
845         /* Return variables */
846
847         /* Return result */
848         if (werror) {
849                 *werror = r.out.result;
850         }
851
852         return werror_to_ntstatus(r.out.result);
853 }
854
855 struct rpccli_DRSUAPI_REPLICA_ADD_state {
856         struct DRSUAPI_REPLICA_ADD orig;
857         struct DRSUAPI_REPLICA_ADD tmp;
858         TALLOC_CTX *out_mem_ctx;
859         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
860 };
861
862 static void rpccli_DRSUAPI_REPLICA_ADD_done(struct tevent_req *subreq);
863
864 struct tevent_req *rpccli_DRSUAPI_REPLICA_ADD_send(TALLOC_CTX *mem_ctx,
865                                                    struct tevent_context *ev,
866                                                    struct rpc_pipe_client *cli)
867 {
868         struct tevent_req *req;
869         struct rpccli_DRSUAPI_REPLICA_ADD_state *state;
870         struct tevent_req *subreq;
871
872         req = tevent_req_create(mem_ctx, &state,
873                                 struct rpccli_DRSUAPI_REPLICA_ADD_state);
874         if (req == NULL) {
875                 return NULL;
876         }
877         state->out_mem_ctx = NULL;
878         state->dispatch_recv = cli->dispatch_recv;
879
880         /* In parameters */
881
882         /* Out parameters */
883
884         /* Result */
885         ZERO_STRUCT(state->orig.out.result);
886
887         if (DEBUGLEVEL >= 10) {
888                 NDR_PRINT_IN_DEBUG(DRSUAPI_REPLICA_ADD, &state->orig);
889         }
890
891         /* make a temporary copy, that we pass to the dispatch function */
892         state->tmp = state->orig;
893
894         subreq = cli->dispatch_send(state, ev, cli,
895                                     &ndr_table_drsuapi,
896                                     NDR_DRSUAPI_REPLICA_ADD,
897                                     &state->tmp);
898         if (tevent_req_nomem(subreq, req)) {
899                 return tevent_req_post(req, ev);
900         }
901         tevent_req_set_callback(subreq, rpccli_DRSUAPI_REPLICA_ADD_done, req);
902         return req;
903 }
904
905 static void rpccli_DRSUAPI_REPLICA_ADD_done(struct tevent_req *subreq)
906 {
907         struct tevent_req *req = tevent_req_callback_data(
908                 subreq, struct tevent_req);
909         struct rpccli_DRSUAPI_REPLICA_ADD_state *state = tevent_req_data(
910                 req, struct rpccli_DRSUAPI_REPLICA_ADD_state);
911         NTSTATUS status;
912         TALLOC_CTX *mem_ctx;
913
914         if (state->out_mem_ctx) {
915                 mem_ctx = state->out_mem_ctx;
916         } else {
917                 mem_ctx = state;
918         }
919
920         status = state->dispatch_recv(subreq, mem_ctx);
921         TALLOC_FREE(subreq);
922         if (!NT_STATUS_IS_OK(status)) {
923                 tevent_req_nterror(req, status);
924                 return;
925         }
926
927         /* Copy out parameters */
928
929         /* Copy result */
930         state->orig.out.result = state->tmp.out.result;
931
932         /* Reset temporary structure */
933         ZERO_STRUCT(state->tmp);
934
935         if (DEBUGLEVEL >= 10) {
936                 NDR_PRINT_OUT_DEBUG(DRSUAPI_REPLICA_ADD, &state->orig);
937         }
938
939         tevent_req_done(req);
940 }
941
942 NTSTATUS rpccli_DRSUAPI_REPLICA_ADD_recv(struct tevent_req *req,
943                                          TALLOC_CTX *mem_ctx,
944                                          WERROR *result)
945 {
946         struct rpccli_DRSUAPI_REPLICA_ADD_state *state = tevent_req_data(
947                 req, struct rpccli_DRSUAPI_REPLICA_ADD_state);
948         NTSTATUS status;
949
950         if (tevent_req_is_nterror(req, &status)) {
951                 tevent_req_received(req);
952                 return status;
953         }
954
955         /* Steal possbile out parameters to the callers context */
956         talloc_steal(mem_ctx, state->out_mem_ctx);
957
958         /* Return result */
959         *result = state->orig.out.result;
960
961         tevent_req_received(req);
962         return NT_STATUS_OK;
963 }
964
965 NTSTATUS rpccli_DRSUAPI_REPLICA_ADD(struct rpc_pipe_client *cli,
966                                     TALLOC_CTX *mem_ctx,
967                                     WERROR *werror)
968 {
969         struct DRSUAPI_REPLICA_ADD r;
970         NTSTATUS status;
971
972         /* In parameters */
973
974         if (DEBUGLEVEL >= 10) {
975                 NDR_PRINT_IN_DEBUG(DRSUAPI_REPLICA_ADD, &r);
976         }
977
978         status = cli->dispatch(cli,
979                                 mem_ctx,
980                                 &ndr_table_drsuapi,
981                                 NDR_DRSUAPI_REPLICA_ADD,
982                                 &r);
983
984         if (!NT_STATUS_IS_OK(status)) {
985                 return status;
986         }
987
988         if (DEBUGLEVEL >= 10) {
989                 NDR_PRINT_OUT_DEBUG(DRSUAPI_REPLICA_ADD, &r);
990         }
991
992         if (NT_STATUS_IS_ERR(status)) {
993                 return status;
994         }
995
996         /* Return variables */
997
998         /* Return result */
999         if (werror) {
1000                 *werror = r.out.result;
1001         }
1002
1003         return werror_to_ntstatus(r.out.result);
1004 }
1005
1006 struct rpccli_DRSUAPI_REPLICA_DEL_state {
1007         struct DRSUAPI_REPLICA_DEL orig;
1008         struct DRSUAPI_REPLICA_DEL tmp;
1009         TALLOC_CTX *out_mem_ctx;
1010         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1011 };
1012
1013 static void rpccli_DRSUAPI_REPLICA_DEL_done(struct tevent_req *subreq);
1014
1015 struct tevent_req *rpccli_DRSUAPI_REPLICA_DEL_send(TALLOC_CTX *mem_ctx,
1016                                                    struct tevent_context *ev,
1017                                                    struct rpc_pipe_client *cli)
1018 {
1019         struct tevent_req *req;
1020         struct rpccli_DRSUAPI_REPLICA_DEL_state *state;
1021         struct tevent_req *subreq;
1022
1023         req = tevent_req_create(mem_ctx, &state,
1024                                 struct rpccli_DRSUAPI_REPLICA_DEL_state);
1025         if (req == NULL) {
1026                 return NULL;
1027         }
1028         state->out_mem_ctx = NULL;
1029         state->dispatch_recv = cli->dispatch_recv;
1030
1031         /* In parameters */
1032
1033         /* Out parameters */
1034
1035         /* Result */
1036         ZERO_STRUCT(state->orig.out.result);
1037
1038         if (DEBUGLEVEL >= 10) {
1039                 NDR_PRINT_IN_DEBUG(DRSUAPI_REPLICA_DEL, &state->orig);
1040         }
1041
1042         /* make a temporary copy, that we pass to the dispatch function */
1043         state->tmp = state->orig;
1044
1045         subreq = cli->dispatch_send(state, ev, cli,
1046                                     &ndr_table_drsuapi,
1047                                     NDR_DRSUAPI_REPLICA_DEL,
1048                                     &state->tmp);
1049         if (tevent_req_nomem(subreq, req)) {
1050                 return tevent_req_post(req, ev);
1051         }
1052         tevent_req_set_callback(subreq, rpccli_DRSUAPI_REPLICA_DEL_done, req);
1053         return req;
1054 }
1055
1056 static void rpccli_DRSUAPI_REPLICA_DEL_done(struct tevent_req *subreq)
1057 {
1058         struct tevent_req *req = tevent_req_callback_data(
1059                 subreq, struct tevent_req);
1060         struct rpccli_DRSUAPI_REPLICA_DEL_state *state = tevent_req_data(
1061                 req, struct rpccli_DRSUAPI_REPLICA_DEL_state);
1062         NTSTATUS status;
1063         TALLOC_CTX *mem_ctx;
1064
1065         if (state->out_mem_ctx) {
1066                 mem_ctx = state->out_mem_ctx;
1067         } else {
1068                 mem_ctx = state;
1069         }
1070
1071         status = state->dispatch_recv(subreq, mem_ctx);
1072         TALLOC_FREE(subreq);
1073         if (!NT_STATUS_IS_OK(status)) {
1074                 tevent_req_nterror(req, status);
1075                 return;
1076         }
1077
1078         /* Copy out parameters */
1079
1080         /* Copy result */
1081         state->orig.out.result = state->tmp.out.result;
1082
1083         /* Reset temporary structure */
1084         ZERO_STRUCT(state->tmp);
1085
1086         if (DEBUGLEVEL >= 10) {
1087                 NDR_PRINT_OUT_DEBUG(DRSUAPI_REPLICA_DEL, &state->orig);
1088         }
1089
1090         tevent_req_done(req);
1091 }
1092
1093 NTSTATUS rpccli_DRSUAPI_REPLICA_DEL_recv(struct tevent_req *req,
1094                                          TALLOC_CTX *mem_ctx,
1095                                          WERROR *result)
1096 {
1097         struct rpccli_DRSUAPI_REPLICA_DEL_state *state = tevent_req_data(
1098                 req, struct rpccli_DRSUAPI_REPLICA_DEL_state);
1099         NTSTATUS status;
1100
1101         if (tevent_req_is_nterror(req, &status)) {
1102                 tevent_req_received(req);
1103                 return status;
1104         }
1105
1106         /* Steal possbile out parameters to the callers context */
1107         talloc_steal(mem_ctx, state->out_mem_ctx);
1108
1109         /* Return result */
1110         *result = state->orig.out.result;
1111
1112         tevent_req_received(req);
1113         return NT_STATUS_OK;
1114 }
1115
1116 NTSTATUS rpccli_DRSUAPI_REPLICA_DEL(struct rpc_pipe_client *cli,
1117                                     TALLOC_CTX *mem_ctx,
1118                                     WERROR *werror)
1119 {
1120         struct DRSUAPI_REPLICA_DEL r;
1121         NTSTATUS status;
1122
1123         /* In parameters */
1124
1125         if (DEBUGLEVEL >= 10) {
1126                 NDR_PRINT_IN_DEBUG(DRSUAPI_REPLICA_DEL, &r);
1127         }
1128
1129         status = cli->dispatch(cli,
1130                                 mem_ctx,
1131                                 &ndr_table_drsuapi,
1132                                 NDR_DRSUAPI_REPLICA_DEL,
1133                                 &r);
1134
1135         if (!NT_STATUS_IS_OK(status)) {
1136                 return status;
1137         }
1138
1139         if (DEBUGLEVEL >= 10) {
1140                 NDR_PRINT_OUT_DEBUG(DRSUAPI_REPLICA_DEL, &r);
1141         }
1142
1143         if (NT_STATUS_IS_ERR(status)) {
1144                 return status;
1145         }
1146
1147         /* Return variables */
1148
1149         /* Return result */
1150         if (werror) {
1151                 *werror = r.out.result;
1152         }
1153
1154         return werror_to_ntstatus(r.out.result);
1155 }
1156
1157 struct rpccli_DRSUAPI_REPLICA_MODIFY_state {
1158         struct DRSUAPI_REPLICA_MODIFY orig;
1159         struct DRSUAPI_REPLICA_MODIFY tmp;
1160         TALLOC_CTX *out_mem_ctx;
1161         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1162 };
1163
1164 static void rpccli_DRSUAPI_REPLICA_MODIFY_done(struct tevent_req *subreq);
1165
1166 struct tevent_req *rpccli_DRSUAPI_REPLICA_MODIFY_send(TALLOC_CTX *mem_ctx,
1167                                                       struct tevent_context *ev,
1168                                                       struct rpc_pipe_client *cli)
1169 {
1170         struct tevent_req *req;
1171         struct rpccli_DRSUAPI_REPLICA_MODIFY_state *state;
1172         struct tevent_req *subreq;
1173
1174         req = tevent_req_create(mem_ctx, &state,
1175                                 struct rpccli_DRSUAPI_REPLICA_MODIFY_state);
1176         if (req == NULL) {
1177                 return NULL;
1178         }
1179         state->out_mem_ctx = NULL;
1180         state->dispatch_recv = cli->dispatch_recv;
1181
1182         /* In parameters */
1183
1184         /* Out parameters */
1185
1186         /* Result */
1187         ZERO_STRUCT(state->orig.out.result);
1188
1189         if (DEBUGLEVEL >= 10) {
1190                 NDR_PRINT_IN_DEBUG(DRSUAPI_REPLICA_MODIFY, &state->orig);
1191         }
1192
1193         /* make a temporary copy, that we pass to the dispatch function */
1194         state->tmp = state->orig;
1195
1196         subreq = cli->dispatch_send(state, ev, cli,
1197                                     &ndr_table_drsuapi,
1198                                     NDR_DRSUAPI_REPLICA_MODIFY,
1199                                     &state->tmp);
1200         if (tevent_req_nomem(subreq, req)) {
1201                 return tevent_req_post(req, ev);
1202         }
1203         tevent_req_set_callback(subreq, rpccli_DRSUAPI_REPLICA_MODIFY_done, req);
1204         return req;
1205 }
1206
1207 static void rpccli_DRSUAPI_REPLICA_MODIFY_done(struct tevent_req *subreq)
1208 {
1209         struct tevent_req *req = tevent_req_callback_data(
1210                 subreq, struct tevent_req);
1211         struct rpccli_DRSUAPI_REPLICA_MODIFY_state *state = tevent_req_data(
1212                 req, struct rpccli_DRSUAPI_REPLICA_MODIFY_state);
1213         NTSTATUS status;
1214         TALLOC_CTX *mem_ctx;
1215
1216         if (state->out_mem_ctx) {
1217                 mem_ctx = state->out_mem_ctx;
1218         } else {
1219                 mem_ctx = state;
1220         }
1221
1222         status = state->dispatch_recv(subreq, mem_ctx);
1223         TALLOC_FREE(subreq);
1224         if (!NT_STATUS_IS_OK(status)) {
1225                 tevent_req_nterror(req, status);
1226                 return;
1227         }
1228
1229         /* Copy out parameters */
1230
1231         /* Copy result */
1232         state->orig.out.result = state->tmp.out.result;
1233
1234         /* Reset temporary structure */
1235         ZERO_STRUCT(state->tmp);
1236
1237         if (DEBUGLEVEL >= 10) {
1238                 NDR_PRINT_OUT_DEBUG(DRSUAPI_REPLICA_MODIFY, &state->orig);
1239         }
1240
1241         tevent_req_done(req);
1242 }
1243
1244 NTSTATUS rpccli_DRSUAPI_REPLICA_MODIFY_recv(struct tevent_req *req,
1245                                             TALLOC_CTX *mem_ctx,
1246                                             WERROR *result)
1247 {
1248         struct rpccli_DRSUAPI_REPLICA_MODIFY_state *state = tevent_req_data(
1249                 req, struct rpccli_DRSUAPI_REPLICA_MODIFY_state);
1250         NTSTATUS status;
1251
1252         if (tevent_req_is_nterror(req, &status)) {
1253                 tevent_req_received(req);
1254                 return status;
1255         }
1256
1257         /* Steal possbile out parameters to the callers context */
1258         talloc_steal(mem_ctx, state->out_mem_ctx);
1259
1260         /* Return result */
1261         *result = state->orig.out.result;
1262
1263         tevent_req_received(req);
1264         return NT_STATUS_OK;
1265 }
1266
1267 NTSTATUS rpccli_DRSUAPI_REPLICA_MODIFY(struct rpc_pipe_client *cli,
1268                                        TALLOC_CTX *mem_ctx,
1269                                        WERROR *werror)
1270 {
1271         struct DRSUAPI_REPLICA_MODIFY r;
1272         NTSTATUS status;
1273
1274         /* In parameters */
1275
1276         if (DEBUGLEVEL >= 10) {
1277                 NDR_PRINT_IN_DEBUG(DRSUAPI_REPLICA_MODIFY, &r);
1278         }
1279
1280         status = cli->dispatch(cli,
1281                                 mem_ctx,
1282                                 &ndr_table_drsuapi,
1283                                 NDR_DRSUAPI_REPLICA_MODIFY,
1284                                 &r);
1285
1286         if (!NT_STATUS_IS_OK(status)) {
1287                 return status;
1288         }
1289
1290         if (DEBUGLEVEL >= 10) {
1291                 NDR_PRINT_OUT_DEBUG(DRSUAPI_REPLICA_MODIFY, &r);
1292         }
1293
1294         if (NT_STATUS_IS_ERR(status)) {
1295                 return status;
1296         }
1297
1298         /* Return variables */
1299
1300         /* Return result */
1301         if (werror) {
1302                 *werror = r.out.result;
1303         }
1304
1305         return werror_to_ntstatus(r.out.result);
1306 }
1307
1308 struct rpccli_DRSUAPI_VERIFY_NAMES_state {
1309         struct DRSUAPI_VERIFY_NAMES orig;
1310         struct DRSUAPI_VERIFY_NAMES tmp;
1311         TALLOC_CTX *out_mem_ctx;
1312         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1313 };
1314
1315 static void rpccli_DRSUAPI_VERIFY_NAMES_done(struct tevent_req *subreq);
1316
1317 struct tevent_req *rpccli_DRSUAPI_VERIFY_NAMES_send(TALLOC_CTX *mem_ctx,
1318                                                     struct tevent_context *ev,
1319                                                     struct rpc_pipe_client *cli)
1320 {
1321         struct tevent_req *req;
1322         struct rpccli_DRSUAPI_VERIFY_NAMES_state *state;
1323         struct tevent_req *subreq;
1324
1325         req = tevent_req_create(mem_ctx, &state,
1326                                 struct rpccli_DRSUAPI_VERIFY_NAMES_state);
1327         if (req == NULL) {
1328                 return NULL;
1329         }
1330         state->out_mem_ctx = NULL;
1331         state->dispatch_recv = cli->dispatch_recv;
1332
1333         /* In parameters */
1334
1335         /* Out parameters */
1336
1337         /* Result */
1338         ZERO_STRUCT(state->orig.out.result);
1339
1340         if (DEBUGLEVEL >= 10) {
1341                 NDR_PRINT_IN_DEBUG(DRSUAPI_VERIFY_NAMES, &state->orig);
1342         }
1343
1344         /* make a temporary copy, that we pass to the dispatch function */
1345         state->tmp = state->orig;
1346
1347         subreq = cli->dispatch_send(state, ev, cli,
1348                                     &ndr_table_drsuapi,
1349                                     NDR_DRSUAPI_VERIFY_NAMES,
1350                                     &state->tmp);
1351         if (tevent_req_nomem(subreq, req)) {
1352                 return tevent_req_post(req, ev);
1353         }
1354         tevent_req_set_callback(subreq, rpccli_DRSUAPI_VERIFY_NAMES_done, req);
1355         return req;
1356 }
1357
1358 static void rpccli_DRSUAPI_VERIFY_NAMES_done(struct tevent_req *subreq)
1359 {
1360         struct tevent_req *req = tevent_req_callback_data(
1361                 subreq, struct tevent_req);
1362         struct rpccli_DRSUAPI_VERIFY_NAMES_state *state = tevent_req_data(
1363                 req, struct rpccli_DRSUAPI_VERIFY_NAMES_state);
1364         NTSTATUS status;
1365         TALLOC_CTX *mem_ctx;
1366
1367         if (state->out_mem_ctx) {
1368                 mem_ctx = state->out_mem_ctx;
1369         } else {
1370                 mem_ctx = state;
1371         }
1372
1373         status = state->dispatch_recv(subreq, mem_ctx);
1374         TALLOC_FREE(subreq);
1375         if (!NT_STATUS_IS_OK(status)) {
1376                 tevent_req_nterror(req, status);
1377                 return;
1378         }
1379
1380         /* Copy out parameters */
1381
1382         /* Copy result */
1383         state->orig.out.result = state->tmp.out.result;
1384
1385         /* Reset temporary structure */
1386         ZERO_STRUCT(state->tmp);
1387
1388         if (DEBUGLEVEL >= 10) {
1389                 NDR_PRINT_OUT_DEBUG(DRSUAPI_VERIFY_NAMES, &state->orig);
1390         }
1391
1392         tevent_req_done(req);
1393 }
1394
1395 NTSTATUS rpccli_DRSUAPI_VERIFY_NAMES_recv(struct tevent_req *req,
1396                                           TALLOC_CTX *mem_ctx,
1397                                           WERROR *result)
1398 {
1399         struct rpccli_DRSUAPI_VERIFY_NAMES_state *state = tevent_req_data(
1400                 req, struct rpccli_DRSUAPI_VERIFY_NAMES_state);
1401         NTSTATUS status;
1402
1403         if (tevent_req_is_nterror(req, &status)) {
1404                 tevent_req_received(req);
1405                 return status;
1406         }
1407
1408         /* Steal possbile out parameters to the callers context */
1409         talloc_steal(mem_ctx, state->out_mem_ctx);
1410
1411         /* Return result */
1412         *result = state->orig.out.result;
1413
1414         tevent_req_received(req);
1415         return NT_STATUS_OK;
1416 }
1417
1418 NTSTATUS rpccli_DRSUAPI_VERIFY_NAMES(struct rpc_pipe_client *cli,
1419                                      TALLOC_CTX *mem_ctx,
1420                                      WERROR *werror)
1421 {
1422         struct DRSUAPI_VERIFY_NAMES r;
1423         NTSTATUS status;
1424
1425         /* In parameters */
1426
1427         if (DEBUGLEVEL >= 10) {
1428                 NDR_PRINT_IN_DEBUG(DRSUAPI_VERIFY_NAMES, &r);
1429         }
1430
1431         status = cli->dispatch(cli,
1432                                 mem_ctx,
1433                                 &ndr_table_drsuapi,
1434                                 NDR_DRSUAPI_VERIFY_NAMES,
1435                                 &r);
1436
1437         if (!NT_STATUS_IS_OK(status)) {
1438                 return status;
1439         }
1440
1441         if (DEBUGLEVEL >= 10) {
1442                 NDR_PRINT_OUT_DEBUG(DRSUAPI_VERIFY_NAMES, &r);
1443         }
1444
1445         if (NT_STATUS_IS_ERR(status)) {
1446                 return status;
1447         }
1448
1449         /* Return variables */
1450
1451         /* Return result */
1452         if (werror) {
1453                 *werror = r.out.result;
1454         }
1455
1456         return werror_to_ntstatus(r.out.result);
1457 }
1458
1459 struct rpccli_drsuapi_DsGetMemberships_state {
1460         struct drsuapi_DsGetMemberships orig;
1461         struct drsuapi_DsGetMemberships tmp;
1462         TALLOC_CTX *out_mem_ctx;
1463         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1464 };
1465
1466 static void rpccli_drsuapi_DsGetMemberships_done(struct tevent_req *subreq);
1467
1468 struct tevent_req *rpccli_drsuapi_DsGetMemberships_send(TALLOC_CTX *mem_ctx,
1469                                                         struct tevent_context *ev,
1470                                                         struct rpc_pipe_client *cli,
1471                                                         struct policy_handle *_bind_handle /* [in] [ref] */,
1472                                                         int32_t _level /* [in]  */,
1473                                                         union drsuapi_DsGetMembershipsRequest *_req /* [in] [ref,switch_is(level)] */,
1474                                                         int32_t *_level_out /* [out] [ref] */,
1475                                                         union drsuapi_DsGetMembershipsCtr *_ctr /* [out] [ref,switch_is(*level_out)] */)
1476 {
1477         struct tevent_req *req;
1478         struct rpccli_drsuapi_DsGetMemberships_state *state;
1479         struct tevent_req *subreq;
1480
1481         req = tevent_req_create(mem_ctx, &state,
1482                                 struct rpccli_drsuapi_DsGetMemberships_state);
1483         if (req == NULL) {
1484                 return NULL;
1485         }
1486         state->out_mem_ctx = NULL;
1487         state->dispatch_recv = cli->dispatch_recv;
1488
1489         /* In parameters */
1490         state->orig.in.bind_handle = _bind_handle;
1491         state->orig.in.level = _level;
1492         state->orig.in.req = _req;
1493
1494         /* Out parameters */
1495         state->orig.out.level_out = _level_out;
1496         state->orig.out.ctr = _ctr;
1497
1498         /* Result */
1499         ZERO_STRUCT(state->orig.out.result);
1500
1501         if (DEBUGLEVEL >= 10) {
1502                 NDR_PRINT_IN_DEBUG(drsuapi_DsGetMemberships, &state->orig);
1503         }
1504
1505         state->out_mem_ctx = talloc_named_const(state, 0,
1506                              "rpccli_drsuapi_DsGetMemberships_out_memory");
1507         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1508                 return tevent_req_post(req, ev);
1509         }
1510
1511         /* make a temporary copy, that we pass to the dispatch function */
1512         state->tmp = state->orig;
1513
1514         subreq = cli->dispatch_send(state, ev, cli,
1515                                     &ndr_table_drsuapi,
1516                                     NDR_DRSUAPI_DSGETMEMBERSHIPS,
1517                                     &state->tmp);
1518         if (tevent_req_nomem(subreq, req)) {
1519                 return tevent_req_post(req, ev);
1520         }
1521         tevent_req_set_callback(subreq, rpccli_drsuapi_DsGetMemberships_done, req);
1522         return req;
1523 }
1524
1525 static void rpccli_drsuapi_DsGetMemberships_done(struct tevent_req *subreq)
1526 {
1527         struct tevent_req *req = tevent_req_callback_data(
1528                 subreq, struct tevent_req);
1529         struct rpccli_drsuapi_DsGetMemberships_state *state = tevent_req_data(
1530                 req, struct rpccli_drsuapi_DsGetMemberships_state);
1531         NTSTATUS status;
1532         TALLOC_CTX *mem_ctx;
1533
1534         if (state->out_mem_ctx) {
1535                 mem_ctx = state->out_mem_ctx;
1536         } else {
1537                 mem_ctx = state;
1538         }
1539
1540         status = state->dispatch_recv(subreq, mem_ctx);
1541         TALLOC_FREE(subreq);
1542         if (!NT_STATUS_IS_OK(status)) {
1543                 tevent_req_nterror(req, status);
1544                 return;
1545         }
1546
1547         /* Copy out parameters */
1548         *state->orig.out.level_out = *state->tmp.out.level_out;
1549         *state->orig.out.ctr = *state->tmp.out.ctr;
1550
1551         /* Copy result */
1552         state->orig.out.result = state->tmp.out.result;
1553
1554         /* Reset temporary structure */
1555         ZERO_STRUCT(state->tmp);
1556
1557         if (DEBUGLEVEL >= 10) {
1558                 NDR_PRINT_OUT_DEBUG(drsuapi_DsGetMemberships, &state->orig);
1559         }
1560
1561         tevent_req_done(req);
1562 }
1563
1564 NTSTATUS rpccli_drsuapi_DsGetMemberships_recv(struct tevent_req *req,
1565                                               TALLOC_CTX *mem_ctx,
1566                                               WERROR *result)
1567 {
1568         struct rpccli_drsuapi_DsGetMemberships_state *state = tevent_req_data(
1569                 req, struct rpccli_drsuapi_DsGetMemberships_state);
1570         NTSTATUS status;
1571
1572         if (tevent_req_is_nterror(req, &status)) {
1573                 tevent_req_received(req);
1574                 return status;
1575         }
1576
1577         /* Steal possbile out parameters to the callers context */
1578         talloc_steal(mem_ctx, state->out_mem_ctx);
1579
1580         /* Return result */
1581         *result = state->orig.out.result;
1582
1583         tevent_req_received(req);
1584         return NT_STATUS_OK;
1585 }
1586
1587 NTSTATUS rpccli_drsuapi_DsGetMemberships(struct rpc_pipe_client *cli,
1588                                          TALLOC_CTX *mem_ctx,
1589                                          struct policy_handle *bind_handle /* [in] [ref] */,
1590                                          int32_t level /* [in]  */,
1591                                          union drsuapi_DsGetMembershipsRequest *req /* [in] [ref,switch_is(level)] */,
1592                                          int32_t *level_out /* [out] [ref] */,
1593                                          union drsuapi_DsGetMembershipsCtr *ctr /* [out] [ref,switch_is(*level_out)] */,
1594                                          WERROR *werror)
1595 {
1596         struct drsuapi_DsGetMemberships r;
1597         NTSTATUS status;
1598
1599         /* In parameters */
1600         r.in.bind_handle = bind_handle;
1601         r.in.level = level;
1602         r.in.req = req;
1603
1604         if (DEBUGLEVEL >= 10) {
1605                 NDR_PRINT_IN_DEBUG(drsuapi_DsGetMemberships, &r);
1606         }
1607
1608         status = cli->dispatch(cli,
1609                                 mem_ctx,
1610                                 &ndr_table_drsuapi,
1611                                 NDR_DRSUAPI_DSGETMEMBERSHIPS,
1612                                 &r);
1613
1614         if (!NT_STATUS_IS_OK(status)) {
1615                 return status;
1616         }
1617
1618         if (DEBUGLEVEL >= 10) {
1619                 NDR_PRINT_OUT_DEBUG(drsuapi_DsGetMemberships, &r);
1620         }
1621
1622         if (NT_STATUS_IS_ERR(status)) {
1623                 return status;
1624         }
1625
1626         /* Return variables */
1627         *level_out = *r.out.level_out;
1628         *ctr = *r.out.ctr;
1629
1630         /* Return result */
1631         if (werror) {
1632                 *werror = r.out.result;
1633         }
1634
1635         return werror_to_ntstatus(r.out.result);
1636 }
1637
1638 struct rpccli_DRSUAPI_INTER_DOMAIN_MOVE_state {
1639         struct DRSUAPI_INTER_DOMAIN_MOVE orig;
1640         struct DRSUAPI_INTER_DOMAIN_MOVE tmp;
1641         TALLOC_CTX *out_mem_ctx;
1642         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1643 };
1644
1645 static void rpccli_DRSUAPI_INTER_DOMAIN_MOVE_done(struct tevent_req *subreq);
1646
1647 struct tevent_req *rpccli_DRSUAPI_INTER_DOMAIN_MOVE_send(TALLOC_CTX *mem_ctx,
1648                                                          struct tevent_context *ev,
1649                                                          struct rpc_pipe_client *cli)
1650 {
1651         struct tevent_req *req;
1652         struct rpccli_DRSUAPI_INTER_DOMAIN_MOVE_state *state;
1653         struct tevent_req *subreq;
1654
1655         req = tevent_req_create(mem_ctx, &state,
1656                                 struct rpccli_DRSUAPI_INTER_DOMAIN_MOVE_state);
1657         if (req == NULL) {
1658                 return NULL;
1659         }
1660         state->out_mem_ctx = NULL;
1661         state->dispatch_recv = cli->dispatch_recv;
1662
1663         /* In parameters */
1664
1665         /* Out parameters */
1666
1667         /* Result */
1668         ZERO_STRUCT(state->orig.out.result);
1669
1670         if (DEBUGLEVEL >= 10) {
1671                 NDR_PRINT_IN_DEBUG(DRSUAPI_INTER_DOMAIN_MOVE, &state->orig);
1672         }
1673
1674         /* make a temporary copy, that we pass to the dispatch function */
1675         state->tmp = state->orig;
1676
1677         subreq = cli->dispatch_send(state, ev, cli,
1678                                     &ndr_table_drsuapi,
1679                                     NDR_DRSUAPI_INTER_DOMAIN_MOVE,
1680                                     &state->tmp);
1681         if (tevent_req_nomem(subreq, req)) {
1682                 return tevent_req_post(req, ev);
1683         }
1684         tevent_req_set_callback(subreq, rpccli_DRSUAPI_INTER_DOMAIN_MOVE_done, req);
1685         return req;
1686 }
1687
1688 static void rpccli_DRSUAPI_INTER_DOMAIN_MOVE_done(struct tevent_req *subreq)
1689 {
1690         struct tevent_req *req = tevent_req_callback_data(
1691                 subreq, struct tevent_req);
1692         struct rpccli_DRSUAPI_INTER_DOMAIN_MOVE_state *state = tevent_req_data(
1693                 req, struct rpccli_DRSUAPI_INTER_DOMAIN_MOVE_state);
1694         NTSTATUS status;
1695         TALLOC_CTX *mem_ctx;
1696
1697         if (state->out_mem_ctx) {
1698                 mem_ctx = state->out_mem_ctx;
1699         } else {
1700                 mem_ctx = state;
1701         }
1702
1703         status = state->dispatch_recv(subreq, mem_ctx);
1704         TALLOC_FREE(subreq);
1705         if (!NT_STATUS_IS_OK(status)) {
1706                 tevent_req_nterror(req, status);
1707                 return;
1708         }
1709
1710         /* Copy out parameters */
1711
1712         /* Copy result */
1713         state->orig.out.result = state->tmp.out.result;
1714
1715         /* Reset temporary structure */
1716         ZERO_STRUCT(state->tmp);
1717
1718         if (DEBUGLEVEL >= 10) {
1719                 NDR_PRINT_OUT_DEBUG(DRSUAPI_INTER_DOMAIN_MOVE, &state->orig);
1720         }
1721
1722         tevent_req_done(req);
1723 }
1724
1725 NTSTATUS rpccli_DRSUAPI_INTER_DOMAIN_MOVE_recv(struct tevent_req *req,
1726                                                TALLOC_CTX *mem_ctx,
1727                                                WERROR *result)
1728 {
1729         struct rpccli_DRSUAPI_INTER_DOMAIN_MOVE_state *state = tevent_req_data(
1730                 req, struct rpccli_DRSUAPI_INTER_DOMAIN_MOVE_state);
1731         NTSTATUS status;
1732
1733         if (tevent_req_is_nterror(req, &status)) {
1734                 tevent_req_received(req);
1735                 return status;
1736         }
1737
1738         /* Steal possbile out parameters to the callers context */
1739         talloc_steal(mem_ctx, state->out_mem_ctx);
1740
1741         /* Return result */
1742         *result = state->orig.out.result;
1743
1744         tevent_req_received(req);
1745         return NT_STATUS_OK;
1746 }
1747
1748 NTSTATUS rpccli_DRSUAPI_INTER_DOMAIN_MOVE(struct rpc_pipe_client *cli,
1749                                           TALLOC_CTX *mem_ctx,
1750                                           WERROR *werror)
1751 {
1752         struct DRSUAPI_INTER_DOMAIN_MOVE r;
1753         NTSTATUS status;
1754
1755         /* In parameters */
1756
1757         if (DEBUGLEVEL >= 10) {
1758                 NDR_PRINT_IN_DEBUG(DRSUAPI_INTER_DOMAIN_MOVE, &r);
1759         }
1760
1761         status = cli->dispatch(cli,
1762                                 mem_ctx,
1763                                 &ndr_table_drsuapi,
1764                                 NDR_DRSUAPI_INTER_DOMAIN_MOVE,
1765                                 &r);
1766
1767         if (!NT_STATUS_IS_OK(status)) {
1768                 return status;
1769         }
1770
1771         if (DEBUGLEVEL >= 10) {
1772                 NDR_PRINT_OUT_DEBUG(DRSUAPI_INTER_DOMAIN_MOVE, &r);
1773         }
1774
1775         if (NT_STATUS_IS_ERR(status)) {
1776                 return status;
1777         }
1778
1779         /* Return variables */
1780
1781         /* Return result */
1782         if (werror) {
1783                 *werror = r.out.result;
1784         }
1785
1786         return werror_to_ntstatus(r.out.result);
1787 }
1788
1789 struct rpccli_drsuapi_DsGetNT4ChangeLog_state {
1790         struct drsuapi_DsGetNT4ChangeLog orig;
1791         struct drsuapi_DsGetNT4ChangeLog tmp;
1792         TALLOC_CTX *out_mem_ctx;
1793         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1794 };
1795
1796 static void rpccli_drsuapi_DsGetNT4ChangeLog_done(struct tevent_req *subreq);
1797
1798 struct tevent_req *rpccli_drsuapi_DsGetNT4ChangeLog_send(TALLOC_CTX *mem_ctx,
1799                                                          struct tevent_context *ev,
1800                                                          struct rpc_pipe_client *cli,
1801                                                          struct policy_handle *_bind_handle /* [in] [ref] */,
1802                                                          uint32_t _level /* [in]  */,
1803                                                          union drsuapi_DsGetNT4ChangeLogRequest *_req /* [in] [ref,switch_is(level)] */,
1804                                                          uint32_t *_level_out /* [out] [ref] */,
1805                                                          union drsuapi_DsGetNT4ChangeLogInfo *_info /* [out] [ref,switch_is(*level_out)] */)
1806 {
1807         struct tevent_req *req;
1808         struct rpccli_drsuapi_DsGetNT4ChangeLog_state *state;
1809         struct tevent_req *subreq;
1810
1811         req = tevent_req_create(mem_ctx, &state,
1812                                 struct rpccli_drsuapi_DsGetNT4ChangeLog_state);
1813         if (req == NULL) {
1814                 return NULL;
1815         }
1816         state->out_mem_ctx = NULL;
1817         state->dispatch_recv = cli->dispatch_recv;
1818
1819         /* In parameters */
1820         state->orig.in.bind_handle = _bind_handle;
1821         state->orig.in.level = _level;
1822         state->orig.in.req = _req;
1823
1824         /* Out parameters */
1825         state->orig.out.level_out = _level_out;
1826         state->orig.out.info = _info;
1827
1828         /* Result */
1829         ZERO_STRUCT(state->orig.out.result);
1830
1831         if (DEBUGLEVEL >= 10) {
1832                 NDR_PRINT_IN_DEBUG(drsuapi_DsGetNT4ChangeLog, &state->orig);
1833         }
1834
1835         state->out_mem_ctx = talloc_named_const(state, 0,
1836                              "rpccli_drsuapi_DsGetNT4ChangeLog_out_memory");
1837         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1838                 return tevent_req_post(req, ev);
1839         }
1840
1841         /* make a temporary copy, that we pass to the dispatch function */
1842         state->tmp = state->orig;
1843
1844         subreq = cli->dispatch_send(state, ev, cli,
1845                                     &ndr_table_drsuapi,
1846                                     NDR_DRSUAPI_DSGETNT4CHANGELOG,
1847                                     &state->tmp);
1848         if (tevent_req_nomem(subreq, req)) {
1849                 return tevent_req_post(req, ev);
1850         }
1851         tevent_req_set_callback(subreq, rpccli_drsuapi_DsGetNT4ChangeLog_done, req);
1852         return req;
1853 }
1854
1855 static void rpccli_drsuapi_DsGetNT4ChangeLog_done(struct tevent_req *subreq)
1856 {
1857         struct tevent_req *req = tevent_req_callback_data(
1858                 subreq, struct tevent_req);
1859         struct rpccli_drsuapi_DsGetNT4ChangeLog_state *state = tevent_req_data(
1860                 req, struct rpccli_drsuapi_DsGetNT4ChangeLog_state);
1861         NTSTATUS status;
1862         TALLOC_CTX *mem_ctx;
1863
1864         if (state->out_mem_ctx) {
1865                 mem_ctx = state->out_mem_ctx;
1866         } else {
1867                 mem_ctx = state;
1868         }
1869
1870         status = state->dispatch_recv(subreq, mem_ctx);
1871         TALLOC_FREE(subreq);
1872         if (!NT_STATUS_IS_OK(status)) {
1873                 tevent_req_nterror(req, status);
1874                 return;
1875         }
1876
1877         /* Copy out parameters */
1878         *state->orig.out.level_out = *state->tmp.out.level_out;
1879         *state->orig.out.info = *state->tmp.out.info;
1880
1881         /* Copy result */
1882         state->orig.out.result = state->tmp.out.result;
1883
1884         /* Reset temporary structure */
1885         ZERO_STRUCT(state->tmp);
1886
1887         if (DEBUGLEVEL >= 10) {
1888                 NDR_PRINT_OUT_DEBUG(drsuapi_DsGetNT4ChangeLog, &state->orig);
1889         }
1890
1891         tevent_req_done(req);
1892 }
1893
1894 NTSTATUS rpccli_drsuapi_DsGetNT4ChangeLog_recv(struct tevent_req *req,
1895                                                TALLOC_CTX *mem_ctx,
1896                                                WERROR *result)
1897 {
1898         struct rpccli_drsuapi_DsGetNT4ChangeLog_state *state = tevent_req_data(
1899                 req, struct rpccli_drsuapi_DsGetNT4ChangeLog_state);
1900         NTSTATUS status;
1901
1902         if (tevent_req_is_nterror(req, &status)) {
1903                 tevent_req_received(req);
1904                 return status;
1905         }
1906
1907         /* Steal possbile out parameters to the callers context */
1908         talloc_steal(mem_ctx, state->out_mem_ctx);
1909
1910         /* Return result */
1911         *result = state->orig.out.result;
1912
1913         tevent_req_received(req);
1914         return NT_STATUS_OK;
1915 }
1916
1917 NTSTATUS rpccli_drsuapi_DsGetNT4ChangeLog(struct rpc_pipe_client *cli,
1918                                           TALLOC_CTX *mem_ctx,
1919                                           struct policy_handle *bind_handle /* [in] [ref] */,
1920                                           uint32_t level /* [in]  */,
1921                                           union drsuapi_DsGetNT4ChangeLogRequest *req /* [in] [ref,switch_is(level)] */,
1922                                           uint32_t *level_out /* [out] [ref] */,
1923                                           union drsuapi_DsGetNT4ChangeLogInfo *info /* [out] [ref,switch_is(*level_out)] */,
1924                                           WERROR *werror)
1925 {
1926         struct drsuapi_DsGetNT4ChangeLog r;
1927         NTSTATUS status;
1928
1929         /* In parameters */
1930         r.in.bind_handle = bind_handle;
1931         r.in.level = level;
1932         r.in.req = req;
1933
1934         if (DEBUGLEVEL >= 10) {
1935                 NDR_PRINT_IN_DEBUG(drsuapi_DsGetNT4ChangeLog, &r);
1936         }
1937
1938         status = cli->dispatch(cli,
1939                                 mem_ctx,
1940                                 &ndr_table_drsuapi,
1941                                 NDR_DRSUAPI_DSGETNT4CHANGELOG,
1942                                 &r);
1943
1944         if (!NT_STATUS_IS_OK(status)) {
1945                 return status;
1946         }
1947
1948         if (DEBUGLEVEL >= 10) {
1949                 NDR_PRINT_OUT_DEBUG(drsuapi_DsGetNT4ChangeLog, &r);
1950         }
1951
1952         if (NT_STATUS_IS_ERR(status)) {
1953                 return status;
1954         }
1955
1956         /* Return variables */
1957         *level_out = *r.out.level_out;
1958         *info = *r.out.info;
1959
1960         /* Return result */
1961         if (werror) {
1962                 *werror = r.out.result;
1963         }
1964
1965         return werror_to_ntstatus(r.out.result);
1966 }
1967
1968 struct rpccli_drsuapi_DsCrackNames_state {
1969         struct drsuapi_DsCrackNames orig;
1970         struct drsuapi_DsCrackNames tmp;
1971         TALLOC_CTX *out_mem_ctx;
1972         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1973 };
1974
1975 static void rpccli_drsuapi_DsCrackNames_done(struct tevent_req *subreq);
1976
1977 struct tevent_req *rpccli_drsuapi_DsCrackNames_send(TALLOC_CTX *mem_ctx,
1978                                                     struct tevent_context *ev,
1979                                                     struct rpc_pipe_client *cli,
1980                                                     struct policy_handle *_bind_handle /* [in] [ref] */,
1981                                                     int32_t _level /* [in]  */,
1982                                                     union drsuapi_DsNameRequest *_req /* [in] [ref,switch_is(level)] */,
1983                                                     int32_t *_level_out /* [out] [ref] */,
1984                                                     union drsuapi_DsNameCtr *_ctr /* [out] [ref,switch_is(*level_out)] */)
1985 {
1986         struct tevent_req *req;
1987         struct rpccli_drsuapi_DsCrackNames_state *state;
1988         struct tevent_req *subreq;
1989
1990         req = tevent_req_create(mem_ctx, &state,
1991                                 struct rpccli_drsuapi_DsCrackNames_state);
1992         if (req == NULL) {
1993                 return NULL;
1994         }
1995         state->out_mem_ctx = NULL;
1996         state->dispatch_recv = cli->dispatch_recv;
1997
1998         /* In parameters */
1999         state->orig.in.bind_handle = _bind_handle;
2000         state->orig.in.level = _level;
2001         state->orig.in.req = _req;
2002
2003         /* Out parameters */
2004         state->orig.out.level_out = _level_out;
2005         state->orig.out.ctr = _ctr;
2006
2007         /* Result */
2008         ZERO_STRUCT(state->orig.out.result);
2009
2010         if (DEBUGLEVEL >= 10) {
2011                 NDR_PRINT_IN_DEBUG(drsuapi_DsCrackNames, &state->orig);
2012         }
2013
2014         state->out_mem_ctx = talloc_named_const(state, 0,
2015                              "rpccli_drsuapi_DsCrackNames_out_memory");
2016         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2017                 return tevent_req_post(req, ev);
2018         }
2019
2020         /* make a temporary copy, that we pass to the dispatch function */
2021         state->tmp = state->orig;
2022
2023         subreq = cli->dispatch_send(state, ev, cli,
2024                                     &ndr_table_drsuapi,
2025                                     NDR_DRSUAPI_DSCRACKNAMES,
2026                                     &state->tmp);
2027         if (tevent_req_nomem(subreq, req)) {
2028                 return tevent_req_post(req, ev);
2029         }
2030         tevent_req_set_callback(subreq, rpccli_drsuapi_DsCrackNames_done, req);
2031         return req;
2032 }
2033
2034 static void rpccli_drsuapi_DsCrackNames_done(struct tevent_req *subreq)
2035 {
2036         struct tevent_req *req = tevent_req_callback_data(
2037                 subreq, struct tevent_req);
2038         struct rpccli_drsuapi_DsCrackNames_state *state = tevent_req_data(
2039                 req, struct rpccli_drsuapi_DsCrackNames_state);
2040         NTSTATUS status;
2041         TALLOC_CTX *mem_ctx;
2042
2043         if (state->out_mem_ctx) {
2044                 mem_ctx = state->out_mem_ctx;
2045         } else {
2046                 mem_ctx = state;
2047         }
2048
2049         status = state->dispatch_recv(subreq, mem_ctx);
2050         TALLOC_FREE(subreq);
2051         if (!NT_STATUS_IS_OK(status)) {
2052                 tevent_req_nterror(req, status);
2053                 return;
2054         }
2055
2056         /* Copy out parameters */
2057         *state->orig.out.level_out = *state->tmp.out.level_out;
2058         *state->orig.out.ctr = *state->tmp.out.ctr;
2059
2060         /* Copy result */
2061         state->orig.out.result = state->tmp.out.result;
2062
2063         /* Reset temporary structure */
2064         ZERO_STRUCT(state->tmp);
2065
2066         if (DEBUGLEVEL >= 10) {
2067                 NDR_PRINT_OUT_DEBUG(drsuapi_DsCrackNames, &state->orig);
2068         }
2069
2070         tevent_req_done(req);
2071 }
2072
2073 NTSTATUS rpccli_drsuapi_DsCrackNames_recv(struct tevent_req *req,
2074                                           TALLOC_CTX *mem_ctx,
2075                                           WERROR *result)
2076 {
2077         struct rpccli_drsuapi_DsCrackNames_state *state = tevent_req_data(
2078                 req, struct rpccli_drsuapi_DsCrackNames_state);
2079         NTSTATUS status;
2080
2081         if (tevent_req_is_nterror(req, &status)) {
2082                 tevent_req_received(req);
2083                 return status;
2084         }
2085
2086         /* Steal possbile out parameters to the callers context */
2087         talloc_steal(mem_ctx, state->out_mem_ctx);
2088
2089         /* Return result */
2090         *result = state->orig.out.result;
2091
2092         tevent_req_received(req);
2093         return NT_STATUS_OK;
2094 }
2095
2096 NTSTATUS rpccli_drsuapi_DsCrackNames(struct rpc_pipe_client *cli,
2097                                      TALLOC_CTX *mem_ctx,
2098                                      struct policy_handle *bind_handle /* [in] [ref] */,
2099                                      int32_t level /* [in]  */,
2100                                      union drsuapi_DsNameRequest *req /* [in] [ref,switch_is(level)] */,
2101                                      int32_t *level_out /* [out] [ref] */,
2102                                      union drsuapi_DsNameCtr *ctr /* [out] [ref,switch_is(*level_out)] */,
2103                                      WERROR *werror)
2104 {
2105         struct drsuapi_DsCrackNames r;
2106         NTSTATUS status;
2107
2108         /* In parameters */
2109         r.in.bind_handle = bind_handle;
2110         r.in.level = level;
2111         r.in.req = req;
2112
2113         if (DEBUGLEVEL >= 10) {
2114                 NDR_PRINT_IN_DEBUG(drsuapi_DsCrackNames, &r);
2115         }
2116
2117         status = cli->dispatch(cli,
2118                                 mem_ctx,
2119                                 &ndr_table_drsuapi,
2120                                 NDR_DRSUAPI_DSCRACKNAMES,
2121                                 &r);
2122
2123         if (!NT_STATUS_IS_OK(status)) {
2124                 return status;
2125         }
2126
2127         if (DEBUGLEVEL >= 10) {
2128                 NDR_PRINT_OUT_DEBUG(drsuapi_DsCrackNames, &r);
2129         }
2130
2131         if (NT_STATUS_IS_ERR(status)) {
2132                 return status;
2133         }
2134
2135         /* Return variables */
2136         *level_out = *r.out.level_out;
2137         *ctr = *r.out.ctr;
2138
2139         /* Return result */
2140         if (werror) {
2141                 *werror = r.out.result;
2142         }
2143
2144         return werror_to_ntstatus(r.out.result);
2145 }
2146
2147 struct rpccli_drsuapi_DsWriteAccountSpn_state {
2148         struct drsuapi_DsWriteAccountSpn orig;
2149         struct drsuapi_DsWriteAccountSpn tmp;
2150         TALLOC_CTX *out_mem_ctx;
2151         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2152 };
2153
2154 static void rpccli_drsuapi_DsWriteAccountSpn_done(struct tevent_req *subreq);
2155
2156 struct tevent_req *rpccli_drsuapi_DsWriteAccountSpn_send(TALLOC_CTX *mem_ctx,
2157                                                          struct tevent_context *ev,
2158                                                          struct rpc_pipe_client *cli,
2159                                                          struct policy_handle *_bind_handle /* [in] [ref] */,
2160                                                          int32_t _level /* [in]  */,
2161                                                          union drsuapi_DsWriteAccountSpnRequest *_req /* [in] [ref,switch_is(level)] */,
2162                                                          int32_t *_level_out /* [out] [ref] */,
2163                                                          union drsuapi_DsWriteAccountSpnResult *_res /* [out] [ref,switch_is(*level_out)] */)
2164 {
2165         struct tevent_req *req;
2166         struct rpccli_drsuapi_DsWriteAccountSpn_state *state;
2167         struct tevent_req *subreq;
2168
2169         req = tevent_req_create(mem_ctx, &state,
2170                                 struct rpccli_drsuapi_DsWriteAccountSpn_state);
2171         if (req == NULL) {
2172                 return NULL;
2173         }
2174         state->out_mem_ctx = NULL;
2175         state->dispatch_recv = cli->dispatch_recv;
2176
2177         /* In parameters */
2178         state->orig.in.bind_handle = _bind_handle;
2179         state->orig.in.level = _level;
2180         state->orig.in.req = _req;
2181
2182         /* Out parameters */
2183         state->orig.out.level_out = _level_out;
2184         state->orig.out.res = _res;
2185
2186         /* Result */
2187         ZERO_STRUCT(state->orig.out.result);
2188
2189         if (DEBUGLEVEL >= 10) {
2190                 NDR_PRINT_IN_DEBUG(drsuapi_DsWriteAccountSpn, &state->orig);
2191         }
2192
2193         state->out_mem_ctx = talloc_named_const(state, 0,
2194                              "rpccli_drsuapi_DsWriteAccountSpn_out_memory");
2195         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2196                 return tevent_req_post(req, ev);
2197         }
2198
2199         /* make a temporary copy, that we pass to the dispatch function */
2200         state->tmp = state->orig;
2201
2202         subreq = cli->dispatch_send(state, ev, cli,
2203                                     &ndr_table_drsuapi,
2204                                     NDR_DRSUAPI_DSWRITEACCOUNTSPN,
2205                                     &state->tmp);
2206         if (tevent_req_nomem(subreq, req)) {
2207                 return tevent_req_post(req, ev);
2208         }
2209         tevent_req_set_callback(subreq, rpccli_drsuapi_DsWriteAccountSpn_done, req);
2210         return req;
2211 }
2212
2213 static void rpccli_drsuapi_DsWriteAccountSpn_done(struct tevent_req *subreq)
2214 {
2215         struct tevent_req *req = tevent_req_callback_data(
2216                 subreq, struct tevent_req);
2217         struct rpccli_drsuapi_DsWriteAccountSpn_state *state = tevent_req_data(
2218                 req, struct rpccli_drsuapi_DsWriteAccountSpn_state);
2219         NTSTATUS status;
2220         TALLOC_CTX *mem_ctx;
2221
2222         if (state->out_mem_ctx) {
2223                 mem_ctx = state->out_mem_ctx;
2224         } else {
2225                 mem_ctx = state;
2226         }
2227
2228         status = state->dispatch_recv(subreq, mem_ctx);
2229         TALLOC_FREE(subreq);
2230         if (!NT_STATUS_IS_OK(status)) {
2231                 tevent_req_nterror(req, status);
2232                 return;
2233         }
2234
2235         /* Copy out parameters */
2236         *state->orig.out.level_out = *state->tmp.out.level_out;
2237         *state->orig.out.res = *state->tmp.out.res;
2238
2239         /* Copy result */
2240         state->orig.out.result = state->tmp.out.result;
2241
2242         /* Reset temporary structure */
2243         ZERO_STRUCT(state->tmp);
2244
2245         if (DEBUGLEVEL >= 10) {
2246                 NDR_PRINT_OUT_DEBUG(drsuapi_DsWriteAccountSpn, &state->orig);
2247         }
2248
2249         tevent_req_done(req);
2250 }
2251
2252 NTSTATUS rpccli_drsuapi_DsWriteAccountSpn_recv(struct tevent_req *req,
2253                                                TALLOC_CTX *mem_ctx,
2254                                                WERROR *result)
2255 {
2256         struct rpccli_drsuapi_DsWriteAccountSpn_state *state = tevent_req_data(
2257                 req, struct rpccli_drsuapi_DsWriteAccountSpn_state);
2258         NTSTATUS status;
2259
2260         if (tevent_req_is_nterror(req, &status)) {
2261                 tevent_req_received(req);
2262                 return status;
2263         }
2264
2265         /* Steal possbile out parameters to the callers context */
2266         talloc_steal(mem_ctx, state->out_mem_ctx);
2267
2268         /* Return result */
2269         *result = state->orig.out.result;
2270
2271         tevent_req_received(req);
2272         return NT_STATUS_OK;
2273 }
2274
2275 NTSTATUS rpccli_drsuapi_DsWriteAccountSpn(struct rpc_pipe_client *cli,
2276                                           TALLOC_CTX *mem_ctx,
2277                                           struct policy_handle *bind_handle /* [in] [ref] */,
2278                                           int32_t level /* [in]  */,
2279                                           union drsuapi_DsWriteAccountSpnRequest *req /* [in] [ref,switch_is(level)] */,
2280                                           int32_t *level_out /* [out] [ref] */,
2281                                           union drsuapi_DsWriteAccountSpnResult *res /* [out] [ref,switch_is(*level_out)] */,
2282                                           WERROR *werror)
2283 {
2284         struct drsuapi_DsWriteAccountSpn r;
2285         NTSTATUS status;
2286
2287         /* In parameters */
2288         r.in.bind_handle = bind_handle;
2289         r.in.level = level;
2290         r.in.req = req;
2291
2292         if (DEBUGLEVEL >= 10) {
2293                 NDR_PRINT_IN_DEBUG(drsuapi_DsWriteAccountSpn, &r);
2294         }
2295
2296         status = cli->dispatch(cli,
2297                                 mem_ctx,
2298                                 &ndr_table_drsuapi,
2299                                 NDR_DRSUAPI_DSWRITEACCOUNTSPN,
2300                                 &r);
2301
2302         if (!NT_STATUS_IS_OK(status)) {
2303                 return status;
2304         }
2305
2306         if (DEBUGLEVEL >= 10) {
2307                 NDR_PRINT_OUT_DEBUG(drsuapi_DsWriteAccountSpn, &r);
2308         }
2309
2310         if (NT_STATUS_IS_ERR(status)) {
2311                 return status;
2312         }
2313
2314         /* Return variables */
2315         *level_out = *r.out.level_out;
2316         *res = *r.out.res;
2317
2318         /* Return result */
2319         if (werror) {
2320                 *werror = r.out.result;
2321         }
2322
2323         return werror_to_ntstatus(r.out.result);
2324 }
2325
2326 struct rpccli_drsuapi_DsRemoveDSServer_state {
2327         struct drsuapi_DsRemoveDSServer orig;
2328         struct drsuapi_DsRemoveDSServer tmp;
2329         TALLOC_CTX *out_mem_ctx;
2330         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2331 };
2332
2333 static void rpccli_drsuapi_DsRemoveDSServer_done(struct tevent_req *subreq);
2334
2335 struct tevent_req *rpccli_drsuapi_DsRemoveDSServer_send(TALLOC_CTX *mem_ctx,
2336                                                         struct tevent_context *ev,
2337                                                         struct rpc_pipe_client *cli,
2338                                                         struct policy_handle *_bind_handle /* [in] [ref] */,
2339                                                         int32_t _level /* [in]  */,
2340                                                         union drsuapi_DsRemoveDSServerRequest *_req /* [in] [ref,switch_is(level)] */,
2341                                                         int32_t *_level_out /* [out] [ref] */,
2342                                                         union drsuapi_DsRemoveDSServerResult *_res /* [out] [ref,switch_is(*level_out)] */)
2343 {
2344         struct tevent_req *req;
2345         struct rpccli_drsuapi_DsRemoveDSServer_state *state;
2346         struct tevent_req *subreq;
2347
2348         req = tevent_req_create(mem_ctx, &state,
2349                                 struct rpccli_drsuapi_DsRemoveDSServer_state);
2350         if (req == NULL) {
2351                 return NULL;
2352         }
2353         state->out_mem_ctx = NULL;
2354         state->dispatch_recv = cli->dispatch_recv;
2355
2356         /* In parameters */
2357         state->orig.in.bind_handle = _bind_handle;
2358         state->orig.in.level = _level;
2359         state->orig.in.req = _req;
2360
2361         /* Out parameters */
2362         state->orig.out.level_out = _level_out;
2363         state->orig.out.res = _res;
2364
2365         /* Result */
2366         ZERO_STRUCT(state->orig.out.result);
2367
2368         if (DEBUGLEVEL >= 10) {
2369                 NDR_PRINT_IN_DEBUG(drsuapi_DsRemoveDSServer, &state->orig);
2370         }
2371
2372         state->out_mem_ctx = talloc_named_const(state, 0,
2373                              "rpccli_drsuapi_DsRemoveDSServer_out_memory");
2374         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2375                 return tevent_req_post(req, ev);
2376         }
2377
2378         /* make a temporary copy, that we pass to the dispatch function */
2379         state->tmp = state->orig;
2380
2381         subreq = cli->dispatch_send(state, ev, cli,
2382                                     &ndr_table_drsuapi,
2383                                     NDR_DRSUAPI_DSREMOVEDSSERVER,
2384                                     &state->tmp);
2385         if (tevent_req_nomem(subreq, req)) {
2386                 return tevent_req_post(req, ev);
2387         }
2388         tevent_req_set_callback(subreq, rpccli_drsuapi_DsRemoveDSServer_done, req);
2389         return req;
2390 }
2391
2392 static void rpccli_drsuapi_DsRemoveDSServer_done(struct tevent_req *subreq)
2393 {
2394         struct tevent_req *req = tevent_req_callback_data(
2395                 subreq, struct tevent_req);
2396         struct rpccli_drsuapi_DsRemoveDSServer_state *state = tevent_req_data(
2397                 req, struct rpccli_drsuapi_DsRemoveDSServer_state);
2398         NTSTATUS status;
2399         TALLOC_CTX *mem_ctx;
2400
2401         if (state->out_mem_ctx) {
2402                 mem_ctx = state->out_mem_ctx;
2403         } else {
2404                 mem_ctx = state;
2405         }
2406
2407         status = state->dispatch_recv(subreq, mem_ctx);
2408         TALLOC_FREE(subreq);
2409         if (!NT_STATUS_IS_OK(status)) {
2410                 tevent_req_nterror(req, status);
2411                 return;
2412         }
2413
2414         /* Copy out parameters */
2415         *state->orig.out.level_out = *state->tmp.out.level_out;
2416         *state->orig.out.res = *state->tmp.out.res;
2417
2418         /* Copy result */
2419         state->orig.out.result = state->tmp.out.result;
2420
2421         /* Reset temporary structure */
2422         ZERO_STRUCT(state->tmp);
2423
2424         if (DEBUGLEVEL >= 10) {
2425                 NDR_PRINT_OUT_DEBUG(drsuapi_DsRemoveDSServer, &state->orig);
2426         }
2427
2428         tevent_req_done(req);
2429 }
2430
2431 NTSTATUS rpccli_drsuapi_DsRemoveDSServer_recv(struct tevent_req *req,
2432                                               TALLOC_CTX *mem_ctx,
2433                                               WERROR *result)
2434 {
2435         struct rpccli_drsuapi_DsRemoveDSServer_state *state = tevent_req_data(
2436                 req, struct rpccli_drsuapi_DsRemoveDSServer_state);
2437         NTSTATUS status;
2438
2439         if (tevent_req_is_nterror(req, &status)) {
2440                 tevent_req_received(req);
2441                 return status;
2442         }
2443
2444         /* Steal possbile out parameters to the callers context */
2445         talloc_steal(mem_ctx, state->out_mem_ctx);
2446
2447         /* Return result */
2448         *result = state->orig.out.result;
2449
2450         tevent_req_received(req);
2451         return NT_STATUS_OK;
2452 }
2453
2454 NTSTATUS rpccli_drsuapi_DsRemoveDSServer(struct rpc_pipe_client *cli,
2455                                          TALLOC_CTX *mem_ctx,
2456                                          struct policy_handle *bind_handle /* [in] [ref] */,
2457                                          int32_t level /* [in]  */,
2458                                          union drsuapi_DsRemoveDSServerRequest *req /* [in] [ref,switch_is(level)] */,
2459                                          int32_t *level_out /* [out] [ref] */,
2460                                          union drsuapi_DsRemoveDSServerResult *res /* [out] [ref,switch_is(*level_out)] */,
2461                                          WERROR *werror)
2462 {
2463         struct drsuapi_DsRemoveDSServer r;
2464         NTSTATUS status;
2465
2466         /* In parameters */
2467         r.in.bind_handle = bind_handle;
2468         r.in.level = level;
2469         r.in.req = req;
2470
2471         if (DEBUGLEVEL >= 10) {
2472                 NDR_PRINT_IN_DEBUG(drsuapi_DsRemoveDSServer, &r);
2473         }
2474
2475         status = cli->dispatch(cli,
2476                                 mem_ctx,
2477                                 &ndr_table_drsuapi,
2478                                 NDR_DRSUAPI_DSREMOVEDSSERVER,
2479                                 &r);
2480
2481         if (!NT_STATUS_IS_OK(status)) {
2482                 return status;
2483         }
2484
2485         if (DEBUGLEVEL >= 10) {
2486                 NDR_PRINT_OUT_DEBUG(drsuapi_DsRemoveDSServer, &r);
2487         }
2488
2489         if (NT_STATUS_IS_ERR(status)) {
2490                 return status;
2491         }
2492
2493         /* Return variables */
2494         *level_out = *r.out.level_out;
2495         *res = *r.out.res;
2496
2497         /* Return result */
2498         if (werror) {
2499                 *werror = r.out.result;
2500         }
2501
2502         return werror_to_ntstatus(r.out.result);
2503 }
2504
2505 struct rpccli_DRSUAPI_REMOVE_DS_DOMAIN_state {
2506         struct DRSUAPI_REMOVE_DS_DOMAIN orig;
2507         struct DRSUAPI_REMOVE_DS_DOMAIN tmp;
2508         TALLOC_CTX *out_mem_ctx;
2509         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2510 };
2511
2512 static void rpccli_DRSUAPI_REMOVE_DS_DOMAIN_done(struct tevent_req *subreq);
2513
2514 struct tevent_req *rpccli_DRSUAPI_REMOVE_DS_DOMAIN_send(TALLOC_CTX *mem_ctx,
2515                                                         struct tevent_context *ev,
2516                                                         struct rpc_pipe_client *cli)
2517 {
2518         struct tevent_req *req;
2519         struct rpccli_DRSUAPI_REMOVE_DS_DOMAIN_state *state;
2520         struct tevent_req *subreq;
2521
2522         req = tevent_req_create(mem_ctx, &state,
2523                                 struct rpccli_DRSUAPI_REMOVE_DS_DOMAIN_state);
2524         if (req == NULL) {
2525                 return NULL;
2526         }
2527         state->out_mem_ctx = NULL;
2528         state->dispatch_recv = cli->dispatch_recv;
2529
2530         /* In parameters */
2531
2532         /* Out parameters */
2533
2534         /* Result */
2535         ZERO_STRUCT(state->orig.out.result);
2536
2537         if (DEBUGLEVEL >= 10) {
2538                 NDR_PRINT_IN_DEBUG(DRSUAPI_REMOVE_DS_DOMAIN, &state->orig);
2539         }
2540
2541         /* make a temporary copy, that we pass to the dispatch function */
2542         state->tmp = state->orig;
2543
2544         subreq = cli->dispatch_send(state, ev, cli,
2545                                     &ndr_table_drsuapi,
2546                                     NDR_DRSUAPI_REMOVE_DS_DOMAIN,
2547                                     &state->tmp);
2548         if (tevent_req_nomem(subreq, req)) {
2549                 return tevent_req_post(req, ev);
2550         }
2551         tevent_req_set_callback(subreq, rpccli_DRSUAPI_REMOVE_DS_DOMAIN_done, req);
2552         return req;
2553 }
2554
2555 static void rpccli_DRSUAPI_REMOVE_DS_DOMAIN_done(struct tevent_req *subreq)
2556 {
2557         struct tevent_req *req = tevent_req_callback_data(
2558                 subreq, struct tevent_req);
2559         struct rpccli_DRSUAPI_REMOVE_DS_DOMAIN_state *state = tevent_req_data(
2560                 req, struct rpccli_DRSUAPI_REMOVE_DS_DOMAIN_state);
2561         NTSTATUS status;
2562         TALLOC_CTX *mem_ctx;
2563
2564         if (state->out_mem_ctx) {
2565                 mem_ctx = state->out_mem_ctx;
2566         } else {
2567                 mem_ctx = state;
2568         }
2569
2570         status = state->dispatch_recv(subreq, mem_ctx);
2571         TALLOC_FREE(subreq);
2572         if (!NT_STATUS_IS_OK(status)) {
2573                 tevent_req_nterror(req, status);
2574                 return;
2575         }
2576
2577         /* Copy out parameters */
2578
2579         /* Copy result */
2580         state->orig.out.result = state->tmp.out.result;
2581
2582         /* Reset temporary structure */
2583         ZERO_STRUCT(state->tmp);
2584
2585         if (DEBUGLEVEL >= 10) {
2586                 NDR_PRINT_OUT_DEBUG(DRSUAPI_REMOVE_DS_DOMAIN, &state->orig);
2587         }
2588
2589         tevent_req_done(req);
2590 }
2591
2592 NTSTATUS rpccli_DRSUAPI_REMOVE_DS_DOMAIN_recv(struct tevent_req *req,
2593                                               TALLOC_CTX *mem_ctx,
2594                                               WERROR *result)
2595 {
2596         struct rpccli_DRSUAPI_REMOVE_DS_DOMAIN_state *state = tevent_req_data(
2597                 req, struct rpccli_DRSUAPI_REMOVE_DS_DOMAIN_state);
2598         NTSTATUS status;
2599
2600         if (tevent_req_is_nterror(req, &status)) {
2601                 tevent_req_received(req);
2602                 return status;
2603         }
2604
2605         /* Steal possbile out parameters to the callers context */
2606         talloc_steal(mem_ctx, state->out_mem_ctx);
2607
2608         /* Return result */
2609         *result = state->orig.out.result;
2610
2611         tevent_req_received(req);
2612         return NT_STATUS_OK;
2613 }
2614
2615 NTSTATUS rpccli_DRSUAPI_REMOVE_DS_DOMAIN(struct rpc_pipe_client *cli,
2616                                          TALLOC_CTX *mem_ctx,
2617                                          WERROR *werror)
2618 {
2619         struct DRSUAPI_REMOVE_DS_DOMAIN r;
2620         NTSTATUS status;
2621
2622         /* In parameters */
2623
2624         if (DEBUGLEVEL >= 10) {
2625                 NDR_PRINT_IN_DEBUG(DRSUAPI_REMOVE_DS_DOMAIN, &r);
2626         }
2627
2628         status = cli->dispatch(cli,
2629                                 mem_ctx,
2630                                 &ndr_table_drsuapi,
2631                                 NDR_DRSUAPI_REMOVE_DS_DOMAIN,
2632                                 &r);
2633
2634         if (!NT_STATUS_IS_OK(status)) {
2635                 return status;
2636         }
2637
2638         if (DEBUGLEVEL >= 10) {
2639                 NDR_PRINT_OUT_DEBUG(DRSUAPI_REMOVE_DS_DOMAIN, &r);
2640         }
2641
2642         if (NT_STATUS_IS_ERR(status)) {
2643                 return status;
2644         }
2645
2646         /* Return variables */
2647
2648         /* Return result */
2649         if (werror) {
2650                 *werror = r.out.result;
2651         }
2652
2653         return werror_to_ntstatus(r.out.result);
2654 }
2655
2656 struct rpccli_drsuapi_DsGetDomainControllerInfo_state {
2657         struct drsuapi_DsGetDomainControllerInfo orig;
2658         struct drsuapi_DsGetDomainControllerInfo tmp;
2659         TALLOC_CTX *out_mem_ctx;
2660         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2661 };
2662
2663 static void rpccli_drsuapi_DsGetDomainControllerInfo_done(struct tevent_req *subreq);
2664
2665 struct tevent_req *rpccli_drsuapi_DsGetDomainControllerInfo_send(TALLOC_CTX *mem_ctx,
2666                                                                  struct tevent_context *ev,
2667                                                                  struct rpc_pipe_client *cli,
2668                                                                  struct policy_handle *_bind_handle /* [in] [ref] */,
2669                                                                  int32_t _level /* [in]  */,
2670                                                                  union drsuapi_DsGetDCInfoRequest *_req /* [in] [ref,switch_is(level)] */,
2671                                                                  int32_t *_level_out /* [out] [ref] */,
2672                                                                  union drsuapi_DsGetDCInfoCtr *_ctr /* [out] [ref,switch_is(*level_out)] */)
2673 {
2674         struct tevent_req *req;
2675         struct rpccli_drsuapi_DsGetDomainControllerInfo_state *state;
2676         struct tevent_req *subreq;
2677
2678         req = tevent_req_create(mem_ctx, &state,
2679                                 struct rpccli_drsuapi_DsGetDomainControllerInfo_state);
2680         if (req == NULL) {
2681                 return NULL;
2682         }
2683         state->out_mem_ctx = NULL;
2684         state->dispatch_recv = cli->dispatch_recv;
2685
2686         /* In parameters */
2687         state->orig.in.bind_handle = _bind_handle;
2688         state->orig.in.level = _level;
2689         state->orig.in.req = _req;
2690
2691         /* Out parameters */
2692         state->orig.out.level_out = _level_out;
2693         state->orig.out.ctr = _ctr;
2694
2695         /* Result */
2696         ZERO_STRUCT(state->orig.out.result);
2697
2698         if (DEBUGLEVEL >= 10) {
2699                 NDR_PRINT_IN_DEBUG(drsuapi_DsGetDomainControllerInfo, &state->orig);
2700         }
2701
2702         state->out_mem_ctx = talloc_named_const(state, 0,
2703                              "rpccli_drsuapi_DsGetDomainControllerInfo_out_memory");
2704         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2705                 return tevent_req_post(req, ev);
2706         }
2707
2708         /* make a temporary copy, that we pass to the dispatch function */
2709         state->tmp = state->orig;
2710
2711         subreq = cli->dispatch_send(state, ev, cli,
2712                                     &ndr_table_drsuapi,
2713                                     NDR_DRSUAPI_DSGETDOMAINCONTROLLERINFO,
2714                                     &state->tmp);
2715         if (tevent_req_nomem(subreq, req)) {
2716                 return tevent_req_post(req, ev);
2717         }
2718         tevent_req_set_callback(subreq, rpccli_drsuapi_DsGetDomainControllerInfo_done, req);
2719         return req;
2720 }
2721
2722 static void rpccli_drsuapi_DsGetDomainControllerInfo_done(struct tevent_req *subreq)
2723 {
2724         struct tevent_req *req = tevent_req_callback_data(
2725                 subreq, struct tevent_req);
2726         struct rpccli_drsuapi_DsGetDomainControllerInfo_state *state = tevent_req_data(
2727                 req, struct rpccli_drsuapi_DsGetDomainControllerInfo_state);
2728         NTSTATUS status;
2729         TALLOC_CTX *mem_ctx;
2730
2731         if (state->out_mem_ctx) {
2732                 mem_ctx = state->out_mem_ctx;
2733         } else {
2734                 mem_ctx = state;
2735         }
2736
2737         status = state->dispatch_recv(subreq, mem_ctx);
2738         TALLOC_FREE(subreq);
2739         if (!NT_STATUS_IS_OK(status)) {
2740                 tevent_req_nterror(req, status);
2741                 return;
2742         }
2743
2744         /* Copy out parameters */
2745         *state->orig.out.level_out = *state->tmp.out.level_out;
2746         *state->orig.out.ctr = *state->tmp.out.ctr;
2747
2748         /* Copy result */
2749         state->orig.out.result = state->tmp.out.result;
2750
2751         /* Reset temporary structure */
2752         ZERO_STRUCT(state->tmp);
2753
2754         if (DEBUGLEVEL >= 10) {
2755                 NDR_PRINT_OUT_DEBUG(drsuapi_DsGetDomainControllerInfo, &state->orig);
2756         }
2757
2758         tevent_req_done(req);
2759 }
2760
2761 NTSTATUS rpccli_drsuapi_DsGetDomainControllerInfo_recv(struct tevent_req *req,
2762                                                        TALLOC_CTX *mem_ctx,
2763                                                        WERROR *result)
2764 {
2765         struct rpccli_drsuapi_DsGetDomainControllerInfo_state *state = tevent_req_data(
2766                 req, struct rpccli_drsuapi_DsGetDomainControllerInfo_state);
2767         NTSTATUS status;
2768
2769         if (tevent_req_is_nterror(req, &status)) {
2770                 tevent_req_received(req);
2771                 return status;
2772         }
2773
2774         /* Steal possbile out parameters to the callers context */
2775         talloc_steal(mem_ctx, state->out_mem_ctx);
2776
2777         /* Return result */
2778         *result = state->orig.out.result;
2779
2780         tevent_req_received(req);
2781         return NT_STATUS_OK;
2782 }
2783
2784 NTSTATUS rpccli_drsuapi_DsGetDomainControllerInfo(struct rpc_pipe_client *cli,
2785                                                   TALLOC_CTX *mem_ctx,
2786                                                   struct policy_handle *bind_handle /* [in] [ref] */,
2787                                                   int32_t level /* [in]  */,
2788                                                   union drsuapi_DsGetDCInfoRequest *req /* [in] [ref,switch_is(level)] */,
2789                                                   int32_t *level_out /* [out] [ref] */,
2790                                                   union drsuapi_DsGetDCInfoCtr *ctr /* [out] [ref,switch_is(*level_out)] */,
2791                                                   WERROR *werror)
2792 {
2793         struct drsuapi_DsGetDomainControllerInfo r;
2794         NTSTATUS status;
2795
2796         /* In parameters */
2797         r.in.bind_handle = bind_handle;
2798         r.in.level = level;
2799         r.in.req = req;
2800
2801         if (DEBUGLEVEL >= 10) {
2802                 NDR_PRINT_IN_DEBUG(drsuapi_DsGetDomainControllerInfo, &r);
2803         }
2804
2805         status = cli->dispatch(cli,
2806                                 mem_ctx,
2807                                 &ndr_table_drsuapi,
2808                                 NDR_DRSUAPI_DSGETDOMAINCONTROLLERINFO,
2809                                 &r);
2810
2811         if (!NT_STATUS_IS_OK(status)) {
2812                 return status;
2813         }
2814
2815         if (DEBUGLEVEL >= 10) {
2816                 NDR_PRINT_OUT_DEBUG(drsuapi_DsGetDomainControllerInfo, &r);
2817         }
2818
2819         if (NT_STATUS_IS_ERR(status)) {
2820                 return status;
2821         }
2822
2823         /* Return variables */
2824         *level_out = *r.out.level_out;
2825         *ctr = *r.out.ctr;
2826
2827         /* Return result */
2828         if (werror) {
2829                 *werror = r.out.result;
2830         }
2831
2832         return werror_to_ntstatus(r.out.result);
2833 }
2834
2835 struct rpccli_drsuapi_DsAddEntry_state {
2836         struct drsuapi_DsAddEntry orig;
2837         struct drsuapi_DsAddEntry tmp;
2838         TALLOC_CTX *out_mem_ctx;
2839         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2840 };
2841
2842 static void rpccli_drsuapi_DsAddEntry_done(struct tevent_req *subreq);
2843
2844 struct tevent_req *rpccli_drsuapi_DsAddEntry_send(TALLOC_CTX *mem_ctx,
2845                                                   struct tevent_context *ev,
2846                                                   struct rpc_pipe_client *cli,
2847                                                   struct policy_handle *_bind_handle /* [in] [ref] */,
2848                                                   int32_t _level /* [in]  */,
2849                                                   union drsuapi_DsAddEntryRequest *_req /* [in] [ref,switch_is(level)] */,
2850                                                   int32_t *_level_out /* [out] [ref] */,
2851                                                   union drsuapi_DsAddEntryCtr *_ctr /* [out] [ref,switch_is(*level_out)] */)
2852 {
2853         struct tevent_req *req;
2854         struct rpccli_drsuapi_DsAddEntry_state *state;
2855         struct tevent_req *subreq;
2856
2857         req = tevent_req_create(mem_ctx, &state,
2858                                 struct rpccli_drsuapi_DsAddEntry_state);
2859         if (req == NULL) {
2860                 return NULL;
2861         }
2862         state->out_mem_ctx = NULL;
2863         state->dispatch_recv = cli->dispatch_recv;
2864
2865         /* In parameters */
2866         state->orig.in.bind_handle = _bind_handle;
2867         state->orig.in.level = _level;
2868         state->orig.in.req = _req;
2869
2870         /* Out parameters */
2871         state->orig.out.level_out = _level_out;
2872         state->orig.out.ctr = _ctr;
2873
2874         /* Result */
2875         ZERO_STRUCT(state->orig.out.result);
2876
2877         if (DEBUGLEVEL >= 10) {
2878                 NDR_PRINT_IN_DEBUG(drsuapi_DsAddEntry, &state->orig);
2879         }
2880
2881         state->out_mem_ctx = talloc_named_const(state, 0,
2882                              "rpccli_drsuapi_DsAddEntry_out_memory");
2883         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2884                 return tevent_req_post(req, ev);
2885         }
2886
2887         /* make a temporary copy, that we pass to the dispatch function */
2888         state->tmp = state->orig;
2889
2890         subreq = cli->dispatch_send(state, ev, cli,
2891                                     &ndr_table_drsuapi,
2892                                     NDR_DRSUAPI_DSADDENTRY,
2893                                     &state->tmp);
2894         if (tevent_req_nomem(subreq, req)) {
2895                 return tevent_req_post(req, ev);
2896         }
2897         tevent_req_set_callback(subreq, rpccli_drsuapi_DsAddEntry_done, req);
2898         return req;
2899 }
2900
2901 static void rpccli_drsuapi_DsAddEntry_done(struct tevent_req *subreq)
2902 {
2903         struct tevent_req *req = tevent_req_callback_data(
2904                 subreq, struct tevent_req);
2905         struct rpccli_drsuapi_DsAddEntry_state *state = tevent_req_data(
2906                 req, struct rpccli_drsuapi_DsAddEntry_state);
2907         NTSTATUS status;
2908         TALLOC_CTX *mem_ctx;
2909
2910         if (state->out_mem_ctx) {
2911                 mem_ctx = state->out_mem_ctx;
2912         } else {
2913                 mem_ctx = state;
2914         }
2915
2916         status = state->dispatch_recv(subreq, mem_ctx);
2917         TALLOC_FREE(subreq);
2918         if (!NT_STATUS_IS_OK(status)) {
2919                 tevent_req_nterror(req, status);
2920                 return;
2921         }
2922
2923         /* Copy out parameters */
2924         *state->orig.out.level_out = *state->tmp.out.level_out;
2925         *state->orig.out.ctr = *state->tmp.out.ctr;
2926
2927         /* Copy result */
2928         state->orig.out.result = state->tmp.out.result;
2929
2930         /* Reset temporary structure */
2931         ZERO_STRUCT(state->tmp);
2932
2933         if (DEBUGLEVEL >= 10) {
2934                 NDR_PRINT_OUT_DEBUG(drsuapi_DsAddEntry, &state->orig);
2935         }
2936
2937         tevent_req_done(req);
2938 }
2939
2940 NTSTATUS rpccli_drsuapi_DsAddEntry_recv(struct tevent_req *req,
2941                                         TALLOC_CTX *mem_ctx,
2942                                         WERROR *result)
2943 {
2944         struct rpccli_drsuapi_DsAddEntry_state *state = tevent_req_data(
2945                 req, struct rpccli_drsuapi_DsAddEntry_state);
2946         NTSTATUS status;
2947
2948         if (tevent_req_is_nterror(req, &status)) {
2949                 tevent_req_received(req);
2950                 return status;
2951         }
2952
2953         /* Steal possbile out parameters to the callers context */
2954         talloc_steal(mem_ctx, state->out_mem_ctx);
2955
2956         /* Return result */
2957         *result = state->orig.out.result;
2958
2959         tevent_req_received(req);
2960         return NT_STATUS_OK;
2961 }
2962
2963 NTSTATUS rpccli_drsuapi_DsAddEntry(struct rpc_pipe_client *cli,
2964                                    TALLOC_CTX *mem_ctx,
2965                                    struct policy_handle *bind_handle /* [in] [ref] */,
2966                                    int32_t level /* [in]  */,
2967                                    union drsuapi_DsAddEntryRequest *req /* [in] [ref,switch_is(level)] */,
2968                                    int32_t *level_out /* [out] [ref] */,
2969                                    union drsuapi_DsAddEntryCtr *ctr /* [out] [ref,switch_is(*level_out)] */,
2970                                    WERROR *werror)
2971 {
2972         struct drsuapi_DsAddEntry r;
2973         NTSTATUS status;
2974
2975         /* In parameters */
2976         r.in.bind_handle = bind_handle;
2977         r.in.level = level;
2978         r.in.req = req;
2979
2980         if (DEBUGLEVEL >= 10) {
2981                 NDR_PRINT_IN_DEBUG(drsuapi_DsAddEntry, &r);
2982         }
2983
2984         status = cli->dispatch(cli,
2985                                 mem_ctx,
2986                                 &ndr_table_drsuapi,
2987                                 NDR_DRSUAPI_DSADDENTRY,
2988                                 &r);
2989
2990         if (!NT_STATUS_IS_OK(status)) {
2991                 return status;
2992         }
2993
2994         if (DEBUGLEVEL >= 10) {
2995                 NDR_PRINT_OUT_DEBUG(drsuapi_DsAddEntry, &r);
2996         }
2997
2998         if (NT_STATUS_IS_ERR(status)) {
2999                 return status;
3000         }
3001
3002         /* Return variables */
3003         *level_out = *r.out.level_out;
3004         *ctr = *r.out.ctr;
3005
3006         /* Return result */
3007         if (werror) {
3008                 *werror = r.out.result;
3009         }
3010
3011         return werror_to_ntstatus(r.out.result);
3012 }
3013
3014 struct rpccli_DRSUAPI_EXECUTE_KCC_state {
3015         struct DRSUAPI_EXECUTE_KCC orig;
3016         struct DRSUAPI_EXECUTE_KCC tmp;
3017         TALLOC_CTX *out_mem_ctx;
3018         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3019 };
3020
3021 static void rpccli_DRSUAPI_EXECUTE_KCC_done(struct tevent_req *subreq);
3022
3023 struct tevent_req *rpccli_DRSUAPI_EXECUTE_KCC_send(TALLOC_CTX *mem_ctx,
3024                                                    struct tevent_context *ev,
3025                                                    struct rpc_pipe_client *cli)
3026 {
3027         struct tevent_req *req;
3028         struct rpccli_DRSUAPI_EXECUTE_KCC_state *state;
3029         struct tevent_req *subreq;
3030
3031         req = tevent_req_create(mem_ctx, &state,
3032                                 struct rpccli_DRSUAPI_EXECUTE_KCC_state);
3033         if (req == NULL) {
3034                 return NULL;
3035         }
3036         state->out_mem_ctx = NULL;
3037         state->dispatch_recv = cli->dispatch_recv;
3038
3039         /* In parameters */
3040
3041         /* Out parameters */
3042
3043         /* Result */
3044         ZERO_STRUCT(state->orig.out.result);
3045
3046         if (DEBUGLEVEL >= 10) {
3047                 NDR_PRINT_IN_DEBUG(DRSUAPI_EXECUTE_KCC, &state->orig);
3048         }
3049
3050         /* make a temporary copy, that we pass to the dispatch function */
3051         state->tmp = state->orig;
3052
3053         subreq = cli->dispatch_send(state, ev, cli,
3054                                     &ndr_table_drsuapi,
3055                                     NDR_DRSUAPI_EXECUTE_KCC,
3056                                     &state->tmp);
3057         if (tevent_req_nomem(subreq, req)) {
3058                 return tevent_req_post(req, ev);
3059         }
3060         tevent_req_set_callback(subreq, rpccli_DRSUAPI_EXECUTE_KCC_done, req);
3061         return req;
3062 }
3063
3064 static void rpccli_DRSUAPI_EXECUTE_KCC_done(struct tevent_req *subreq)
3065 {
3066         struct tevent_req *req = tevent_req_callback_data(
3067                 subreq, struct tevent_req);
3068         struct rpccli_DRSUAPI_EXECUTE_KCC_state *state = tevent_req_data(
3069                 req, struct rpccli_DRSUAPI_EXECUTE_KCC_state);
3070         NTSTATUS status;
3071         TALLOC_CTX *mem_ctx;
3072
3073         if (state->out_mem_ctx) {
3074                 mem_ctx = state->out_mem_ctx;
3075         } else {
3076                 mem_ctx = state;
3077         }
3078
3079         status = state->dispatch_recv(subreq, mem_ctx);
3080         TALLOC_FREE(subreq);
3081         if (!NT_STATUS_IS_OK(status)) {
3082                 tevent_req_nterror(req, status);
3083                 return;
3084         }
3085
3086         /* Copy out parameters */
3087
3088         /* Copy result */
3089         state->orig.out.result = state->tmp.out.result;
3090
3091         /* Reset temporary structure */
3092         ZERO_STRUCT(state->tmp);
3093
3094         if (DEBUGLEVEL >= 10) {
3095                 NDR_PRINT_OUT_DEBUG(DRSUAPI_EXECUTE_KCC, &state->orig);
3096         }
3097
3098         tevent_req_done(req);
3099 }
3100
3101 NTSTATUS rpccli_DRSUAPI_EXECUTE_KCC_recv(struct tevent_req *req,
3102                                          TALLOC_CTX *mem_ctx,
3103                                          WERROR *result)
3104 {
3105         struct rpccli_DRSUAPI_EXECUTE_KCC_state *state = tevent_req_data(
3106                 req, struct rpccli_DRSUAPI_EXECUTE_KCC_state);
3107         NTSTATUS status;
3108
3109         if (tevent_req_is_nterror(req, &status)) {
3110                 tevent_req_received(req);
3111                 return status;
3112         }
3113
3114         /* Steal possbile out parameters to the callers context */
3115         talloc_steal(mem_ctx, state->out_mem_ctx);
3116
3117         /* Return result */
3118         *result = state->orig.out.result;
3119
3120         tevent_req_received(req);
3121         return NT_STATUS_OK;
3122 }
3123
3124 NTSTATUS rpccli_DRSUAPI_EXECUTE_KCC(struct rpc_pipe_client *cli,
3125                                     TALLOC_CTX *mem_ctx,
3126                                     WERROR *werror)
3127 {
3128         struct DRSUAPI_EXECUTE_KCC r;
3129         NTSTATUS status;
3130
3131         /* In parameters */
3132
3133         if (DEBUGLEVEL >= 10) {
3134                 NDR_PRINT_IN_DEBUG(DRSUAPI_EXECUTE_KCC, &r);
3135         }
3136
3137         status = cli->dispatch(cli,
3138                                 mem_ctx,
3139                                 &ndr_table_drsuapi,
3140                                 NDR_DRSUAPI_EXECUTE_KCC,
3141                                 &r);
3142
3143         if (!NT_STATUS_IS_OK(status)) {
3144                 return status;
3145         }
3146
3147         if (DEBUGLEVEL >= 10) {
3148                 NDR_PRINT_OUT_DEBUG(DRSUAPI_EXECUTE_KCC, &r);
3149         }
3150
3151         if (NT_STATUS_IS_ERR(status)) {
3152                 return status;
3153         }
3154
3155         /* Return variables */
3156
3157         /* Return result */
3158         if (werror) {
3159                 *werror = r.out.result;
3160         }
3161
3162         return werror_to_ntstatus(r.out.result);
3163 }
3164
3165 struct rpccli_drsuapi_DsReplicaGetInfo_state {
3166         struct drsuapi_DsReplicaGetInfo orig;
3167         struct drsuapi_DsReplicaGetInfo tmp;
3168         TALLOC_CTX *out_mem_ctx;
3169         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3170 };
3171
3172 static void rpccli_drsuapi_DsReplicaGetInfo_done(struct tevent_req *subreq);
3173
3174 struct tevent_req *rpccli_drsuapi_DsReplicaGetInfo_send(TALLOC_CTX *mem_ctx,
3175                                                         struct tevent_context *ev,
3176                                                         struct rpc_pipe_client *cli,
3177                                                         struct policy_handle *_bind_handle /* [in] [ref] */,
3178                                                         enum drsuapi_DsReplicaGetInfoLevel _level /* [in]  */,
3179                                                         union drsuapi_DsReplicaGetInfoRequest *_req /* [in] [ref,switch_is(level)] */,
3180                                                         enum drsuapi_DsReplicaInfoType *_info_type /* [out] [ref] */,
3181                                                         union drsuapi_DsReplicaInfo *_info /* [out] [ref,switch_is(*info_type)] */)
3182 {
3183         struct tevent_req *req;
3184         struct rpccli_drsuapi_DsReplicaGetInfo_state *state;
3185         struct tevent_req *subreq;
3186
3187         req = tevent_req_create(mem_ctx, &state,
3188                                 struct rpccli_drsuapi_DsReplicaGetInfo_state);
3189         if (req == NULL) {
3190                 return NULL;
3191         }
3192         state->out_mem_ctx = NULL;
3193         state->dispatch_recv = cli->dispatch_recv;
3194
3195         /* In parameters */
3196         state->orig.in.bind_handle = _bind_handle;
3197         state->orig.in.level = _level;
3198         state->orig.in.req = _req;
3199
3200         /* Out parameters */
3201         state->orig.out.info_type = _info_type;
3202         state->orig.out.info = _info;
3203
3204         /* Result */
3205         ZERO_STRUCT(state->orig.out.result);
3206
3207         if (DEBUGLEVEL >= 10) {
3208                 NDR_PRINT_IN_DEBUG(drsuapi_DsReplicaGetInfo, &state->orig);
3209         }
3210
3211         state->out_mem_ctx = talloc_named_const(state, 0,
3212                              "rpccli_drsuapi_DsReplicaGetInfo_out_memory");
3213         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3214                 return tevent_req_post(req, ev);
3215         }
3216
3217         /* make a temporary copy, that we pass to the dispatch function */
3218         state->tmp = state->orig;
3219
3220         subreq = cli->dispatch_send(state, ev, cli,
3221                                     &ndr_table_drsuapi,
3222                                     NDR_DRSUAPI_DSREPLICAGETINFO,
3223                                     &state->tmp);
3224         if (tevent_req_nomem(subreq, req)) {
3225                 return tevent_req_post(req, ev);
3226         }
3227         tevent_req_set_callback(subreq, rpccli_drsuapi_DsReplicaGetInfo_done, req);
3228         return req;
3229 }
3230
3231 static void rpccli_drsuapi_DsReplicaGetInfo_done(struct tevent_req *subreq)
3232 {
3233         struct tevent_req *req = tevent_req_callback_data(
3234                 subreq, struct tevent_req);
3235         struct rpccli_drsuapi_DsReplicaGetInfo_state *state = tevent_req_data(
3236                 req, struct rpccli_drsuapi_DsReplicaGetInfo_state);
3237         NTSTATUS status;
3238         TALLOC_CTX *mem_ctx;
3239
3240         if (state->out_mem_ctx) {
3241                 mem_ctx = state->out_mem_ctx;
3242         } else {
3243                 mem_ctx = state;
3244         }
3245
3246         status = state->dispatch_recv(subreq, mem_ctx);
3247         TALLOC_FREE(subreq);
3248         if (!NT_STATUS_IS_OK(status)) {
3249                 tevent_req_nterror(req, status);
3250                 return;
3251         }
3252
3253         /* Copy out parameters */
3254         *state->orig.out.info_type = *state->tmp.out.info_type;
3255         *state->orig.out.info = *state->tmp.out.info;
3256
3257         /* Copy result */
3258         state->orig.out.result = state->tmp.out.result;
3259
3260         /* Reset temporary structure */
3261         ZERO_STRUCT(state->tmp);
3262
3263         if (DEBUGLEVEL >= 10) {
3264                 NDR_PRINT_OUT_DEBUG(drsuapi_DsReplicaGetInfo, &state->orig);
3265         }
3266
3267         tevent_req_done(req);
3268 }
3269
3270 NTSTATUS rpccli_drsuapi_DsReplicaGetInfo_recv(struct tevent_req *req,
3271                                               TALLOC_CTX *mem_ctx,
3272                                               WERROR *result)
3273 {
3274         struct rpccli_drsuapi_DsReplicaGetInfo_state *state = tevent_req_data(
3275                 req, struct rpccli_drsuapi_DsReplicaGetInfo_state);
3276         NTSTATUS status;
3277
3278         if (tevent_req_is_nterror(req, &status)) {
3279                 tevent_req_received(req);
3280                 return status;
3281         }
3282
3283         /* Steal possbile out parameters to the callers context */
3284         talloc_steal(mem_ctx, state->out_mem_ctx);
3285
3286         /* Return result */
3287         *result = state->orig.out.result;
3288
3289         tevent_req_received(req);
3290         return NT_STATUS_OK;
3291 }
3292
3293 NTSTATUS rpccli_drsuapi_DsReplicaGetInfo(struct rpc_pipe_client *cli,
3294                                          TALLOC_CTX *mem_ctx,
3295                                          struct policy_handle *bind_handle /* [in] [ref] */,
3296                                          enum drsuapi_DsReplicaGetInfoLevel level /* [in]  */,
3297                                          union drsuapi_DsReplicaGetInfoRequest *req /* [in] [ref,switch_is(level)] */,
3298                                          enum drsuapi_DsReplicaInfoType *info_type /* [out] [ref] */,
3299                                          union drsuapi_DsReplicaInfo *info /* [out] [ref,switch_is(*info_type)] */,
3300                                          WERROR *werror)
3301 {
3302         struct drsuapi_DsReplicaGetInfo r;
3303         NTSTATUS status;
3304
3305         /* In parameters */
3306         r.in.bind_handle = bind_handle;
3307         r.in.level = level;
3308         r.in.req = req;
3309
3310         if (DEBUGLEVEL >= 10) {
3311                 NDR_PRINT_IN_DEBUG(drsuapi_DsReplicaGetInfo, &r);
3312         }
3313
3314         status = cli->dispatch(cli,
3315                                 mem_ctx,
3316                                 &ndr_table_drsuapi,
3317                                 NDR_DRSUAPI_DSREPLICAGETINFO,
3318                                 &r);
3319
3320         if (!NT_STATUS_IS_OK(status)) {
3321                 return status;
3322         }
3323
3324         if (DEBUGLEVEL >= 10) {
3325                 NDR_PRINT_OUT_DEBUG(drsuapi_DsReplicaGetInfo, &r);
3326         }
3327
3328         if (NT_STATUS_IS_ERR(status)) {
3329                 return status;
3330         }
3331
3332         /* Return variables */
3333         *info_type = *r.out.info_type;
3334         *info = *r.out.info;
3335
3336         /* Return result */
3337         if (werror) {
3338                 *werror = r.out.result;
3339         }
3340
3341         return werror_to_ntstatus(r.out.result);
3342 }
3343
3344 struct rpccli_DRSUAPI_ADD_SID_HISTORY_state {
3345         struct DRSUAPI_ADD_SID_HISTORY orig;
3346         struct DRSUAPI_ADD_SID_HISTORY tmp;
3347         TALLOC_CTX *out_mem_ctx;
3348         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3349 };
3350
3351 static void rpccli_DRSUAPI_ADD_SID_HISTORY_done(struct tevent_req *subreq);
3352
3353 struct tevent_req *rpccli_DRSUAPI_ADD_SID_HISTORY_send(TALLOC_CTX *mem_ctx,
3354                                                        struct tevent_context *ev,
3355                                                        struct rpc_pipe_client *cli)
3356 {
3357         struct tevent_req *req;
3358         struct rpccli_DRSUAPI_ADD_SID_HISTORY_state *state;
3359         struct tevent_req *subreq;
3360
3361         req = tevent_req_create(mem_ctx, &state,
3362                                 struct rpccli_DRSUAPI_ADD_SID_HISTORY_state);
3363         if (req == NULL) {
3364                 return NULL;
3365         }
3366         state->out_mem_ctx = NULL;
3367         state->dispatch_recv = cli->dispatch_recv;
3368
3369         /* In parameters */
3370
3371         /* Out parameters */
3372
3373         /* Result */
3374         ZERO_STRUCT(state->orig.out.result);
3375
3376         if (DEBUGLEVEL >= 10) {
3377                 NDR_PRINT_IN_DEBUG(DRSUAPI_ADD_SID_HISTORY, &state->orig);
3378         }
3379
3380         /* make a temporary copy, that we pass to the dispatch function */
3381         state->tmp = state->orig;
3382
3383         subreq = cli->dispatch_send(state, ev, cli,
3384                                     &ndr_table_drsuapi,
3385                                     NDR_DRSUAPI_ADD_SID_HISTORY,
3386                                     &state->tmp);
3387         if (tevent_req_nomem(subreq, req)) {
3388                 return tevent_req_post(req, ev);
3389         }
3390         tevent_req_set_callback(subreq, rpccli_DRSUAPI_ADD_SID_HISTORY_done, req);
3391         return req;
3392 }
3393
3394 static void rpccli_DRSUAPI_ADD_SID_HISTORY_done(struct tevent_req *subreq)
3395 {
3396         struct tevent_req *req = tevent_req_callback_data(
3397                 subreq, struct tevent_req);
3398         struct rpccli_DRSUAPI_ADD_SID_HISTORY_state *state = tevent_req_data(
3399                 req, struct rpccli_DRSUAPI_ADD_SID_HISTORY_state);
3400         NTSTATUS status;
3401         TALLOC_CTX *mem_ctx;
3402
3403         if (state->out_mem_ctx) {
3404                 mem_ctx = state->out_mem_ctx;
3405         } else {
3406                 mem_ctx = state;
3407         }
3408
3409         status = state->dispatch_recv(subreq, mem_ctx);
3410         TALLOC_FREE(subreq);
3411         if (!NT_STATUS_IS_OK(status)) {
3412                 tevent_req_nterror(req, status);
3413                 return;
3414         }
3415
3416         /* Copy out parameters */
3417
3418         /* Copy result */
3419         state->orig.out.result = state->tmp.out.result;
3420
3421         /* Reset temporary structure */
3422         ZERO_STRUCT(state->tmp);
3423
3424         if (DEBUGLEVEL >= 10) {
3425                 NDR_PRINT_OUT_DEBUG(DRSUAPI_ADD_SID_HISTORY, &state->orig);
3426         }
3427
3428         tevent_req_done(req);
3429 }
3430
3431 NTSTATUS rpccli_DRSUAPI_ADD_SID_HISTORY_recv(struct tevent_req *req,
3432                                              TALLOC_CTX *mem_ctx,
3433                                              WERROR *result)
3434 {
3435         struct rpccli_DRSUAPI_ADD_SID_HISTORY_state *state = tevent_req_data(
3436                 req, struct rpccli_DRSUAPI_ADD_SID_HISTORY_state);
3437         NTSTATUS status;
3438
3439         if (tevent_req_is_nterror(req, &status)) {
3440                 tevent_req_received(req);
3441                 return status;
3442         }
3443
3444         /* Steal possbile out parameters to the callers context */
3445         talloc_steal(mem_ctx, state->out_mem_ctx);
3446
3447         /* Return result */
3448         *result = state->orig.out.result;
3449
3450         tevent_req_received(req);
3451         return NT_STATUS_OK;
3452 }
3453
3454 NTSTATUS rpccli_DRSUAPI_ADD_SID_HISTORY(struct rpc_pipe_client *cli,
3455                                         TALLOC_CTX *mem_ctx,
3456                                         WERROR *werror)
3457 {
3458         struct DRSUAPI_ADD_SID_HISTORY r;
3459         NTSTATUS status;
3460
3461         /* In parameters */
3462
3463         if (DEBUGLEVEL >= 10) {
3464                 NDR_PRINT_IN_DEBUG(DRSUAPI_ADD_SID_HISTORY, &r);
3465         }
3466
3467         status = cli->dispatch(cli,
3468                                 mem_ctx,
3469                                 &ndr_table_drsuapi,
3470                                 NDR_DRSUAPI_ADD_SID_HISTORY,
3471                                 &r);
3472
3473         if (!NT_STATUS_IS_OK(status)) {
3474                 return status;
3475         }
3476
3477         if (DEBUGLEVEL >= 10) {
3478                 NDR_PRINT_OUT_DEBUG(DRSUAPI_ADD_SID_HISTORY, &r);
3479         }
3480
3481         if (NT_STATUS_IS_ERR(status)) {
3482                 return status;
3483         }
3484
3485         /* Return variables */
3486
3487         /* Return result */
3488         if (werror) {
3489                 *werror = r.out.result;
3490         }
3491
3492         return werror_to_ntstatus(r.out.result);
3493 }
3494
3495 struct rpccli_drsuapi_DsGetMemberships2_state {
3496         struct drsuapi_DsGetMemberships2 orig;
3497         struct drsuapi_DsGetMemberships2 tmp;
3498         TALLOC_CTX *out_mem_ctx;
3499         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3500 };
3501
3502 static void rpccli_drsuapi_DsGetMemberships2_done(struct tevent_req *subreq);
3503
3504 struct tevent_req *rpccli_drsuapi_DsGetMemberships2_send(TALLOC_CTX *mem_ctx,
3505                                                          struct tevent_context *ev,
3506                                                          struct rpc_pipe_client *cli,
3507                                                          struct policy_handle *_bind_handle /* [in] [ref] */,
3508                                                          int32_t _level /* [in]  */,
3509                                                          union drsuapi_DsGetMemberships2Request *_req /* [in] [ref,switch_is(level)] */,
3510                                                          int32_t *_level_out /* [out] [ref] */,
3511                                                          union drsuapi_DsGetMemberships2Ctr *_ctr /* [out] [ref,switch_is(*level_out)] */)
3512 {
3513         struct tevent_req *req;
3514         struct rpccli_drsuapi_DsGetMemberships2_state *state;
3515         struct tevent_req *subreq;
3516
3517         req = tevent_req_create(mem_ctx, &state,
3518                                 struct rpccli_drsuapi_DsGetMemberships2_state);
3519         if (req == NULL) {
3520                 return NULL;
3521         }
3522         state->out_mem_ctx = NULL;
3523         state->dispatch_recv = cli->dispatch_recv;
3524
3525         /* In parameters */
3526         state->orig.in.bind_handle = _bind_handle;
3527         state->orig.in.level = _level;
3528         state->orig.in.req = _req;
3529
3530         /* Out parameters */
3531         state->orig.out.level_out = _level_out;
3532         state->orig.out.ctr = _ctr;
3533
3534         /* Result */
3535         ZERO_STRUCT(state->orig.out.result);
3536
3537         if (DEBUGLEVEL >= 10) {
3538                 NDR_PRINT_IN_DEBUG(drsuapi_DsGetMemberships2, &state->orig);
3539         }
3540
3541         state->out_mem_ctx = talloc_named_const(state, 0,
3542                              "rpccli_drsuapi_DsGetMemberships2_out_memory");
3543         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3544                 return tevent_req_post(req, ev);
3545         }
3546
3547         /* make a temporary copy, that we pass to the dispatch function */
3548         state->tmp = state->orig;
3549
3550         subreq = cli->dispatch_send(state, ev, cli,
3551                                     &ndr_table_drsuapi,
3552                                     NDR_DRSUAPI_DSGETMEMBERSHIPS2,
3553                                     &state->tmp);
3554         if (tevent_req_nomem(subreq, req)) {
3555                 return tevent_req_post(req, ev);
3556         }
3557         tevent_req_set_callback(subreq, rpccli_drsuapi_DsGetMemberships2_done, req);
3558         return req;
3559 }
3560
3561 static void rpccli_drsuapi_DsGetMemberships2_done(struct tevent_req *subreq)
3562 {
3563         struct tevent_req *req = tevent_req_callback_data(
3564                 subreq, struct tevent_req);
3565         struct rpccli_drsuapi_DsGetMemberships2_state *state = tevent_req_data(
3566                 req, struct rpccli_drsuapi_DsGetMemberships2_state);
3567         NTSTATUS status;
3568         TALLOC_CTX *mem_ctx;
3569
3570         if (state->out_mem_ctx) {
3571                 mem_ctx = state->out_mem_ctx;
3572         } else {
3573                 mem_ctx = state;
3574         }
3575
3576         status = state->dispatch_recv(subreq, mem_ctx);
3577         TALLOC_FREE(subreq);
3578         if (!NT_STATUS_IS_OK(status)) {
3579                 tevent_req_nterror(req, status);
3580                 return;
3581         }
3582
3583         /* Copy out parameters */
3584         *state->orig.out.level_out = *state->tmp.out.level_out;
3585         *state->orig.out.ctr = *state->tmp.out.ctr;
3586
3587         /* Copy result */
3588         state->orig.out.result = state->tmp.out.result;
3589
3590         /* Reset temporary structure */
3591         ZERO_STRUCT(state->tmp);
3592
3593         if (DEBUGLEVEL >= 10) {
3594                 NDR_PRINT_OUT_DEBUG(drsuapi_DsGetMemberships2, &state->orig);
3595         }
3596
3597         tevent_req_done(req);
3598 }
3599
3600 NTSTATUS rpccli_drsuapi_DsGetMemberships2_recv(struct tevent_req *req,
3601                                                TALLOC_CTX *mem_ctx,
3602                                                WERROR *result)
3603 {
3604         struct rpccli_drsuapi_DsGetMemberships2_state *state = tevent_req_data(
3605                 req, struct rpccli_drsuapi_DsGetMemberships2_state);
3606         NTSTATUS status;
3607
3608         if (tevent_req_is_nterror(req, &status)) {
3609                 tevent_req_received(req);
3610                 return status;
3611         }
3612
3613         /* Steal possbile out parameters to the callers context */
3614         talloc_steal(mem_ctx, state->out_mem_ctx);
3615
3616         /* Return result */
3617         *result = state->orig.out.result;
3618
3619         tevent_req_received(req);
3620         return NT_STATUS_OK;
3621 }
3622
3623 NTSTATUS rpccli_drsuapi_DsGetMemberships2(struct rpc_pipe_client *cli,
3624                                           TALLOC_CTX *mem_ctx,
3625                                           struct policy_handle *bind_handle /* [in] [ref] */,
3626                                           int32_t level /* [in]  */,
3627                                           union drsuapi_DsGetMemberships2Request *req /* [in] [ref,switch_is(level)] */,
3628                                           int32_t *level_out /* [out] [ref] */,
3629                                           union drsuapi_DsGetMemberships2Ctr *ctr /* [out] [ref,switch_is(*level_out)] */,
3630                                           WERROR *werror)
3631 {
3632         struct drsuapi_DsGetMemberships2 r;
3633         NTSTATUS status;
3634
3635         /* In parameters */
3636         r.in.bind_handle = bind_handle;
3637         r.in.level = level;
3638         r.in.req = req;
3639
3640         if (DEBUGLEVEL >= 10) {
3641                 NDR_PRINT_IN_DEBUG(drsuapi_DsGetMemberships2, &r);
3642         }
3643
3644         status = cli->dispatch(cli,
3645                                 mem_ctx,
3646                                 &ndr_table_drsuapi,
3647                                 NDR_DRSUAPI_DSGETMEMBERSHIPS2,
3648                                 &r);
3649
3650         if (!NT_STATUS_IS_OK(status)) {
3651                 return status;
3652         }
3653
3654         if (DEBUGLEVEL >= 10) {
3655                 NDR_PRINT_OUT_DEBUG(drsuapi_DsGetMemberships2, &r);
3656         }
3657
3658         if (NT_STATUS_IS_ERR(status)) {
3659                 return status;
3660         }
3661
3662         /* Return variables */
3663         *level_out = *r.out.level_out;
3664         *ctr = *r.out.ctr;
3665
3666         /* Return result */
3667         if (werror) {
3668                 *werror = r.out.result;
3669         }
3670
3671         return werror_to_ntstatus(r.out.result);
3672 }
3673
3674 struct rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS_state {
3675         struct DRSUAPI_REPLICA_VERIFY_OBJECTS orig;
3676         struct DRSUAPI_REPLICA_VERIFY_OBJECTS tmp;
3677         TALLOC_CTX *out_mem_ctx;
3678         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3679 };
3680
3681 static void rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS_done(struct tevent_req *subreq);
3682
3683 struct tevent_req *rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS_send(TALLOC_CTX *mem_ctx,
3684                                                               struct tevent_context *ev,
3685                                                               struct rpc_pipe_client *cli)
3686 {
3687         struct tevent_req *req;
3688         struct rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS_state *state;
3689         struct tevent_req *subreq;
3690
3691         req = tevent_req_create(mem_ctx, &state,
3692                                 struct rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS_state);
3693         if (req == NULL) {
3694                 return NULL;
3695         }
3696         state->out_mem_ctx = NULL;
3697         state->dispatch_recv = cli->dispatch_recv;
3698
3699         /* In parameters */
3700
3701         /* Out parameters */
3702
3703         /* Result */
3704         ZERO_STRUCT(state->orig.out.result);
3705
3706         if (DEBUGLEVEL >= 10) {
3707                 NDR_PRINT_IN_DEBUG(DRSUAPI_REPLICA_VERIFY_OBJECTS, &state->orig);
3708         }
3709
3710         /* make a temporary copy, that we pass to the dispatch function */
3711         state->tmp = state->orig;
3712
3713         subreq = cli->dispatch_send(state, ev, cli,
3714                                     &ndr_table_drsuapi,
3715                                     NDR_DRSUAPI_REPLICA_VERIFY_OBJECTS,
3716                                     &state->tmp);
3717         if (tevent_req_nomem(subreq, req)) {
3718                 return tevent_req_post(req, ev);
3719         }
3720         tevent_req_set_callback(subreq, rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS_done, req);
3721         return req;
3722 }
3723
3724 static void rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS_done(struct tevent_req *subreq)
3725 {
3726         struct tevent_req *req = tevent_req_callback_data(
3727                 subreq, struct tevent_req);
3728         struct rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS_state *state = tevent_req_data(
3729                 req, struct rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS_state);
3730         NTSTATUS status;
3731         TALLOC_CTX *mem_ctx;
3732
3733         if (state->out_mem_ctx) {
3734                 mem_ctx = state->out_mem_ctx;
3735         } else {
3736                 mem_ctx = state;
3737         }
3738
3739         status = state->dispatch_recv(subreq, mem_ctx);
3740         TALLOC_FREE(subreq);
3741         if (!NT_STATUS_IS_OK(status)) {
3742                 tevent_req_nterror(req, status);
3743                 return;
3744         }
3745
3746         /* Copy out parameters */
3747
3748         /* Copy result */
3749         state->orig.out.result = state->tmp.out.result;
3750
3751         /* Reset temporary structure */
3752         ZERO_STRUCT(state->tmp);
3753
3754         if (DEBUGLEVEL >= 10) {
3755                 NDR_PRINT_OUT_DEBUG(DRSUAPI_REPLICA_VERIFY_OBJECTS, &state->orig);
3756         }
3757
3758         tevent_req_done(req);
3759 }
3760
3761 NTSTATUS rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS_recv(struct tevent_req *req,
3762                                                     TALLOC_CTX *mem_ctx,
3763                                                     WERROR *result)
3764 {
3765         struct rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS_state *state = tevent_req_data(
3766                 req, struct rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS_state);
3767         NTSTATUS status;
3768
3769         if (tevent_req_is_nterror(req, &status)) {
3770                 tevent_req_received(req);
3771                 return status;
3772         }
3773
3774         /* Steal possbile out parameters to the callers context */
3775         talloc_steal(mem_ctx, state->out_mem_ctx);
3776
3777         /* Return result */
3778         *result = state->orig.out.result;
3779
3780         tevent_req_received(req);
3781         return NT_STATUS_OK;
3782 }
3783
3784 NTSTATUS rpccli_DRSUAPI_REPLICA_VERIFY_OBJECTS(struct rpc_pipe_client *cli,
3785                                                TALLOC_CTX *mem_ctx,
3786                                                WERROR *werror)
3787 {
3788         struct DRSUAPI_REPLICA_VERIFY_OBJECTS r;
3789         NTSTATUS status;
3790
3791         /* In parameters */
3792
3793         if (DEBUGLEVEL >= 10) {
3794                 NDR_PRINT_IN_DEBUG(DRSUAPI_REPLICA_VERIFY_OBJECTS, &r);
3795         }
3796
3797         status = cli->dispatch(cli,
3798                                 mem_ctx,
3799                                 &ndr_table_drsuapi,
3800                                 NDR_DRSUAPI_REPLICA_VERIFY_OBJECTS,
3801                                 &r);
3802
3803         if (!NT_STATUS_IS_OK(status)) {
3804                 return status;
3805         }
3806
3807         if (DEBUGLEVEL >= 10) {
3808                 NDR_PRINT_OUT_DEBUG(DRSUAPI_REPLICA_VERIFY_OBJECTS, &r);
3809         }
3810
3811         if (NT_STATUS_IS_ERR(status)) {
3812                 return status;
3813         }
3814
3815         /* Return variables */
3816
3817         /* Return result */
3818         if (werror) {
3819                 *werror = r.out.result;
3820         }
3821
3822         return werror_to_ntstatus(r.out.result);
3823 }
3824
3825 struct rpccli_DRSUAPI_GET_OBJECT_EXISTENCE_state {
3826         struct DRSUAPI_GET_OBJECT_EXISTENCE orig;
3827         struct DRSUAPI_GET_OBJECT_EXISTENCE tmp;
3828         TALLOC_CTX *out_mem_ctx;
3829         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3830 };
3831
3832 static void rpccli_DRSUAPI_GET_OBJECT_EXISTENCE_done(struct tevent_req *subreq);
3833
3834 struct tevent_req *rpccli_DRSUAPI_GET_OBJECT_EXISTENCE_send(TALLOC_CTX *mem_ctx,
3835                                                             struct tevent_context *ev,
3836                                                             struct rpc_pipe_client *cli)
3837 {
3838         struct tevent_req *req;
3839         struct rpccli_DRSUAPI_GET_OBJECT_EXISTENCE_state *state;
3840         struct tevent_req *subreq;
3841
3842         req = tevent_req_create(mem_ctx, &state,
3843                                 struct rpccli_DRSUAPI_GET_OBJECT_EXISTENCE_state);
3844         if (req == NULL) {
3845                 return NULL;
3846         }
3847         state->out_mem_ctx = NULL;
3848         state->dispatch_recv = cli->dispatch_recv;
3849
3850         /* In parameters */
3851
3852         /* Out parameters */
3853
3854         /* Result */
3855         ZERO_STRUCT(state->orig.out.result);
3856
3857         if (DEBUGLEVEL >= 10) {
3858                 NDR_PRINT_IN_DEBUG(DRSUAPI_GET_OBJECT_EXISTENCE, &state->orig);
3859         }
3860
3861         /* make a temporary copy, that we pass to the dispatch function */
3862         state->tmp = state->orig;
3863
3864         subreq = cli->dispatch_send(state, ev, cli,
3865                                     &ndr_table_drsuapi,
3866                                     NDR_DRSUAPI_GET_OBJECT_EXISTENCE,
3867                                     &state->tmp);
3868         if (tevent_req_nomem(subreq, req)) {
3869                 return tevent_req_post(req, ev);
3870         }
3871         tevent_req_set_callback(subreq, rpccli_DRSUAPI_GET_OBJECT_EXISTENCE_done, req);
3872         return req;
3873 }
3874
3875 static void rpccli_DRSUAPI_GET_OBJECT_EXISTENCE_done(struct tevent_req *subreq)
3876 {
3877         struct tevent_req *req = tevent_req_callback_data(
3878                 subreq, struct tevent_req);
3879         struct rpccli_DRSUAPI_GET_OBJECT_EXISTENCE_state *state = tevent_req_data(
3880                 req, struct rpccli_DRSUAPI_GET_OBJECT_EXISTENCE_state);
3881         NTSTATUS status;
3882         TALLOC_CTX *mem_ctx;
3883
3884         if (state->out_mem_ctx) {
3885                 mem_ctx = state->out_mem_ctx;
3886         } else {
3887                 mem_ctx = state;
3888         }
3889
3890         status = state->dispatch_recv(subreq, mem_ctx);
3891         TALLOC_FREE(subreq);
3892         if (!NT_STATUS_IS_OK(status)) {
3893                 tevent_req_nterror(req, status);
3894                 return;
3895         }
3896
3897         /* Copy out parameters */
3898
3899         /* Copy result */
3900         state->orig.out.result = state->tmp.out.result;
3901
3902         /* Reset temporary structure */
3903         ZERO_STRUCT(state->tmp);
3904
3905         if (DEBUGLEVEL >= 10) {
3906                 NDR_PRINT_OUT_DEBUG(DRSUAPI_GET_OBJECT_EXISTENCE, &state->orig);
3907         }
3908
3909         tevent_req_done(req);
3910 }
3911
3912 NTSTATUS rpccli_DRSUAPI_GET_OBJECT_EXISTENCE_recv(struct tevent_req *req,
3913                                                   TALLOC_CTX *mem_ctx,
3914                                                   WERROR *result)
3915 {
3916         struct rpccli_DRSUAPI_GET_OBJECT_EXISTENCE_state *state = tevent_req_data(
3917                 req, struct rpccli_DRSUAPI_GET_OBJECT_EXISTENCE_state);
3918         NTSTATUS status;
3919
3920         if (tevent_req_is_nterror(req, &status)) {
3921                 tevent_req_received(req);
3922                 return status;
3923         }
3924
3925         /* Steal possbile out parameters to the callers context */
3926         talloc_steal(mem_ctx, state->out_mem_ctx);
3927
3928         /* Return result */
3929         *result = state->orig.out.result;
3930
3931         tevent_req_received(req);
3932         return NT_STATUS_OK;
3933 }
3934
3935 NTSTATUS rpccli_DRSUAPI_GET_OBJECT_EXISTENCE(struct rpc_pipe_client *cli,
3936                                              TALLOC_CTX *mem_ctx,
3937                                              WERROR *werror)
3938 {
3939         struct DRSUAPI_GET_OBJECT_EXISTENCE r;
3940         NTSTATUS status;
3941
3942         /* In parameters */
3943
3944         if (DEBUGLEVEL >= 10) {
3945                 NDR_PRINT_IN_DEBUG(DRSUAPI_GET_OBJECT_EXISTENCE, &r);
3946         }
3947
3948         status = cli->dispatch(cli,
3949                                 mem_ctx,
3950                                 &ndr_table_drsuapi,
3951                                 NDR_DRSUAPI_GET_OBJECT_EXISTENCE,
3952                                 &r);
3953
3954         if (!NT_STATUS_IS_OK(status)) {
3955                 return status;
3956         }
3957
3958         if (DEBUGLEVEL >= 10) {
3959                 NDR_PRINT_OUT_DEBUG(DRSUAPI_GET_OBJECT_EXISTENCE, &r);
3960         }
3961
3962         if (NT_STATUS_IS_ERR(status)) {
3963                 return status;
3964         }
3965
3966         /* Return variables */
3967
3968         /* Return result */
3969         if (werror) {
3970                 *werror = r.out.result;
3971         }
3972
3973         return werror_to_ntstatus(r.out.result);
3974 }
3975
3976 struct rpccli_drsuapi_QuerySitesByCost_state {
3977         struct drsuapi_QuerySitesByCost orig;
3978         struct drsuapi_QuerySitesByCost tmp;
3979         TALLOC_CTX *out_mem_ctx;
3980         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3981 };
3982
3983 static void rpccli_drsuapi_QuerySitesByCost_done(struct tevent_req *subreq);
3984
3985 struct tevent_req *rpccli_drsuapi_QuerySitesByCost_send(TALLOC_CTX *mem_ctx,
3986                                                         struct tevent_context *ev,
3987                                                         struct rpc_pipe_client *cli,
3988                                                         struct policy_handle *_bind_handle /* [in] [ref] */,
3989                                                         int32_t _level /* [in]  */,
3990                                                         union drsuapi_QuerySitesByCostRequest *_req /* [in] [ref,switch_is(level)] */,
3991                                                         int32_t *_level_out /* [out] [ref] */,
3992                                                         union drsuapi_QuerySitesByCostCtr *_ctr /* [out] [ref,switch_is(*level_out)] */)
3993 {
3994         struct tevent_req *req;
3995         struct rpccli_drsuapi_QuerySitesByCost_state *state;
3996         struct tevent_req *subreq;
3997
3998         req = tevent_req_create(mem_ctx, &state,
3999                                 struct rpccli_drsuapi_QuerySitesByCost_state);
4000         if (req == NULL) {
4001                 return NULL;
4002         }
4003         state->out_mem_ctx = NULL;
4004         state->dispatch_recv = cli->dispatch_recv;
4005
4006         /* In parameters */
4007         state->orig.in.bind_handle = _bind_handle;
4008         state->orig.in.level = _level;
4009         state->orig.in.req = _req;
4010
4011         /* Out parameters */
4012         state->orig.out.level_out = _level_out;
4013         state->orig.out.ctr = _ctr;
4014
4015         /* Result */
4016         ZERO_STRUCT(state->orig.out.result);
4017
4018         if (DEBUGLEVEL >= 10) {
4019                 NDR_PRINT_IN_DEBUG(drsuapi_QuerySitesByCost, &state->orig);
4020         }
4021
4022         state->out_mem_ctx = talloc_named_const(state, 0,
4023                              "rpccli_drsuapi_QuerySitesByCost_out_memory");
4024         if (tevent_req_nomem(state->out_mem_ctx, req)) {
4025                 return tevent_req_post(req, ev);
4026         }
4027
4028         /* make a temporary copy, that we pass to the dispatch function */
4029         state->tmp = state->orig;
4030
4031         subreq = cli->dispatch_send(state, ev, cli,
4032                                     &ndr_table_drsuapi,
4033                                     NDR_DRSUAPI_QUERYSITESBYCOST,
4034                                     &state->tmp);
4035         if (tevent_req_nomem(subreq, req)) {
4036                 return tevent_req_post(req, ev);
4037         }
4038         tevent_req_set_callback(subreq, rpccli_drsuapi_QuerySitesByCost_done, req);
4039         return req;
4040 }
4041
4042 static void rpccli_drsuapi_QuerySitesByCost_done(struct tevent_req *subreq)
4043 {
4044         struct tevent_req *req = tevent_req_callback_data(
4045                 subreq, struct tevent_req);
4046         struct rpccli_drsuapi_QuerySitesByCost_state *state = tevent_req_data(
4047                 req, struct rpccli_drsuapi_QuerySitesByCost_state);
4048         NTSTATUS status;
4049         TALLOC_CTX *mem_ctx;
4050
4051         if (state->out_mem_ctx) {
4052                 mem_ctx = state->out_mem_ctx;
4053         } else {
4054                 mem_ctx = state;
4055         }
4056
4057         status = state->dispatch_recv(subreq, mem_ctx);
4058         TALLOC_FREE(subreq);
4059         if (!NT_STATUS_IS_OK(status)) {
4060                 tevent_req_nterror(req, status);
4061                 return;
4062         }
4063
4064         /* Copy out parameters */
4065         *state->orig.out.level_out = *state->tmp.out.level_out;
4066         *state->orig.out.ctr = *state->tmp.out.ctr;
4067
4068         /* Copy result */
4069         state->orig.out.result = state->tmp.out.result;
4070
4071         /* Reset temporary structure */
4072         ZERO_STRUCT(state->tmp);
4073
4074         if (DEBUGLEVEL >= 10) {
4075                 NDR_PRINT_OUT_DEBUG(drsuapi_QuerySitesByCost, &state->orig);
4076         }
4077
4078         tevent_req_done(req);
4079 }
4080
4081 NTSTATUS rpccli_drsuapi_QuerySitesByCost_recv(struct tevent_req *req,
4082                                               TALLOC_CTX *mem_ctx,
4083                                               WERROR *result)
4084 {
4085         struct rpccli_drsuapi_QuerySitesByCost_state *state = tevent_req_data(
4086                 req, struct rpccli_drsuapi_QuerySitesByCost_state);
4087         NTSTATUS status;
4088
4089         if (tevent_req_is_nterror(req, &status)) {
4090                 tevent_req_received(req);
4091                 return status;
4092         }
4093
4094         /* Steal possbile out parameters to the callers context */
4095         talloc_steal(mem_ctx, state->out_mem_ctx);
4096
4097         /* Return result */
4098         *result = state->orig.out.result;
4099
4100         tevent_req_received(req);
4101         return NT_STATUS_OK;
4102 }
4103
4104 NTSTATUS rpccli_drsuapi_QuerySitesByCost(struct rpc_pipe_client *cli,
4105                                          TALLOC_CTX *mem_ctx,
4106                                          struct policy_handle *bind_handle /* [in] [ref] */,
4107                                          int32_t level /* [in]  */,
4108                                          union drsuapi_QuerySitesByCostRequest *req /* [in] [ref,switch_is(level)] */,
4109                                          int32_t *level_out /* [out] [ref] */,
4110                                          union drsuapi_QuerySitesByCostCtr *ctr /* [out] [ref,switch_is(*level_out)] */,
4111                                          WERROR *werror)
4112 {
4113         struct drsuapi_QuerySitesByCost r;
4114         NTSTATUS status;
4115
4116         /* In parameters */
4117         r.in.bind_handle = bind_handle;
4118         r.in.level = level;
4119         r.in.req = req;
4120
4121         if (DEBUGLEVEL >= 10) {
4122                 NDR_PRINT_IN_DEBUG(drsuapi_QuerySitesByCost, &r);
4123         }
4124
4125         status = cli->dispatch(cli,
4126                                 mem_ctx,
4127                                 &ndr_table_drsuapi,
4128                                 NDR_DRSUAPI_QUERYSITESBYCOST,
4129                                 &r);
4130
4131         if (!NT_STATUS_IS_OK(status)) {
4132                 return status;
4133         }
4134
4135         if (DEBUGLEVEL >= 10) {
4136                 NDR_PRINT_OUT_DEBUG(drsuapi_QuerySitesByCost, &r);
4137         }
4138
4139         if (NT_STATUS_IS_ERR(status)) {
4140                 return status;
4141         }
4142
4143         /* Return variables */
4144         *level_out = *r.out.level_out;
4145         *ctr = *r.out.ctr;
4146
4147         /* Return result */
4148         if (werror) {
4149                 *werror = r.out.result;
4150         }
4151
4152         return werror_to_ntstatus(r.out.result);
4153 }
4154