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