run make idl_full, thus adding explicit casts to gen_ndr server code
[ira/wip.git] / librpc / gen_ndr / srv_netlogon.c
1 /*
2  * Unix SMB/CIFS implementation.
3  * server auto-generated by pidl. DO NOT MODIFY!
4  */
5
6 #include "includes.h"
7 #include "../librpc/gen_ndr/srv_netlogon.h"
8
9 static bool api_netr_LogonUasLogon(pipes_struct *p)
10 {
11         const struct ndr_interface_call *call;
12         struct ndr_pull *pull;
13         struct ndr_push *push;
14         enum ndr_err_code ndr_err;
15         DATA_BLOB blob;
16         struct netr_LogonUasLogon *r;
17
18         call = &ndr_table_netlogon.calls[NDR_NETR_LOGONUASLOGON];
19
20         r = talloc(talloc_tos(), struct netr_LogonUasLogon);
21         if (r == NULL) {
22                 return false;
23         }
24
25         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
26                 talloc_free(r);
27                 return false;
28         }
29
30         pull = ndr_pull_init_blob(&blob, r, NULL);
31         if (pull == NULL) {
32                 talloc_free(r);
33                 return false;
34         }
35
36         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
37         ndr_err = call->ndr_pull(pull, NDR_IN, r);
38         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
39                 talloc_free(r);
40                 return false;
41         }
42
43         if (DEBUGLEVEL >= 10) {
44                 NDR_PRINT_IN_DEBUG(netr_LogonUasLogon, r);
45         }
46
47         ZERO_STRUCT(r->out);
48         r->out.info = talloc_zero(r, struct netr_UasInfo *);
49         if (r->out.info == NULL) {
50                 talloc_free(r);
51                 return false;
52         }
53
54         r->out.result = _netr_LogonUasLogon(p, r);
55
56         if (p->rng_fault_state) {
57                 talloc_free(r);
58                 /* Return true here, srv_pipe_hnd.c will take care */
59                 return true;
60         }
61
62         if (DEBUGLEVEL >= 10) {
63                 NDR_PRINT_OUT_DEBUG(netr_LogonUasLogon, r);
64         }
65
66         push = ndr_push_init_ctx(r, NULL);
67         if (push == NULL) {
68                 talloc_free(r);
69                 return false;
70         }
71
72         ndr_err = call->ndr_push(push, NDR_OUT, r);
73         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
74                 talloc_free(r);
75                 return false;
76         }
77
78         blob = ndr_push_blob(push);
79         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
80                 talloc_free(r);
81                 return false;
82         }
83
84         talloc_free(r);
85
86         return true;
87 }
88
89 static bool api_netr_LogonUasLogoff(pipes_struct *p)
90 {
91         const struct ndr_interface_call *call;
92         struct ndr_pull *pull;
93         struct ndr_push *push;
94         enum ndr_err_code ndr_err;
95         DATA_BLOB blob;
96         struct netr_LogonUasLogoff *r;
97
98         call = &ndr_table_netlogon.calls[NDR_NETR_LOGONUASLOGOFF];
99
100         r = talloc(talloc_tos(), struct netr_LogonUasLogoff);
101         if (r == NULL) {
102                 return false;
103         }
104
105         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
106                 talloc_free(r);
107                 return false;
108         }
109
110         pull = ndr_pull_init_blob(&blob, r, NULL);
111         if (pull == NULL) {
112                 talloc_free(r);
113                 return false;
114         }
115
116         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
117         ndr_err = call->ndr_pull(pull, NDR_IN, r);
118         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
119                 talloc_free(r);
120                 return false;
121         }
122
123         if (DEBUGLEVEL >= 10) {
124                 NDR_PRINT_IN_DEBUG(netr_LogonUasLogoff, r);
125         }
126
127         ZERO_STRUCT(r->out);
128         r->out.info = talloc_zero(r, struct netr_UasLogoffInfo);
129         if (r->out.info == NULL) {
130                 talloc_free(r);
131                 return false;
132         }
133
134         r->out.result = _netr_LogonUasLogoff(p, r);
135
136         if (p->rng_fault_state) {
137                 talloc_free(r);
138                 /* Return true here, srv_pipe_hnd.c will take care */
139                 return true;
140         }
141
142         if (DEBUGLEVEL >= 10) {
143                 NDR_PRINT_OUT_DEBUG(netr_LogonUasLogoff, r);
144         }
145
146         push = ndr_push_init_ctx(r, NULL);
147         if (push == NULL) {
148                 talloc_free(r);
149                 return false;
150         }
151
152         ndr_err = call->ndr_push(push, NDR_OUT, r);
153         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
154                 talloc_free(r);
155                 return false;
156         }
157
158         blob = ndr_push_blob(push);
159         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
160                 talloc_free(r);
161                 return false;
162         }
163
164         talloc_free(r);
165
166         return true;
167 }
168
169 static bool api_netr_LogonSamLogon(pipes_struct *p)
170 {
171         const struct ndr_interface_call *call;
172         struct ndr_pull *pull;
173         struct ndr_push *push;
174         enum ndr_err_code ndr_err;
175         DATA_BLOB blob;
176         struct netr_LogonSamLogon *r;
177
178         call = &ndr_table_netlogon.calls[NDR_NETR_LOGONSAMLOGON];
179
180         r = talloc(talloc_tos(), struct netr_LogonSamLogon);
181         if (r == NULL) {
182                 return false;
183         }
184
185         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
186                 talloc_free(r);
187                 return false;
188         }
189
190         pull = ndr_pull_init_blob(&blob, r, NULL);
191         if (pull == NULL) {
192                 talloc_free(r);
193                 return false;
194         }
195
196         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
197         ndr_err = call->ndr_pull(pull, NDR_IN, r);
198         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
199                 talloc_free(r);
200                 return false;
201         }
202
203         if (DEBUGLEVEL >= 10) {
204                 NDR_PRINT_IN_DEBUG(netr_LogonSamLogon, r);
205         }
206
207         ZERO_STRUCT(r->out);
208         r->out.return_authenticator = r->in.return_authenticator;
209         r->out.validation = talloc_zero(r, union netr_Validation);
210         if (r->out.validation == NULL) {
211                 talloc_free(r);
212                 return false;
213         }
214
215         r->out.authoritative = talloc_zero(r, uint8_t);
216         if (r->out.authoritative == NULL) {
217                 talloc_free(r);
218                 return false;
219         }
220
221         r->out.result = _netr_LogonSamLogon(p, r);
222
223         if (p->rng_fault_state) {
224                 talloc_free(r);
225                 /* Return true here, srv_pipe_hnd.c will take care */
226                 return true;
227         }
228
229         if (DEBUGLEVEL >= 10) {
230                 NDR_PRINT_OUT_DEBUG(netr_LogonSamLogon, r);
231         }
232
233         push = ndr_push_init_ctx(r, NULL);
234         if (push == NULL) {
235                 talloc_free(r);
236                 return false;
237         }
238
239         ndr_err = call->ndr_push(push, NDR_OUT, r);
240         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
241                 talloc_free(r);
242                 return false;
243         }
244
245         blob = ndr_push_blob(push);
246         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
247                 talloc_free(r);
248                 return false;
249         }
250
251         talloc_free(r);
252
253         return true;
254 }
255
256 static bool api_netr_LogonSamLogoff(pipes_struct *p)
257 {
258         const struct ndr_interface_call *call;
259         struct ndr_pull *pull;
260         struct ndr_push *push;
261         enum ndr_err_code ndr_err;
262         DATA_BLOB blob;
263         struct netr_LogonSamLogoff *r;
264
265         call = &ndr_table_netlogon.calls[NDR_NETR_LOGONSAMLOGOFF];
266
267         r = talloc(talloc_tos(), struct netr_LogonSamLogoff);
268         if (r == NULL) {
269                 return false;
270         }
271
272         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
273                 talloc_free(r);
274                 return false;
275         }
276
277         pull = ndr_pull_init_blob(&blob, r, NULL);
278         if (pull == NULL) {
279                 talloc_free(r);
280                 return false;
281         }
282
283         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
284         ndr_err = call->ndr_pull(pull, NDR_IN, r);
285         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
286                 talloc_free(r);
287                 return false;
288         }
289
290         if (DEBUGLEVEL >= 10) {
291                 NDR_PRINT_IN_DEBUG(netr_LogonSamLogoff, r);
292         }
293
294         ZERO_STRUCT(r->out);
295         r->out.return_authenticator = r->in.return_authenticator;
296         r->out.result = _netr_LogonSamLogoff(p, r);
297
298         if (p->rng_fault_state) {
299                 talloc_free(r);
300                 /* Return true here, srv_pipe_hnd.c will take care */
301                 return true;
302         }
303
304         if (DEBUGLEVEL >= 10) {
305                 NDR_PRINT_OUT_DEBUG(netr_LogonSamLogoff, r);
306         }
307
308         push = ndr_push_init_ctx(r, NULL);
309         if (push == NULL) {
310                 talloc_free(r);
311                 return false;
312         }
313
314         ndr_err = call->ndr_push(push, NDR_OUT, r);
315         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
316                 talloc_free(r);
317                 return false;
318         }
319
320         blob = ndr_push_blob(push);
321         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
322                 talloc_free(r);
323                 return false;
324         }
325
326         talloc_free(r);
327
328         return true;
329 }
330
331 static bool api_netr_ServerReqChallenge(pipes_struct *p)
332 {
333         const struct ndr_interface_call *call;
334         struct ndr_pull *pull;
335         struct ndr_push *push;
336         enum ndr_err_code ndr_err;
337         DATA_BLOB blob;
338         struct netr_ServerReqChallenge *r;
339
340         call = &ndr_table_netlogon.calls[NDR_NETR_SERVERREQCHALLENGE];
341
342         r = talloc(talloc_tos(), struct netr_ServerReqChallenge);
343         if (r == NULL) {
344                 return false;
345         }
346
347         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
348                 talloc_free(r);
349                 return false;
350         }
351
352         pull = ndr_pull_init_blob(&blob, r, NULL);
353         if (pull == NULL) {
354                 talloc_free(r);
355                 return false;
356         }
357
358         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
359         ndr_err = call->ndr_pull(pull, NDR_IN, r);
360         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
361                 talloc_free(r);
362                 return false;
363         }
364
365         if (DEBUGLEVEL >= 10) {
366                 NDR_PRINT_IN_DEBUG(netr_ServerReqChallenge, r);
367         }
368
369         ZERO_STRUCT(r->out);
370         r->out.return_credentials = talloc_zero(r, struct netr_Credential);
371         if (r->out.return_credentials == NULL) {
372                 talloc_free(r);
373                 return false;
374         }
375
376         r->out.result = _netr_ServerReqChallenge(p, r);
377
378         if (p->rng_fault_state) {
379                 talloc_free(r);
380                 /* Return true here, srv_pipe_hnd.c will take care */
381                 return true;
382         }
383
384         if (DEBUGLEVEL >= 10) {
385                 NDR_PRINT_OUT_DEBUG(netr_ServerReqChallenge, r);
386         }
387
388         push = ndr_push_init_ctx(r, NULL);
389         if (push == NULL) {
390                 talloc_free(r);
391                 return false;
392         }
393
394         ndr_err = call->ndr_push(push, NDR_OUT, r);
395         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
396                 talloc_free(r);
397                 return false;
398         }
399
400         blob = ndr_push_blob(push);
401         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
402                 talloc_free(r);
403                 return false;
404         }
405
406         talloc_free(r);
407
408         return true;
409 }
410
411 static bool api_netr_ServerAuthenticate(pipes_struct *p)
412 {
413         const struct ndr_interface_call *call;
414         struct ndr_pull *pull;
415         struct ndr_push *push;
416         enum ndr_err_code ndr_err;
417         DATA_BLOB blob;
418         struct netr_ServerAuthenticate *r;
419
420         call = &ndr_table_netlogon.calls[NDR_NETR_SERVERAUTHENTICATE];
421
422         r = talloc(talloc_tos(), struct netr_ServerAuthenticate);
423         if (r == NULL) {
424                 return false;
425         }
426
427         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
428                 talloc_free(r);
429                 return false;
430         }
431
432         pull = ndr_pull_init_blob(&blob, r, NULL);
433         if (pull == NULL) {
434                 talloc_free(r);
435                 return false;
436         }
437
438         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
439         ndr_err = call->ndr_pull(pull, NDR_IN, r);
440         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
441                 talloc_free(r);
442                 return false;
443         }
444
445         if (DEBUGLEVEL >= 10) {
446                 NDR_PRINT_IN_DEBUG(netr_ServerAuthenticate, r);
447         }
448
449         ZERO_STRUCT(r->out);
450         r->out.return_credentials = talloc_zero(r, struct netr_Credential);
451         if (r->out.return_credentials == NULL) {
452                 talloc_free(r);
453                 return false;
454         }
455
456         r->out.result = _netr_ServerAuthenticate(p, r);
457
458         if (p->rng_fault_state) {
459                 talloc_free(r);
460                 /* Return true here, srv_pipe_hnd.c will take care */
461                 return true;
462         }
463
464         if (DEBUGLEVEL >= 10) {
465                 NDR_PRINT_OUT_DEBUG(netr_ServerAuthenticate, r);
466         }
467
468         push = ndr_push_init_ctx(r, NULL);
469         if (push == NULL) {
470                 talloc_free(r);
471                 return false;
472         }
473
474         ndr_err = call->ndr_push(push, NDR_OUT, r);
475         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
476                 talloc_free(r);
477                 return false;
478         }
479
480         blob = ndr_push_blob(push);
481         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
482                 talloc_free(r);
483                 return false;
484         }
485
486         talloc_free(r);
487
488         return true;
489 }
490
491 static bool api_netr_ServerPasswordSet(pipes_struct *p)
492 {
493         const struct ndr_interface_call *call;
494         struct ndr_pull *pull;
495         struct ndr_push *push;
496         enum ndr_err_code ndr_err;
497         DATA_BLOB blob;
498         struct netr_ServerPasswordSet *r;
499
500         call = &ndr_table_netlogon.calls[NDR_NETR_SERVERPASSWORDSET];
501
502         r = talloc(talloc_tos(), struct netr_ServerPasswordSet);
503         if (r == NULL) {
504                 return false;
505         }
506
507         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
508                 talloc_free(r);
509                 return false;
510         }
511
512         pull = ndr_pull_init_blob(&blob, r, NULL);
513         if (pull == NULL) {
514                 talloc_free(r);
515                 return false;
516         }
517
518         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
519         ndr_err = call->ndr_pull(pull, NDR_IN, r);
520         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
521                 talloc_free(r);
522                 return false;
523         }
524
525         if (DEBUGLEVEL >= 10) {
526                 NDR_PRINT_IN_DEBUG(netr_ServerPasswordSet, r);
527         }
528
529         ZERO_STRUCT(r->out);
530         r->out.return_authenticator = talloc_zero(r, struct netr_Authenticator);
531         if (r->out.return_authenticator == NULL) {
532                 talloc_free(r);
533                 return false;
534         }
535
536         r->out.result = _netr_ServerPasswordSet(p, r);
537
538         if (p->rng_fault_state) {
539                 talloc_free(r);
540                 /* Return true here, srv_pipe_hnd.c will take care */
541                 return true;
542         }
543
544         if (DEBUGLEVEL >= 10) {
545                 NDR_PRINT_OUT_DEBUG(netr_ServerPasswordSet, r);
546         }
547
548         push = ndr_push_init_ctx(r, NULL);
549         if (push == NULL) {
550                 talloc_free(r);
551                 return false;
552         }
553
554         ndr_err = call->ndr_push(push, NDR_OUT, r);
555         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
556                 talloc_free(r);
557                 return false;
558         }
559
560         blob = ndr_push_blob(push);
561         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
562                 talloc_free(r);
563                 return false;
564         }
565
566         talloc_free(r);
567
568         return true;
569 }
570
571 static bool api_netr_DatabaseDeltas(pipes_struct *p)
572 {
573         const struct ndr_interface_call *call;
574         struct ndr_pull *pull;
575         struct ndr_push *push;
576         enum ndr_err_code ndr_err;
577         DATA_BLOB blob;
578         struct netr_DatabaseDeltas *r;
579
580         call = &ndr_table_netlogon.calls[NDR_NETR_DATABASEDELTAS];
581
582         r = talloc(talloc_tos(), struct netr_DatabaseDeltas);
583         if (r == NULL) {
584                 return false;
585         }
586
587         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
588                 talloc_free(r);
589                 return false;
590         }
591
592         pull = ndr_pull_init_blob(&blob, r, NULL);
593         if (pull == NULL) {
594                 talloc_free(r);
595                 return false;
596         }
597
598         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
599         ndr_err = call->ndr_pull(pull, NDR_IN, r);
600         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
601                 talloc_free(r);
602                 return false;
603         }
604
605         if (DEBUGLEVEL >= 10) {
606                 NDR_PRINT_IN_DEBUG(netr_DatabaseDeltas, r);
607         }
608
609         ZERO_STRUCT(r->out);
610         r->out.return_authenticator = r->in.return_authenticator;
611         r->out.sequence_num = r->in.sequence_num;
612         r->out.delta_enum_array = talloc_zero(r, struct netr_DELTA_ENUM_ARRAY *);
613         if (r->out.delta_enum_array == NULL) {
614                 talloc_free(r);
615                 return false;
616         }
617
618         r->out.result = _netr_DatabaseDeltas(p, r);
619
620         if (p->rng_fault_state) {
621                 talloc_free(r);
622                 /* Return true here, srv_pipe_hnd.c will take care */
623                 return true;
624         }
625
626         if (DEBUGLEVEL >= 10) {
627                 NDR_PRINT_OUT_DEBUG(netr_DatabaseDeltas, r);
628         }
629
630         push = ndr_push_init_ctx(r, NULL);
631         if (push == NULL) {
632                 talloc_free(r);
633                 return false;
634         }
635
636         ndr_err = call->ndr_push(push, NDR_OUT, r);
637         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
638                 talloc_free(r);
639                 return false;
640         }
641
642         blob = ndr_push_blob(push);
643         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
644                 talloc_free(r);
645                 return false;
646         }
647
648         talloc_free(r);
649
650         return true;
651 }
652
653 static bool api_netr_DatabaseSync(pipes_struct *p)
654 {
655         const struct ndr_interface_call *call;
656         struct ndr_pull *pull;
657         struct ndr_push *push;
658         enum ndr_err_code ndr_err;
659         DATA_BLOB blob;
660         struct netr_DatabaseSync *r;
661
662         call = &ndr_table_netlogon.calls[NDR_NETR_DATABASESYNC];
663
664         r = talloc(talloc_tos(), struct netr_DatabaseSync);
665         if (r == NULL) {
666                 return false;
667         }
668
669         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
670                 talloc_free(r);
671                 return false;
672         }
673
674         pull = ndr_pull_init_blob(&blob, r, NULL);
675         if (pull == NULL) {
676                 talloc_free(r);
677                 return false;
678         }
679
680         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
681         ndr_err = call->ndr_pull(pull, NDR_IN, r);
682         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
683                 talloc_free(r);
684                 return false;
685         }
686
687         if (DEBUGLEVEL >= 10) {
688                 NDR_PRINT_IN_DEBUG(netr_DatabaseSync, r);
689         }
690
691         ZERO_STRUCT(r->out);
692         r->out.return_authenticator = r->in.return_authenticator;
693         r->out.sync_context = r->in.sync_context;
694         r->out.delta_enum_array = talloc_zero(r, struct netr_DELTA_ENUM_ARRAY *);
695         if (r->out.delta_enum_array == NULL) {
696                 talloc_free(r);
697                 return false;
698         }
699
700         r->out.result = _netr_DatabaseSync(p, r);
701
702         if (p->rng_fault_state) {
703                 talloc_free(r);
704                 /* Return true here, srv_pipe_hnd.c will take care */
705                 return true;
706         }
707
708         if (DEBUGLEVEL >= 10) {
709                 NDR_PRINT_OUT_DEBUG(netr_DatabaseSync, r);
710         }
711
712         push = ndr_push_init_ctx(r, NULL);
713         if (push == NULL) {
714                 talloc_free(r);
715                 return false;
716         }
717
718         ndr_err = call->ndr_push(push, NDR_OUT, r);
719         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
720                 talloc_free(r);
721                 return false;
722         }
723
724         blob = ndr_push_blob(push);
725         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
726                 talloc_free(r);
727                 return false;
728         }
729
730         talloc_free(r);
731
732         return true;
733 }
734
735 static bool api_netr_AccountDeltas(pipes_struct *p)
736 {
737         const struct ndr_interface_call *call;
738         struct ndr_pull *pull;
739         struct ndr_push *push;
740         enum ndr_err_code ndr_err;
741         DATA_BLOB blob;
742         struct netr_AccountDeltas *r;
743
744         call = &ndr_table_netlogon.calls[NDR_NETR_ACCOUNTDELTAS];
745
746         r = talloc(talloc_tos(), struct netr_AccountDeltas);
747         if (r == NULL) {
748                 return false;
749         }
750
751         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
752                 talloc_free(r);
753                 return false;
754         }
755
756         pull = ndr_pull_init_blob(&blob, r, NULL);
757         if (pull == NULL) {
758                 talloc_free(r);
759                 return false;
760         }
761
762         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
763         ndr_err = call->ndr_pull(pull, NDR_IN, r);
764         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
765                 talloc_free(r);
766                 return false;
767         }
768
769         if (DEBUGLEVEL >= 10) {
770                 NDR_PRINT_IN_DEBUG(netr_AccountDeltas, r);
771         }
772
773         ZERO_STRUCT(r->out);
774         r->out.return_authenticator = r->in.return_authenticator;
775         r->out.buffer = talloc_zero(r, struct netr_AccountBuffer);
776         if (r->out.buffer == NULL) {
777                 talloc_free(r);
778                 return false;
779         }
780
781         r->out.count_returned = talloc_zero(r, uint32_t);
782         if (r->out.count_returned == NULL) {
783                 talloc_free(r);
784                 return false;
785         }
786
787         r->out.total_entries = talloc_zero(r, uint32_t);
788         if (r->out.total_entries == NULL) {
789                 talloc_free(r);
790                 return false;
791         }
792
793         r->out.recordid = talloc_zero(r, struct netr_UAS_INFO_0);
794         if (r->out.recordid == NULL) {
795                 talloc_free(r);
796                 return false;
797         }
798
799         r->out.result = _netr_AccountDeltas(p, r);
800
801         if (p->rng_fault_state) {
802                 talloc_free(r);
803                 /* Return true here, srv_pipe_hnd.c will take care */
804                 return true;
805         }
806
807         if (DEBUGLEVEL >= 10) {
808                 NDR_PRINT_OUT_DEBUG(netr_AccountDeltas, r);
809         }
810
811         push = ndr_push_init_ctx(r, NULL);
812         if (push == NULL) {
813                 talloc_free(r);
814                 return false;
815         }
816
817         ndr_err = call->ndr_push(push, NDR_OUT, r);
818         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
819                 talloc_free(r);
820                 return false;
821         }
822
823         blob = ndr_push_blob(push);
824         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
825                 talloc_free(r);
826                 return false;
827         }
828
829         talloc_free(r);
830
831         return true;
832 }
833
834 static bool api_netr_AccountSync(pipes_struct *p)
835 {
836         const struct ndr_interface_call *call;
837         struct ndr_pull *pull;
838         struct ndr_push *push;
839         enum ndr_err_code ndr_err;
840         DATA_BLOB blob;
841         struct netr_AccountSync *r;
842
843         call = &ndr_table_netlogon.calls[NDR_NETR_ACCOUNTSYNC];
844
845         r = talloc(talloc_tos(), struct netr_AccountSync);
846         if (r == NULL) {
847                 return false;
848         }
849
850         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
851                 talloc_free(r);
852                 return false;
853         }
854
855         pull = ndr_pull_init_blob(&blob, r, NULL);
856         if (pull == NULL) {
857                 talloc_free(r);
858                 return false;
859         }
860
861         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
862         ndr_err = call->ndr_pull(pull, NDR_IN, r);
863         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
864                 talloc_free(r);
865                 return false;
866         }
867
868         if (DEBUGLEVEL >= 10) {
869                 NDR_PRINT_IN_DEBUG(netr_AccountSync, r);
870         }
871
872         ZERO_STRUCT(r->out);
873         r->out.return_authenticator = r->in.return_authenticator;
874         r->out.recordid = r->in.recordid;
875         r->out.buffer = talloc_zero(r, struct netr_AccountBuffer);
876         if (r->out.buffer == NULL) {
877                 talloc_free(r);
878                 return false;
879         }
880
881         r->out.count_returned = talloc_zero(r, uint32_t);
882         if (r->out.count_returned == NULL) {
883                 talloc_free(r);
884                 return false;
885         }
886
887         r->out.total_entries = talloc_zero(r, uint32_t);
888         if (r->out.total_entries == NULL) {
889                 talloc_free(r);
890                 return false;
891         }
892
893         r->out.next_reference = talloc_zero(r, uint32_t);
894         if (r->out.next_reference == NULL) {
895                 talloc_free(r);
896                 return false;
897         }
898
899         r->out.result = _netr_AccountSync(p, r);
900
901         if (p->rng_fault_state) {
902                 talloc_free(r);
903                 /* Return true here, srv_pipe_hnd.c will take care */
904                 return true;
905         }
906
907         if (DEBUGLEVEL >= 10) {
908                 NDR_PRINT_OUT_DEBUG(netr_AccountSync, r);
909         }
910
911         push = ndr_push_init_ctx(r, NULL);
912         if (push == NULL) {
913                 talloc_free(r);
914                 return false;
915         }
916
917         ndr_err = call->ndr_push(push, NDR_OUT, r);
918         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
919                 talloc_free(r);
920                 return false;
921         }
922
923         blob = ndr_push_blob(push);
924         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
925                 talloc_free(r);
926                 return false;
927         }
928
929         talloc_free(r);
930
931         return true;
932 }
933
934 static bool api_netr_GetDcName(pipes_struct *p)
935 {
936         const struct ndr_interface_call *call;
937         struct ndr_pull *pull;
938         struct ndr_push *push;
939         enum ndr_err_code ndr_err;
940         DATA_BLOB blob;
941         struct netr_GetDcName *r;
942
943         call = &ndr_table_netlogon.calls[NDR_NETR_GETDCNAME];
944
945         r = talloc(talloc_tos(), struct netr_GetDcName);
946         if (r == NULL) {
947                 return false;
948         }
949
950         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
951                 talloc_free(r);
952                 return false;
953         }
954
955         pull = ndr_pull_init_blob(&blob, r, NULL);
956         if (pull == NULL) {
957                 talloc_free(r);
958                 return false;
959         }
960
961         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
962         ndr_err = call->ndr_pull(pull, NDR_IN, r);
963         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
964                 talloc_free(r);
965                 return false;
966         }
967
968         if (DEBUGLEVEL >= 10) {
969                 NDR_PRINT_IN_DEBUG(netr_GetDcName, r);
970         }
971
972         ZERO_STRUCT(r->out);
973         r->out.dcname = talloc_zero(r, const char *);
974         if (r->out.dcname == NULL) {
975                 talloc_free(r);
976                 return false;
977         }
978
979         r->out.result = _netr_GetDcName(p, r);
980
981         if (p->rng_fault_state) {
982                 talloc_free(r);
983                 /* Return true here, srv_pipe_hnd.c will take care */
984                 return true;
985         }
986
987         if (DEBUGLEVEL >= 10) {
988                 NDR_PRINT_OUT_DEBUG(netr_GetDcName, r);
989         }
990
991         push = ndr_push_init_ctx(r, NULL);
992         if (push == NULL) {
993                 talloc_free(r);
994                 return false;
995         }
996
997         ndr_err = call->ndr_push(push, NDR_OUT, r);
998         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
999                 talloc_free(r);
1000                 return false;
1001         }
1002
1003         blob = ndr_push_blob(push);
1004         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1005                 talloc_free(r);
1006                 return false;
1007         }
1008
1009         talloc_free(r);
1010
1011         return true;
1012 }
1013
1014 static bool api_netr_LogonControl(pipes_struct *p)
1015 {
1016         const struct ndr_interface_call *call;
1017         struct ndr_pull *pull;
1018         struct ndr_push *push;
1019         enum ndr_err_code ndr_err;
1020         DATA_BLOB blob;
1021         struct netr_LogonControl *r;
1022
1023         call = &ndr_table_netlogon.calls[NDR_NETR_LOGONCONTROL];
1024
1025         r = talloc(talloc_tos(), struct netr_LogonControl);
1026         if (r == NULL) {
1027                 return false;
1028         }
1029
1030         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1031                 talloc_free(r);
1032                 return false;
1033         }
1034
1035         pull = ndr_pull_init_blob(&blob, r, NULL);
1036         if (pull == NULL) {
1037                 talloc_free(r);
1038                 return false;
1039         }
1040
1041         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1042         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1043         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1044                 talloc_free(r);
1045                 return false;
1046         }
1047
1048         if (DEBUGLEVEL >= 10) {
1049                 NDR_PRINT_IN_DEBUG(netr_LogonControl, r);
1050         }
1051
1052         ZERO_STRUCT(r->out);
1053         r->out.info = talloc_zero(r, union netr_CONTROL_QUERY_INFORMATION);
1054         if (r->out.info == NULL) {
1055                 talloc_free(r);
1056                 return false;
1057         }
1058
1059         r->out.result = _netr_LogonControl(p, r);
1060
1061         if (p->rng_fault_state) {
1062                 talloc_free(r);
1063                 /* Return true here, srv_pipe_hnd.c will take care */
1064                 return true;
1065         }
1066
1067         if (DEBUGLEVEL >= 10) {
1068                 NDR_PRINT_OUT_DEBUG(netr_LogonControl, r);
1069         }
1070
1071         push = ndr_push_init_ctx(r, NULL);
1072         if (push == NULL) {
1073                 talloc_free(r);
1074                 return false;
1075         }
1076
1077         ndr_err = call->ndr_push(push, NDR_OUT, r);
1078         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1079                 talloc_free(r);
1080                 return false;
1081         }
1082
1083         blob = ndr_push_blob(push);
1084         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1085                 talloc_free(r);
1086                 return false;
1087         }
1088
1089         talloc_free(r);
1090
1091         return true;
1092 }
1093
1094 static bool api_netr_GetAnyDCName(pipes_struct *p)
1095 {
1096         const struct ndr_interface_call *call;
1097         struct ndr_pull *pull;
1098         struct ndr_push *push;
1099         enum ndr_err_code ndr_err;
1100         DATA_BLOB blob;
1101         struct netr_GetAnyDCName *r;
1102
1103         call = &ndr_table_netlogon.calls[NDR_NETR_GETANYDCNAME];
1104
1105         r = talloc(talloc_tos(), struct netr_GetAnyDCName);
1106         if (r == NULL) {
1107                 return false;
1108         }
1109
1110         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1111                 talloc_free(r);
1112                 return false;
1113         }
1114
1115         pull = ndr_pull_init_blob(&blob, r, NULL);
1116         if (pull == NULL) {
1117                 talloc_free(r);
1118                 return false;
1119         }
1120
1121         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1122         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1123         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1124                 talloc_free(r);
1125                 return false;
1126         }
1127
1128         if (DEBUGLEVEL >= 10) {
1129                 NDR_PRINT_IN_DEBUG(netr_GetAnyDCName, r);
1130         }
1131
1132         ZERO_STRUCT(r->out);
1133         r->out.dcname = talloc_zero(r, const char *);
1134         if (r->out.dcname == NULL) {
1135                 talloc_free(r);
1136                 return false;
1137         }
1138
1139         r->out.result = _netr_GetAnyDCName(p, r);
1140
1141         if (p->rng_fault_state) {
1142                 talloc_free(r);
1143                 /* Return true here, srv_pipe_hnd.c will take care */
1144                 return true;
1145         }
1146
1147         if (DEBUGLEVEL >= 10) {
1148                 NDR_PRINT_OUT_DEBUG(netr_GetAnyDCName, r);
1149         }
1150
1151         push = ndr_push_init_ctx(r, NULL);
1152         if (push == NULL) {
1153                 talloc_free(r);
1154                 return false;
1155         }
1156
1157         ndr_err = call->ndr_push(push, NDR_OUT, r);
1158         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1159                 talloc_free(r);
1160                 return false;
1161         }
1162
1163         blob = ndr_push_blob(push);
1164         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1165                 talloc_free(r);
1166                 return false;
1167         }
1168
1169         talloc_free(r);
1170
1171         return true;
1172 }
1173
1174 static bool api_netr_LogonControl2(pipes_struct *p)
1175 {
1176         const struct ndr_interface_call *call;
1177         struct ndr_pull *pull;
1178         struct ndr_push *push;
1179         enum ndr_err_code ndr_err;
1180         DATA_BLOB blob;
1181         struct netr_LogonControl2 *r;
1182
1183         call = &ndr_table_netlogon.calls[NDR_NETR_LOGONCONTROL2];
1184
1185         r = talloc(talloc_tos(), struct netr_LogonControl2);
1186         if (r == NULL) {
1187                 return false;
1188         }
1189
1190         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1191                 talloc_free(r);
1192                 return false;
1193         }
1194
1195         pull = ndr_pull_init_blob(&blob, r, NULL);
1196         if (pull == NULL) {
1197                 talloc_free(r);
1198                 return false;
1199         }
1200
1201         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1202         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1203         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1204                 talloc_free(r);
1205                 return false;
1206         }
1207
1208         if (DEBUGLEVEL >= 10) {
1209                 NDR_PRINT_IN_DEBUG(netr_LogonControl2, r);
1210         }
1211
1212         ZERO_STRUCT(r->out);
1213         r->out.query = talloc_zero(r, union netr_CONTROL_QUERY_INFORMATION);
1214         if (r->out.query == NULL) {
1215                 talloc_free(r);
1216                 return false;
1217         }
1218
1219         r->out.result = _netr_LogonControl2(p, r);
1220
1221         if (p->rng_fault_state) {
1222                 talloc_free(r);
1223                 /* Return true here, srv_pipe_hnd.c will take care */
1224                 return true;
1225         }
1226
1227         if (DEBUGLEVEL >= 10) {
1228                 NDR_PRINT_OUT_DEBUG(netr_LogonControl2, r);
1229         }
1230
1231         push = ndr_push_init_ctx(r, NULL);
1232         if (push == NULL) {
1233                 talloc_free(r);
1234                 return false;
1235         }
1236
1237         ndr_err = call->ndr_push(push, NDR_OUT, r);
1238         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1239                 talloc_free(r);
1240                 return false;
1241         }
1242
1243         blob = ndr_push_blob(push);
1244         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1245                 talloc_free(r);
1246                 return false;
1247         }
1248
1249         talloc_free(r);
1250
1251         return true;
1252 }
1253
1254 static bool api_netr_ServerAuthenticate2(pipes_struct *p)
1255 {
1256         const struct ndr_interface_call *call;
1257         struct ndr_pull *pull;
1258         struct ndr_push *push;
1259         enum ndr_err_code ndr_err;
1260         DATA_BLOB blob;
1261         struct netr_ServerAuthenticate2 *r;
1262
1263         call = &ndr_table_netlogon.calls[NDR_NETR_SERVERAUTHENTICATE2];
1264
1265         r = talloc(talloc_tos(), struct netr_ServerAuthenticate2);
1266         if (r == NULL) {
1267                 return false;
1268         }
1269
1270         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1271                 talloc_free(r);
1272                 return false;
1273         }
1274
1275         pull = ndr_pull_init_blob(&blob, r, NULL);
1276         if (pull == NULL) {
1277                 talloc_free(r);
1278                 return false;
1279         }
1280
1281         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1282         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1283         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1284                 talloc_free(r);
1285                 return false;
1286         }
1287
1288         if (DEBUGLEVEL >= 10) {
1289                 NDR_PRINT_IN_DEBUG(netr_ServerAuthenticate2, r);
1290         }
1291
1292         ZERO_STRUCT(r->out);
1293         r->out.negotiate_flags = r->in.negotiate_flags;
1294         r->out.return_credentials = talloc_zero(r, struct netr_Credential);
1295         if (r->out.return_credentials == NULL) {
1296                 talloc_free(r);
1297                 return false;
1298         }
1299
1300         r->out.result = _netr_ServerAuthenticate2(p, r);
1301
1302         if (p->rng_fault_state) {
1303                 talloc_free(r);
1304                 /* Return true here, srv_pipe_hnd.c will take care */
1305                 return true;
1306         }
1307
1308         if (DEBUGLEVEL >= 10) {
1309                 NDR_PRINT_OUT_DEBUG(netr_ServerAuthenticate2, r);
1310         }
1311
1312         push = ndr_push_init_ctx(r, NULL);
1313         if (push == NULL) {
1314                 talloc_free(r);
1315                 return false;
1316         }
1317
1318         ndr_err = call->ndr_push(push, NDR_OUT, r);
1319         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1320                 talloc_free(r);
1321                 return false;
1322         }
1323
1324         blob = ndr_push_blob(push);
1325         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1326                 talloc_free(r);
1327                 return false;
1328         }
1329
1330         talloc_free(r);
1331
1332         return true;
1333 }
1334
1335 static bool api_netr_DatabaseSync2(pipes_struct *p)
1336 {
1337         const struct ndr_interface_call *call;
1338         struct ndr_pull *pull;
1339         struct ndr_push *push;
1340         enum ndr_err_code ndr_err;
1341         DATA_BLOB blob;
1342         struct netr_DatabaseSync2 *r;
1343
1344         call = &ndr_table_netlogon.calls[NDR_NETR_DATABASESYNC2];
1345
1346         r = talloc(talloc_tos(), struct netr_DatabaseSync2);
1347         if (r == NULL) {
1348                 return false;
1349         }
1350
1351         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1352                 talloc_free(r);
1353                 return false;
1354         }
1355
1356         pull = ndr_pull_init_blob(&blob, r, NULL);
1357         if (pull == NULL) {
1358                 talloc_free(r);
1359                 return false;
1360         }
1361
1362         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1363         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1364         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1365                 talloc_free(r);
1366                 return false;
1367         }
1368
1369         if (DEBUGLEVEL >= 10) {
1370                 NDR_PRINT_IN_DEBUG(netr_DatabaseSync2, r);
1371         }
1372
1373         ZERO_STRUCT(r->out);
1374         r->out.return_authenticator = r->in.return_authenticator;
1375         r->out.sync_context = r->in.sync_context;
1376         r->out.delta_enum_array = talloc_zero(r, struct netr_DELTA_ENUM_ARRAY *);
1377         if (r->out.delta_enum_array == NULL) {
1378                 talloc_free(r);
1379                 return false;
1380         }
1381
1382         r->out.result = _netr_DatabaseSync2(p, r);
1383
1384         if (p->rng_fault_state) {
1385                 talloc_free(r);
1386                 /* Return true here, srv_pipe_hnd.c will take care */
1387                 return true;
1388         }
1389
1390         if (DEBUGLEVEL >= 10) {
1391                 NDR_PRINT_OUT_DEBUG(netr_DatabaseSync2, r);
1392         }
1393
1394         push = ndr_push_init_ctx(r, NULL);
1395         if (push == NULL) {
1396                 talloc_free(r);
1397                 return false;
1398         }
1399
1400         ndr_err = call->ndr_push(push, NDR_OUT, r);
1401         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1402                 talloc_free(r);
1403                 return false;
1404         }
1405
1406         blob = ndr_push_blob(push);
1407         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1408                 talloc_free(r);
1409                 return false;
1410         }
1411
1412         talloc_free(r);
1413
1414         return true;
1415 }
1416
1417 static bool api_netr_DatabaseRedo(pipes_struct *p)
1418 {
1419         const struct ndr_interface_call *call;
1420         struct ndr_pull *pull;
1421         struct ndr_push *push;
1422         enum ndr_err_code ndr_err;
1423         DATA_BLOB blob;
1424         struct netr_DatabaseRedo *r;
1425
1426         call = &ndr_table_netlogon.calls[NDR_NETR_DATABASEREDO];
1427
1428         r = talloc(talloc_tos(), struct netr_DatabaseRedo);
1429         if (r == NULL) {
1430                 return false;
1431         }
1432
1433         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1434                 talloc_free(r);
1435                 return false;
1436         }
1437
1438         pull = ndr_pull_init_blob(&blob, r, NULL);
1439         if (pull == NULL) {
1440                 talloc_free(r);
1441                 return false;
1442         }
1443
1444         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1445         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1446         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1447                 talloc_free(r);
1448                 return false;
1449         }
1450
1451         if (DEBUGLEVEL >= 10) {
1452                 NDR_PRINT_IN_DEBUG(netr_DatabaseRedo, r);
1453         }
1454
1455         ZERO_STRUCT(r->out);
1456         r->out.return_authenticator = r->in.return_authenticator;
1457         r->out.delta_enum_array = talloc_zero(r, struct netr_DELTA_ENUM_ARRAY *);
1458         if (r->out.delta_enum_array == NULL) {
1459                 talloc_free(r);
1460                 return false;
1461         }
1462
1463         r->out.result = _netr_DatabaseRedo(p, r);
1464
1465         if (p->rng_fault_state) {
1466                 talloc_free(r);
1467                 /* Return true here, srv_pipe_hnd.c will take care */
1468                 return true;
1469         }
1470
1471         if (DEBUGLEVEL >= 10) {
1472                 NDR_PRINT_OUT_DEBUG(netr_DatabaseRedo, r);
1473         }
1474
1475         push = ndr_push_init_ctx(r, NULL);
1476         if (push == NULL) {
1477                 talloc_free(r);
1478                 return false;
1479         }
1480
1481         ndr_err = call->ndr_push(push, NDR_OUT, r);
1482         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1483                 talloc_free(r);
1484                 return false;
1485         }
1486
1487         blob = ndr_push_blob(push);
1488         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1489                 talloc_free(r);
1490                 return false;
1491         }
1492
1493         talloc_free(r);
1494
1495         return true;
1496 }
1497
1498 static bool api_netr_LogonControl2Ex(pipes_struct *p)
1499 {
1500         const struct ndr_interface_call *call;
1501         struct ndr_pull *pull;
1502         struct ndr_push *push;
1503         enum ndr_err_code ndr_err;
1504         DATA_BLOB blob;
1505         struct netr_LogonControl2Ex *r;
1506
1507         call = &ndr_table_netlogon.calls[NDR_NETR_LOGONCONTROL2EX];
1508
1509         r = talloc(talloc_tos(), struct netr_LogonControl2Ex);
1510         if (r == NULL) {
1511                 return false;
1512         }
1513
1514         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1515                 talloc_free(r);
1516                 return false;
1517         }
1518
1519         pull = ndr_pull_init_blob(&blob, r, NULL);
1520         if (pull == NULL) {
1521                 talloc_free(r);
1522                 return false;
1523         }
1524
1525         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1526         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1527         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1528                 talloc_free(r);
1529                 return false;
1530         }
1531
1532         if (DEBUGLEVEL >= 10) {
1533                 NDR_PRINT_IN_DEBUG(netr_LogonControl2Ex, r);
1534         }
1535
1536         ZERO_STRUCT(r->out);
1537         r->out.query = talloc_zero(r, union netr_CONTROL_QUERY_INFORMATION);
1538         if (r->out.query == NULL) {
1539                 talloc_free(r);
1540                 return false;
1541         }
1542
1543         r->out.result = _netr_LogonControl2Ex(p, r);
1544
1545         if (p->rng_fault_state) {
1546                 talloc_free(r);
1547                 /* Return true here, srv_pipe_hnd.c will take care */
1548                 return true;
1549         }
1550
1551         if (DEBUGLEVEL >= 10) {
1552                 NDR_PRINT_OUT_DEBUG(netr_LogonControl2Ex, r);
1553         }
1554
1555         push = ndr_push_init_ctx(r, NULL);
1556         if (push == NULL) {
1557                 talloc_free(r);
1558                 return false;
1559         }
1560
1561         ndr_err = call->ndr_push(push, NDR_OUT, r);
1562         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1563                 talloc_free(r);
1564                 return false;
1565         }
1566
1567         blob = ndr_push_blob(push);
1568         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1569                 talloc_free(r);
1570                 return false;
1571         }
1572
1573         talloc_free(r);
1574
1575         return true;
1576 }
1577
1578 static bool api_netr_NetrEnumerateTrustedDomains(pipes_struct *p)
1579 {
1580         const struct ndr_interface_call *call;
1581         struct ndr_pull *pull;
1582         struct ndr_push *push;
1583         enum ndr_err_code ndr_err;
1584         DATA_BLOB blob;
1585         struct netr_NetrEnumerateTrustedDomains *r;
1586
1587         call = &ndr_table_netlogon.calls[NDR_NETR_NETRENUMERATETRUSTEDDOMAINS];
1588
1589         r = talloc(talloc_tos(), struct netr_NetrEnumerateTrustedDomains);
1590         if (r == NULL) {
1591                 return false;
1592         }
1593
1594         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1595                 talloc_free(r);
1596                 return false;
1597         }
1598
1599         pull = ndr_pull_init_blob(&blob, r, NULL);
1600         if (pull == NULL) {
1601                 talloc_free(r);
1602                 return false;
1603         }
1604
1605         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1606         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1607         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1608                 talloc_free(r);
1609                 return false;
1610         }
1611
1612         if (DEBUGLEVEL >= 10) {
1613                 NDR_PRINT_IN_DEBUG(netr_NetrEnumerateTrustedDomains, r);
1614         }
1615
1616         ZERO_STRUCT(r->out);
1617         r->out.trusted_domains_blob = talloc_zero(r, struct netr_Blob);
1618         if (r->out.trusted_domains_blob == NULL) {
1619                 talloc_free(r);
1620                 return false;
1621         }
1622
1623         r->out.result = _netr_NetrEnumerateTrustedDomains(p, r);
1624
1625         if (p->rng_fault_state) {
1626                 talloc_free(r);
1627                 /* Return true here, srv_pipe_hnd.c will take care */
1628                 return true;
1629         }
1630
1631         if (DEBUGLEVEL >= 10) {
1632                 NDR_PRINT_OUT_DEBUG(netr_NetrEnumerateTrustedDomains, r);
1633         }
1634
1635         push = ndr_push_init_ctx(r, NULL);
1636         if (push == NULL) {
1637                 talloc_free(r);
1638                 return false;
1639         }
1640
1641         ndr_err = call->ndr_push(push, NDR_OUT, r);
1642         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1643                 talloc_free(r);
1644                 return false;
1645         }
1646
1647         blob = ndr_push_blob(push);
1648         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1649                 talloc_free(r);
1650                 return false;
1651         }
1652
1653         talloc_free(r);
1654
1655         return true;
1656 }
1657
1658 static bool api_netr_DsRGetDCName(pipes_struct *p)
1659 {
1660         const struct ndr_interface_call *call;
1661         struct ndr_pull *pull;
1662         struct ndr_push *push;
1663         enum ndr_err_code ndr_err;
1664         DATA_BLOB blob;
1665         struct netr_DsRGetDCName *r;
1666
1667         call = &ndr_table_netlogon.calls[NDR_NETR_DSRGETDCNAME];
1668
1669         r = talloc(talloc_tos(), struct netr_DsRGetDCName);
1670         if (r == NULL) {
1671                 return false;
1672         }
1673
1674         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1675                 talloc_free(r);
1676                 return false;
1677         }
1678
1679         pull = ndr_pull_init_blob(&blob, r, NULL);
1680         if (pull == NULL) {
1681                 talloc_free(r);
1682                 return false;
1683         }
1684
1685         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1686         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1687         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1688                 talloc_free(r);
1689                 return false;
1690         }
1691
1692         if (DEBUGLEVEL >= 10) {
1693                 NDR_PRINT_IN_DEBUG(netr_DsRGetDCName, r);
1694         }
1695
1696         ZERO_STRUCT(r->out);
1697         r->out.info = talloc_zero(r, struct netr_DsRGetDCNameInfo *);
1698         if (r->out.info == NULL) {
1699                 talloc_free(r);
1700                 return false;
1701         }
1702
1703         r->out.result = _netr_DsRGetDCName(p, r);
1704
1705         if (p->rng_fault_state) {
1706                 talloc_free(r);
1707                 /* Return true here, srv_pipe_hnd.c will take care */
1708                 return true;
1709         }
1710
1711         if (DEBUGLEVEL >= 10) {
1712                 NDR_PRINT_OUT_DEBUG(netr_DsRGetDCName, r);
1713         }
1714
1715         push = ndr_push_init_ctx(r, NULL);
1716         if (push == NULL) {
1717                 talloc_free(r);
1718                 return false;
1719         }
1720
1721         ndr_err = call->ndr_push(push, NDR_OUT, r);
1722         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1723                 talloc_free(r);
1724                 return false;
1725         }
1726
1727         blob = ndr_push_blob(push);
1728         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1729                 talloc_free(r);
1730                 return false;
1731         }
1732
1733         talloc_free(r);
1734
1735         return true;
1736 }
1737
1738 static bool api_netr_NETRLOGONDUMMYROUTINE1(pipes_struct *p)
1739 {
1740         const struct ndr_interface_call *call;
1741         struct ndr_pull *pull;
1742         struct ndr_push *push;
1743         enum ndr_err_code ndr_err;
1744         DATA_BLOB blob;
1745         struct netr_NETRLOGONDUMMYROUTINE1 *r;
1746
1747         call = &ndr_table_netlogon.calls[NDR_NETR_NETRLOGONDUMMYROUTINE1];
1748
1749         r = talloc(talloc_tos(), struct netr_NETRLOGONDUMMYROUTINE1);
1750         if (r == NULL) {
1751                 return false;
1752         }
1753
1754         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1755                 talloc_free(r);
1756                 return false;
1757         }
1758
1759         pull = ndr_pull_init_blob(&blob, r, NULL);
1760         if (pull == NULL) {
1761                 talloc_free(r);
1762                 return false;
1763         }
1764
1765         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1766         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1767         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1768                 talloc_free(r);
1769                 return false;
1770         }
1771
1772         if (DEBUGLEVEL >= 10) {
1773                 NDR_PRINT_IN_DEBUG(netr_NETRLOGONDUMMYROUTINE1, r);
1774         }
1775
1776         r->out.result = _netr_NETRLOGONDUMMYROUTINE1(p, r);
1777
1778         if (p->rng_fault_state) {
1779                 talloc_free(r);
1780                 /* Return true here, srv_pipe_hnd.c will take care */
1781                 return true;
1782         }
1783
1784         if (DEBUGLEVEL >= 10) {
1785                 NDR_PRINT_OUT_DEBUG(netr_NETRLOGONDUMMYROUTINE1, r);
1786         }
1787
1788         push = ndr_push_init_ctx(r, NULL);
1789         if (push == NULL) {
1790                 talloc_free(r);
1791                 return false;
1792         }
1793
1794         ndr_err = call->ndr_push(push, NDR_OUT, r);
1795         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1796                 talloc_free(r);
1797                 return false;
1798         }
1799
1800         blob = ndr_push_blob(push);
1801         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1802                 talloc_free(r);
1803                 return false;
1804         }
1805
1806         talloc_free(r);
1807
1808         return true;
1809 }
1810
1811 static bool api_netr_NETRLOGONSETSERVICEBITS(pipes_struct *p)
1812 {
1813         const struct ndr_interface_call *call;
1814         struct ndr_pull *pull;
1815         struct ndr_push *push;
1816         enum ndr_err_code ndr_err;
1817         DATA_BLOB blob;
1818         struct netr_NETRLOGONSETSERVICEBITS *r;
1819
1820         call = &ndr_table_netlogon.calls[NDR_NETR_NETRLOGONSETSERVICEBITS];
1821
1822         r = talloc(talloc_tos(), struct netr_NETRLOGONSETSERVICEBITS);
1823         if (r == NULL) {
1824                 return false;
1825         }
1826
1827         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1828                 talloc_free(r);
1829                 return false;
1830         }
1831
1832         pull = ndr_pull_init_blob(&blob, r, NULL);
1833         if (pull == NULL) {
1834                 talloc_free(r);
1835                 return false;
1836         }
1837
1838         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1839         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1840         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1841                 talloc_free(r);
1842                 return false;
1843         }
1844
1845         if (DEBUGLEVEL >= 10) {
1846                 NDR_PRINT_IN_DEBUG(netr_NETRLOGONSETSERVICEBITS, r);
1847         }
1848
1849         r->out.result = _netr_NETRLOGONSETSERVICEBITS(p, r);
1850
1851         if (p->rng_fault_state) {
1852                 talloc_free(r);
1853                 /* Return true here, srv_pipe_hnd.c will take care */
1854                 return true;
1855         }
1856
1857         if (DEBUGLEVEL >= 10) {
1858                 NDR_PRINT_OUT_DEBUG(netr_NETRLOGONSETSERVICEBITS, r);
1859         }
1860
1861         push = ndr_push_init_ctx(r, NULL);
1862         if (push == NULL) {
1863                 talloc_free(r);
1864                 return false;
1865         }
1866
1867         ndr_err = call->ndr_push(push, NDR_OUT, r);
1868         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1869                 talloc_free(r);
1870                 return false;
1871         }
1872
1873         blob = ndr_push_blob(push);
1874         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1875                 talloc_free(r);
1876                 return false;
1877         }
1878
1879         talloc_free(r);
1880
1881         return true;
1882 }
1883
1884 static bool api_netr_LogonGetTrustRid(pipes_struct *p)
1885 {
1886         const struct ndr_interface_call *call;
1887         struct ndr_pull *pull;
1888         struct ndr_push *push;
1889         enum ndr_err_code ndr_err;
1890         DATA_BLOB blob;
1891         struct netr_LogonGetTrustRid *r;
1892
1893         call = &ndr_table_netlogon.calls[NDR_NETR_LOGONGETTRUSTRID];
1894
1895         r = talloc(talloc_tos(), struct netr_LogonGetTrustRid);
1896         if (r == NULL) {
1897                 return false;
1898         }
1899
1900         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1901                 talloc_free(r);
1902                 return false;
1903         }
1904
1905         pull = ndr_pull_init_blob(&blob, r, NULL);
1906         if (pull == NULL) {
1907                 talloc_free(r);
1908                 return false;
1909         }
1910
1911         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1912         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1913         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1914                 talloc_free(r);
1915                 return false;
1916         }
1917
1918         if (DEBUGLEVEL >= 10) {
1919                 NDR_PRINT_IN_DEBUG(netr_LogonGetTrustRid, r);
1920         }
1921
1922         ZERO_STRUCT(r->out);
1923         r->out.rid = talloc_zero(r, uint32_t);
1924         if (r->out.rid == NULL) {
1925                 talloc_free(r);
1926                 return false;
1927         }
1928
1929         r->out.result = _netr_LogonGetTrustRid(p, r);
1930
1931         if (p->rng_fault_state) {
1932                 talloc_free(r);
1933                 /* Return true here, srv_pipe_hnd.c will take care */
1934                 return true;
1935         }
1936
1937         if (DEBUGLEVEL >= 10) {
1938                 NDR_PRINT_OUT_DEBUG(netr_LogonGetTrustRid, r);
1939         }
1940
1941         push = ndr_push_init_ctx(r, NULL);
1942         if (push == NULL) {
1943                 talloc_free(r);
1944                 return false;
1945         }
1946
1947         ndr_err = call->ndr_push(push, NDR_OUT, r);
1948         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1949                 talloc_free(r);
1950                 return false;
1951         }
1952
1953         blob = ndr_push_blob(push);
1954         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1955                 talloc_free(r);
1956                 return false;
1957         }
1958
1959         talloc_free(r);
1960
1961         return true;
1962 }
1963
1964 static bool api_netr_NETRLOGONCOMPUTESERVERDIGEST(pipes_struct *p)
1965 {
1966         const struct ndr_interface_call *call;
1967         struct ndr_pull *pull;
1968         struct ndr_push *push;
1969         enum ndr_err_code ndr_err;
1970         DATA_BLOB blob;
1971         struct netr_NETRLOGONCOMPUTESERVERDIGEST *r;
1972
1973         call = &ndr_table_netlogon.calls[NDR_NETR_NETRLOGONCOMPUTESERVERDIGEST];
1974
1975         r = talloc(talloc_tos(), struct netr_NETRLOGONCOMPUTESERVERDIGEST);
1976         if (r == NULL) {
1977                 return false;
1978         }
1979
1980         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1981                 talloc_free(r);
1982                 return false;
1983         }
1984
1985         pull = ndr_pull_init_blob(&blob, r, NULL);
1986         if (pull == NULL) {
1987                 talloc_free(r);
1988                 return false;
1989         }
1990
1991         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1992         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1993         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1994                 talloc_free(r);
1995                 return false;
1996         }
1997
1998         if (DEBUGLEVEL >= 10) {
1999                 NDR_PRINT_IN_DEBUG(netr_NETRLOGONCOMPUTESERVERDIGEST, r);
2000         }
2001
2002         r->out.result = _netr_NETRLOGONCOMPUTESERVERDIGEST(p, r);
2003
2004         if (p->rng_fault_state) {
2005                 talloc_free(r);
2006                 /* Return true here, srv_pipe_hnd.c will take care */
2007                 return true;
2008         }
2009
2010         if (DEBUGLEVEL >= 10) {
2011                 NDR_PRINT_OUT_DEBUG(netr_NETRLOGONCOMPUTESERVERDIGEST, r);
2012         }
2013
2014         push = ndr_push_init_ctx(r, NULL);
2015         if (push == NULL) {
2016                 talloc_free(r);
2017                 return false;
2018         }
2019
2020         ndr_err = call->ndr_push(push, NDR_OUT, r);
2021         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2022                 talloc_free(r);
2023                 return false;
2024         }
2025
2026         blob = ndr_push_blob(push);
2027         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2028                 talloc_free(r);
2029                 return false;
2030         }
2031
2032         talloc_free(r);
2033
2034         return true;
2035 }
2036
2037 static bool api_netr_NETRLOGONCOMPUTECLIENTDIGEST(pipes_struct *p)
2038 {
2039         const struct ndr_interface_call *call;
2040         struct ndr_pull *pull;
2041         struct ndr_push *push;
2042         enum ndr_err_code ndr_err;
2043         DATA_BLOB blob;
2044         struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r;
2045
2046         call = &ndr_table_netlogon.calls[NDR_NETR_NETRLOGONCOMPUTECLIENTDIGEST];
2047
2048         r = talloc(talloc_tos(), struct netr_NETRLOGONCOMPUTECLIENTDIGEST);
2049         if (r == NULL) {
2050                 return false;
2051         }
2052
2053         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
2054                 talloc_free(r);
2055                 return false;
2056         }
2057
2058         pull = ndr_pull_init_blob(&blob, r, NULL);
2059         if (pull == NULL) {
2060                 talloc_free(r);
2061                 return false;
2062         }
2063
2064         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
2065         ndr_err = call->ndr_pull(pull, NDR_IN, r);
2066         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2067                 talloc_free(r);
2068                 return false;
2069         }
2070
2071         if (DEBUGLEVEL >= 10) {
2072                 NDR_PRINT_IN_DEBUG(netr_NETRLOGONCOMPUTECLIENTDIGEST, r);
2073         }
2074
2075         r->out.result = _netr_NETRLOGONCOMPUTECLIENTDIGEST(p, r);
2076
2077         if (p->rng_fault_state) {
2078                 talloc_free(r);
2079                 /* Return true here, srv_pipe_hnd.c will take care */
2080                 return true;
2081         }
2082
2083         if (DEBUGLEVEL >= 10) {
2084                 NDR_PRINT_OUT_DEBUG(netr_NETRLOGONCOMPUTECLIENTDIGEST, r);
2085         }
2086
2087         push = ndr_push_init_ctx(r, NULL);
2088         if (push == NULL) {
2089                 talloc_free(r);
2090                 return false;
2091         }
2092
2093         ndr_err = call->ndr_push(push, NDR_OUT, r);
2094         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2095                 talloc_free(r);
2096                 return false;
2097         }
2098
2099         blob = ndr_push_blob(push);
2100         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2101                 talloc_free(r);
2102                 return false;
2103         }
2104
2105         talloc_free(r);
2106
2107         return true;
2108 }
2109
2110 static bool api_netr_ServerAuthenticate3(pipes_struct *p)
2111 {
2112         const struct ndr_interface_call *call;
2113         struct ndr_pull *pull;
2114         struct ndr_push *push;
2115         enum ndr_err_code ndr_err;
2116         DATA_BLOB blob;
2117         struct netr_ServerAuthenticate3 *r;
2118
2119         call = &ndr_table_netlogon.calls[NDR_NETR_SERVERAUTHENTICATE3];
2120
2121         r = talloc(talloc_tos(), struct netr_ServerAuthenticate3);
2122         if (r == NULL) {
2123                 return false;
2124         }
2125
2126         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
2127                 talloc_free(r);
2128                 return false;
2129         }
2130
2131         pull = ndr_pull_init_blob(&blob, r, NULL);
2132         if (pull == NULL) {
2133                 talloc_free(r);
2134                 return false;
2135         }
2136
2137         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
2138         ndr_err = call->ndr_pull(pull, NDR_IN, r);
2139         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2140                 talloc_free(r);
2141                 return false;
2142         }
2143
2144         if (DEBUGLEVEL >= 10) {
2145                 NDR_PRINT_IN_DEBUG(netr_ServerAuthenticate3, r);
2146         }
2147
2148         ZERO_STRUCT(r->out);
2149         r->out.negotiate_flags = r->in.negotiate_flags;
2150         r->out.return_credentials = talloc_zero(r, struct netr_Credential);
2151         if (r->out.return_credentials == NULL) {
2152                 talloc_free(r);
2153                 return false;
2154         }
2155
2156         r->out.rid = talloc_zero(r, uint32_t);
2157         if (r->out.rid == NULL) {
2158                 talloc_free(r);
2159                 return false;
2160         }
2161
2162         r->out.result = _netr_ServerAuthenticate3(p, r);
2163
2164         if (p->rng_fault_state) {
2165                 talloc_free(r);
2166                 /* Return true here, srv_pipe_hnd.c will take care */
2167                 return true;
2168         }
2169
2170         if (DEBUGLEVEL >= 10) {
2171                 NDR_PRINT_OUT_DEBUG(netr_ServerAuthenticate3, r);
2172         }
2173
2174         push = ndr_push_init_ctx(r, NULL);
2175         if (push == NULL) {
2176                 talloc_free(r);
2177                 return false;
2178         }
2179
2180         ndr_err = call->ndr_push(push, NDR_OUT, r);
2181         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2182                 talloc_free(r);
2183                 return false;
2184         }
2185
2186         blob = ndr_push_blob(push);
2187         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2188                 talloc_free(r);
2189                 return false;
2190         }
2191
2192         talloc_free(r);
2193
2194         return true;
2195 }
2196
2197 static bool api_netr_DsRGetDCNameEx(pipes_struct *p)
2198 {
2199         const struct ndr_interface_call *call;
2200         struct ndr_pull *pull;
2201         struct ndr_push *push;
2202         enum ndr_err_code ndr_err;
2203         DATA_BLOB blob;
2204         struct netr_DsRGetDCNameEx *r;
2205
2206         call = &ndr_table_netlogon.calls[NDR_NETR_DSRGETDCNAMEEX];
2207
2208         r = talloc(talloc_tos(), struct netr_DsRGetDCNameEx);
2209         if (r == NULL) {
2210                 return false;
2211         }
2212
2213         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
2214                 talloc_free(r);
2215                 return false;
2216         }
2217
2218         pull = ndr_pull_init_blob(&blob, r, NULL);
2219         if (pull == NULL) {
2220                 talloc_free(r);
2221                 return false;
2222         }
2223
2224         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
2225         ndr_err = call->ndr_pull(pull, NDR_IN, r);
2226         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2227                 talloc_free(r);
2228                 return false;
2229         }
2230
2231         if (DEBUGLEVEL >= 10) {
2232                 NDR_PRINT_IN_DEBUG(netr_DsRGetDCNameEx, r);
2233         }
2234
2235         ZERO_STRUCT(r->out);
2236         r->out.info = talloc_zero(r, struct netr_DsRGetDCNameInfo *);
2237         if (r->out.info == NULL) {
2238                 talloc_free(r);
2239                 return false;
2240         }
2241
2242         r->out.result = _netr_DsRGetDCNameEx(p, r);
2243
2244         if (p->rng_fault_state) {
2245                 talloc_free(r);
2246                 /* Return true here, srv_pipe_hnd.c will take care */
2247                 return true;
2248         }
2249
2250         if (DEBUGLEVEL >= 10) {
2251                 NDR_PRINT_OUT_DEBUG(netr_DsRGetDCNameEx, r);
2252         }
2253
2254         push = ndr_push_init_ctx(r, NULL);
2255         if (push == NULL) {
2256                 talloc_free(r);
2257                 return false;
2258         }
2259
2260         ndr_err = call->ndr_push(push, NDR_OUT, r);
2261         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2262                 talloc_free(r);
2263                 return false;
2264         }
2265
2266         blob = ndr_push_blob(push);
2267         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2268                 talloc_free(r);
2269                 return false;
2270         }
2271
2272         talloc_free(r);
2273
2274         return true;
2275 }
2276
2277 static bool api_netr_DsRGetSiteName(pipes_struct *p)
2278 {
2279         const struct ndr_interface_call *call;
2280         struct ndr_pull *pull;
2281         struct ndr_push *push;
2282         enum ndr_err_code ndr_err;
2283         DATA_BLOB blob;
2284         struct netr_DsRGetSiteName *r;
2285
2286         call = &ndr_table_netlogon.calls[NDR_NETR_DSRGETSITENAME];
2287
2288         r = talloc(talloc_tos(), struct netr_DsRGetSiteName);
2289         if (r == NULL) {
2290                 return false;
2291         }
2292
2293         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
2294                 talloc_free(r);
2295                 return false;
2296         }
2297
2298         pull = ndr_pull_init_blob(&blob, r, NULL);
2299         if (pull == NULL) {
2300                 talloc_free(r);
2301                 return false;
2302         }
2303
2304         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
2305         ndr_err = call->ndr_pull(pull, NDR_IN, r);
2306         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2307                 talloc_free(r);
2308                 return false;
2309         }
2310
2311         if (DEBUGLEVEL >= 10) {
2312                 NDR_PRINT_IN_DEBUG(netr_DsRGetSiteName, r);
2313         }
2314
2315         ZERO_STRUCT(r->out);
2316         r->out.site = talloc_zero(r, const char *);
2317         if (r->out.site == NULL) {
2318                 talloc_free(r);
2319                 return false;
2320         }
2321
2322         r->out.result = _netr_DsRGetSiteName(p, r);
2323
2324         if (p->rng_fault_state) {
2325                 talloc_free(r);
2326                 /* Return true here, srv_pipe_hnd.c will take care */
2327                 return true;
2328         }
2329
2330         if (DEBUGLEVEL >= 10) {
2331                 NDR_PRINT_OUT_DEBUG(netr_DsRGetSiteName, r);
2332         }
2333
2334         push = ndr_push_init_ctx(r, NULL);
2335         if (push == NULL) {
2336                 talloc_free(r);
2337                 return false;
2338         }
2339
2340         ndr_err = call->ndr_push(push, NDR_OUT, r);
2341         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2342                 talloc_free(r);
2343                 return false;
2344         }
2345
2346         blob = ndr_push_blob(push);
2347         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2348                 talloc_free(r);
2349                 return false;
2350         }
2351
2352         talloc_free(r);
2353
2354         return true;
2355 }
2356
2357 static bool api_netr_LogonGetDomainInfo(pipes_struct *p)
2358 {
2359         const struct ndr_interface_call *call;
2360         struct ndr_pull *pull;
2361         struct ndr_push *push;
2362         enum ndr_err_code ndr_err;
2363         DATA_BLOB blob;
2364         struct netr_LogonGetDomainInfo *r;
2365
2366         call = &ndr_table_netlogon.calls[NDR_NETR_LOGONGETDOMAININFO];
2367
2368         r = talloc(talloc_tos(), struct netr_LogonGetDomainInfo);
2369         if (r == NULL) {
2370                 return false;
2371         }
2372
2373         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
2374                 talloc_free(r);
2375                 return false;
2376         }
2377
2378         pull = ndr_pull_init_blob(&blob, r, NULL);
2379         if (pull == NULL) {
2380                 talloc_free(r);
2381                 return false;
2382         }
2383
2384         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
2385         ndr_err = call->ndr_pull(pull, NDR_IN, r);
2386         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2387                 talloc_free(r);
2388                 return false;
2389         }
2390
2391         if (DEBUGLEVEL >= 10) {
2392                 NDR_PRINT_IN_DEBUG(netr_LogonGetDomainInfo, r);
2393         }
2394
2395         ZERO_STRUCT(r->out);
2396         r->out.return_authenticator = r->in.return_authenticator;
2397         r->out.info = talloc_zero(r, union netr_DomainInfo);
2398         if (r->out.info == NULL) {
2399                 talloc_free(r);
2400                 return false;
2401         }
2402
2403         r->out.result = _netr_LogonGetDomainInfo(p, r);
2404
2405         if (p->rng_fault_state) {
2406                 talloc_free(r);
2407                 /* Return true here, srv_pipe_hnd.c will take care */
2408                 return true;
2409         }
2410
2411         if (DEBUGLEVEL >= 10) {
2412                 NDR_PRINT_OUT_DEBUG(netr_LogonGetDomainInfo, r);
2413         }
2414
2415         push = ndr_push_init_ctx(r, NULL);
2416         if (push == NULL) {
2417                 talloc_free(r);
2418                 return false;
2419         }
2420
2421         ndr_err = call->ndr_push(push, NDR_OUT, r);
2422         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2423                 talloc_free(r);
2424                 return false;
2425         }
2426
2427         blob = ndr_push_blob(push);
2428         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2429                 talloc_free(r);
2430                 return false;
2431         }
2432
2433         talloc_free(r);
2434
2435         return true;
2436 }
2437
2438 static bool api_netr_ServerPasswordSet2(pipes_struct *p)
2439 {
2440         const struct ndr_interface_call *call;
2441         struct ndr_pull *pull;
2442         struct ndr_push *push;
2443         enum ndr_err_code ndr_err;
2444         DATA_BLOB blob;
2445         struct netr_ServerPasswordSet2 *r;
2446
2447         call = &ndr_table_netlogon.calls[NDR_NETR_SERVERPASSWORDSET2];
2448
2449         r = talloc(talloc_tos(), struct netr_ServerPasswordSet2);
2450         if (r == NULL) {
2451                 return false;
2452         }
2453
2454         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
2455                 talloc_free(r);
2456                 return false;
2457         }
2458
2459         pull = ndr_pull_init_blob(&blob, r, NULL);
2460         if (pull == NULL) {
2461                 talloc_free(r);
2462                 return false;
2463         }
2464
2465         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
2466         ndr_err = call->ndr_pull(pull, NDR_IN, r);
2467         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2468                 talloc_free(r);
2469                 return false;
2470         }
2471
2472         if (DEBUGLEVEL >= 10) {
2473                 NDR_PRINT_IN_DEBUG(netr_ServerPasswordSet2, r);
2474         }
2475
2476         ZERO_STRUCT(r->out);
2477         r->out.return_authenticator = talloc_zero(r, struct netr_Authenticator);
2478         if (r->out.return_authenticator == NULL) {
2479                 talloc_free(r);
2480                 return false;
2481         }
2482
2483         r->out.result = _netr_ServerPasswordSet2(p, r);
2484
2485         if (p->rng_fault_state) {
2486                 talloc_free(r);
2487                 /* Return true here, srv_pipe_hnd.c will take care */
2488                 return true;
2489         }
2490
2491         if (DEBUGLEVEL >= 10) {
2492                 NDR_PRINT_OUT_DEBUG(netr_ServerPasswordSet2, r);
2493         }
2494
2495         push = ndr_push_init_ctx(r, NULL);
2496         if (push == NULL) {
2497                 talloc_free(r);
2498                 return false;
2499         }
2500
2501         ndr_err = call->ndr_push(push, NDR_OUT, r);
2502         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2503                 talloc_free(r);
2504                 return false;
2505         }
2506
2507         blob = ndr_push_blob(push);
2508         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2509                 talloc_free(r);
2510                 return false;
2511         }
2512
2513         talloc_free(r);
2514
2515         return true;
2516 }
2517
2518 static bool api_netr_ServerPasswordGet(pipes_struct *p)
2519 {
2520         const struct ndr_interface_call *call;
2521         struct ndr_pull *pull;
2522         struct ndr_push *push;
2523         enum ndr_err_code ndr_err;
2524         DATA_BLOB blob;
2525         struct netr_ServerPasswordGet *r;
2526
2527         call = &ndr_table_netlogon.calls[NDR_NETR_SERVERPASSWORDGET];
2528
2529         r = talloc(talloc_tos(), struct netr_ServerPasswordGet);
2530         if (r == NULL) {
2531                 return false;
2532         }
2533
2534         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
2535                 talloc_free(r);
2536                 return false;
2537         }
2538
2539         pull = ndr_pull_init_blob(&blob, r, NULL);
2540         if (pull == NULL) {
2541                 talloc_free(r);
2542                 return false;
2543         }
2544
2545         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
2546         ndr_err = call->ndr_pull(pull, NDR_IN, r);
2547         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2548                 talloc_free(r);
2549                 return false;
2550         }
2551
2552         if (DEBUGLEVEL >= 10) {
2553                 NDR_PRINT_IN_DEBUG(netr_ServerPasswordGet, r);
2554         }
2555
2556         ZERO_STRUCT(r->out);
2557         r->out.return_authenticator = talloc_zero(r, struct netr_Authenticator);
2558         if (r->out.return_authenticator == NULL) {
2559                 talloc_free(r);
2560                 return false;
2561         }
2562
2563         r->out.password = talloc_zero(r, struct samr_Password);
2564         if (r->out.password == NULL) {
2565                 talloc_free(r);
2566                 return false;
2567         }
2568
2569         r->out.result = _netr_ServerPasswordGet(p, r);
2570
2571         if (p->rng_fault_state) {
2572                 talloc_free(r);
2573                 /* Return true here, srv_pipe_hnd.c will take care */
2574                 return true;
2575         }
2576
2577         if (DEBUGLEVEL >= 10) {
2578                 NDR_PRINT_OUT_DEBUG(netr_ServerPasswordGet, r);
2579         }
2580
2581         push = ndr_push_init_ctx(r, NULL);
2582         if (push == NULL) {
2583                 talloc_free(r);
2584                 return false;
2585         }
2586
2587         ndr_err = call->ndr_push(push, NDR_OUT, r);
2588         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2589                 talloc_free(r);
2590                 return false;
2591         }
2592
2593         blob = ndr_push_blob(push);
2594         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2595                 talloc_free(r);
2596                 return false;
2597         }
2598
2599         talloc_free(r);
2600
2601         return true;
2602 }
2603
2604 static bool api_netr_NETRLOGONSENDTOSAM(pipes_struct *p)
2605 {
2606         const struct ndr_interface_call *call;
2607         struct ndr_pull *pull;
2608         struct ndr_push *push;
2609         enum ndr_err_code ndr_err;
2610         DATA_BLOB blob;
2611         struct netr_NETRLOGONSENDTOSAM *r;
2612
2613         call = &ndr_table_netlogon.calls[NDR_NETR_NETRLOGONSENDTOSAM];
2614
2615         r = talloc(talloc_tos(), struct netr_NETRLOGONSENDTOSAM);
2616         if (r == NULL) {
2617                 return false;
2618         }
2619
2620         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
2621                 talloc_free(r);
2622                 return false;
2623         }
2624
2625         pull = ndr_pull_init_blob(&blob, r, NULL);
2626         if (pull == NULL) {
2627                 talloc_free(r);
2628                 return false;
2629         }
2630
2631         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
2632         ndr_err = call->ndr_pull(pull, NDR_IN, r);
2633         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2634                 talloc_free(r);
2635                 return false;
2636         }
2637
2638         if (DEBUGLEVEL >= 10) {
2639                 NDR_PRINT_IN_DEBUG(netr_NETRLOGONSENDTOSAM, r);
2640         }
2641
2642         r->out.result = _netr_NETRLOGONSENDTOSAM(p, r);
2643
2644         if (p->rng_fault_state) {
2645                 talloc_free(r);
2646                 /* Return true here, srv_pipe_hnd.c will take care */
2647                 return true;
2648         }
2649
2650         if (DEBUGLEVEL >= 10) {
2651                 NDR_PRINT_OUT_DEBUG(netr_NETRLOGONSENDTOSAM, r);
2652         }
2653
2654         push = ndr_push_init_ctx(r, NULL);
2655         if (push == NULL) {
2656                 talloc_free(r);
2657                 return false;
2658         }
2659
2660         ndr_err = call->ndr_push(push, NDR_OUT, r);
2661         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2662                 talloc_free(r);
2663                 return false;
2664         }
2665
2666         blob = ndr_push_blob(push);
2667         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2668                 talloc_free(r);
2669                 return false;
2670         }
2671
2672         talloc_free(r);
2673
2674         return true;
2675 }
2676
2677 static bool api_netr_DsRAddressToSitenamesW(pipes_struct *p)
2678 {
2679         const struct ndr_interface_call *call;
2680         struct ndr_pull *pull;
2681         struct ndr_push *push;
2682         enum ndr_err_code ndr_err;
2683         DATA_BLOB blob;
2684         struct netr_DsRAddressToSitenamesW *r;
2685
2686         call = &ndr_table_netlogon.calls[NDR_NETR_DSRADDRESSTOSITENAMESW];
2687
2688         r = talloc(talloc_tos(), struct netr_DsRAddressToSitenamesW);
2689         if (r == NULL) {
2690                 return false;
2691         }
2692
2693         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
2694                 talloc_free(r);
2695                 return false;
2696         }
2697
2698         pull = ndr_pull_init_blob(&blob, r, NULL);
2699         if (pull == NULL) {
2700                 talloc_free(r);
2701                 return false;
2702         }
2703
2704         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
2705         ndr_err = call->ndr_pull(pull, NDR_IN, r);
2706         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2707                 talloc_free(r);
2708                 return false;
2709         }
2710
2711         if (DEBUGLEVEL >= 10) {
2712                 NDR_PRINT_IN_DEBUG(netr_DsRAddressToSitenamesW, r);
2713         }
2714
2715         ZERO_STRUCT(r->out);
2716         r->out.ctr = talloc_zero(r, struct netr_DsRAddressToSitenamesWCtr *);
2717         if (r->out.ctr == NULL) {
2718                 talloc_free(r);
2719                 return false;
2720         }
2721
2722         r->out.result = _netr_DsRAddressToSitenamesW(p, r);
2723
2724         if (p->rng_fault_state) {
2725                 talloc_free(r);
2726                 /* Return true here, srv_pipe_hnd.c will take care */
2727                 return true;
2728         }
2729
2730         if (DEBUGLEVEL >= 10) {
2731                 NDR_PRINT_OUT_DEBUG(netr_DsRAddressToSitenamesW, r);
2732         }
2733
2734         push = ndr_push_init_ctx(r, NULL);
2735         if (push == NULL) {
2736                 talloc_free(r);
2737                 return false;
2738         }
2739
2740         ndr_err = call->ndr_push(push, NDR_OUT, r);
2741         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2742                 talloc_free(r);
2743                 return false;
2744         }
2745
2746         blob = ndr_push_blob(push);
2747         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2748                 talloc_free(r);
2749                 return false;
2750         }
2751
2752         talloc_free(r);
2753
2754         return true;
2755 }
2756
2757 static bool api_netr_DsRGetDCNameEx2(pipes_struct *p)
2758 {
2759         const struct ndr_interface_call *call;
2760         struct ndr_pull *pull;
2761         struct ndr_push *push;
2762         enum ndr_err_code ndr_err;
2763         DATA_BLOB blob;
2764         struct netr_DsRGetDCNameEx2 *r;
2765
2766         call = &ndr_table_netlogon.calls[NDR_NETR_DSRGETDCNAMEEX2];
2767
2768         r = talloc(talloc_tos(), struct netr_DsRGetDCNameEx2);
2769         if (r == NULL) {
2770                 return false;
2771         }
2772
2773         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
2774                 talloc_free(r);
2775                 return false;
2776         }
2777
2778         pull = ndr_pull_init_blob(&blob, r, NULL);
2779         if (pull == NULL) {
2780                 talloc_free(r);
2781                 return false;
2782         }
2783
2784         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
2785         ndr_err = call->ndr_pull(pull, NDR_IN, r);
2786         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2787                 talloc_free(r);
2788                 return false;
2789         }
2790
2791         if (DEBUGLEVEL >= 10) {
2792                 NDR_PRINT_IN_DEBUG(netr_DsRGetDCNameEx2, r);
2793         }
2794
2795         ZERO_STRUCT(r->out);
2796         r->out.info = talloc_zero(r, struct netr_DsRGetDCNameInfo *);
2797         if (r->out.info == NULL) {
2798                 talloc_free(r);
2799                 return false;
2800         }
2801
2802         r->out.result = _netr_DsRGetDCNameEx2(p, r);
2803
2804         if (p->rng_fault_state) {
2805                 talloc_free(r);
2806                 /* Return true here, srv_pipe_hnd.c will take care */
2807                 return true;
2808         }
2809
2810         if (DEBUGLEVEL >= 10) {
2811                 NDR_PRINT_OUT_DEBUG(netr_DsRGetDCNameEx2, r);
2812         }
2813
2814         push = ndr_push_init_ctx(r, NULL);
2815         if (push == NULL) {
2816                 talloc_free(r);
2817                 return false;
2818         }
2819
2820         ndr_err = call->ndr_push(push, NDR_OUT, r);
2821         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2822                 talloc_free(r);
2823                 return false;
2824         }
2825
2826         blob = ndr_push_blob(push);
2827         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2828                 talloc_free(r);
2829                 return false;
2830         }
2831
2832         talloc_free(r);
2833
2834         return true;
2835 }
2836
2837 static bool api_netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(pipes_struct *p)
2838 {
2839         const struct ndr_interface_call *call;
2840         struct ndr_pull *pull;
2841         struct ndr_push *push;
2842         enum ndr_err_code ndr_err;
2843         DATA_BLOB blob;
2844         struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r;
2845
2846         call = &ndr_table_netlogon.calls[NDR_NETR_NETRLOGONGETTIMESERVICEPARENTDOMAIN];
2847
2848         r = talloc(talloc_tos(), struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN);
2849         if (r == NULL) {
2850                 return false;
2851         }
2852
2853         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
2854                 talloc_free(r);
2855                 return false;
2856         }
2857
2858         pull = ndr_pull_init_blob(&blob, r, NULL);
2859         if (pull == NULL) {
2860                 talloc_free(r);
2861                 return false;
2862         }
2863
2864         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
2865         ndr_err = call->ndr_pull(pull, NDR_IN, r);
2866         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2867                 talloc_free(r);
2868                 return false;
2869         }
2870
2871         if (DEBUGLEVEL >= 10) {
2872                 NDR_PRINT_IN_DEBUG(netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN, r);
2873         }
2874
2875         r->out.result = _netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(p, r);
2876
2877         if (p->rng_fault_state) {
2878                 talloc_free(r);
2879                 /* Return true here, srv_pipe_hnd.c will take care */
2880                 return true;
2881         }
2882
2883         if (DEBUGLEVEL >= 10) {
2884                 NDR_PRINT_OUT_DEBUG(netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN, r);
2885         }
2886
2887         push = ndr_push_init_ctx(r, NULL);
2888         if (push == NULL) {
2889                 talloc_free(r);
2890                 return false;
2891         }
2892
2893         ndr_err = call->ndr_push(push, NDR_OUT, r);
2894         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2895                 talloc_free(r);
2896                 return false;
2897         }
2898
2899         blob = ndr_push_blob(push);
2900         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2901                 talloc_free(r);
2902                 return false;
2903         }
2904
2905         talloc_free(r);
2906
2907         return true;
2908 }
2909
2910 static bool api_netr_NetrEnumerateTrustedDomainsEx(pipes_struct *p)
2911 {
2912         const struct ndr_interface_call *call;
2913         struct ndr_pull *pull;
2914         struct ndr_push *push;
2915         enum ndr_err_code ndr_err;
2916         DATA_BLOB blob;
2917         struct netr_NetrEnumerateTrustedDomainsEx *r;
2918
2919         call = &ndr_table_netlogon.calls[NDR_NETR_NETRENUMERATETRUSTEDDOMAINSEX];
2920
2921         r = talloc(talloc_tos(), struct netr_NetrEnumerateTrustedDomainsEx);
2922         if (r == NULL) {
2923                 return false;
2924         }
2925
2926         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
2927                 talloc_free(r);
2928                 return false;
2929         }
2930
2931         pull = ndr_pull_init_blob(&blob, r, NULL);
2932         if (pull == NULL) {
2933                 talloc_free(r);
2934                 return false;
2935         }
2936
2937         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
2938         ndr_err = call->ndr_pull(pull, NDR_IN, r);
2939         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2940                 talloc_free(r);
2941                 return false;
2942         }
2943
2944         if (DEBUGLEVEL >= 10) {
2945                 NDR_PRINT_IN_DEBUG(netr_NetrEnumerateTrustedDomainsEx, r);
2946         }
2947
2948         ZERO_STRUCT(r->out);
2949         r->out.dom_trust_list = talloc_zero(r, struct netr_DomainTrustList);
2950         if (r->out.dom_trust_list == NULL) {
2951                 talloc_free(r);
2952                 return false;
2953         }
2954
2955         r->out.result = _netr_NetrEnumerateTrustedDomainsEx(p, r);
2956
2957         if (p->rng_fault_state) {
2958                 talloc_free(r);
2959                 /* Return true here, srv_pipe_hnd.c will take care */
2960                 return true;
2961         }
2962
2963         if (DEBUGLEVEL >= 10) {
2964                 NDR_PRINT_OUT_DEBUG(netr_NetrEnumerateTrustedDomainsEx, r);
2965         }
2966
2967         push = ndr_push_init_ctx(r, NULL);
2968         if (push == NULL) {
2969                 talloc_free(r);
2970                 return false;
2971         }
2972
2973         ndr_err = call->ndr_push(push, NDR_OUT, r);
2974         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2975                 talloc_free(r);
2976                 return false;
2977         }
2978
2979         blob = ndr_push_blob(push);
2980         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
2981                 talloc_free(r);
2982                 return false;
2983         }
2984
2985         talloc_free(r);
2986
2987         return true;
2988 }
2989
2990 static bool api_netr_DsRAddressToSitenamesExW(pipes_struct *p)
2991 {
2992         const struct ndr_interface_call *call;
2993         struct ndr_pull *pull;
2994         struct ndr_push *push;
2995         enum ndr_err_code ndr_err;
2996         DATA_BLOB blob;
2997         struct netr_DsRAddressToSitenamesExW *r;
2998
2999         call = &ndr_table_netlogon.calls[NDR_NETR_DSRADDRESSTOSITENAMESEXW];
3000
3001         r = talloc(talloc_tos(), struct netr_DsRAddressToSitenamesExW);
3002         if (r == NULL) {
3003                 return false;
3004         }
3005
3006         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
3007                 talloc_free(r);
3008                 return false;
3009         }
3010
3011         pull = ndr_pull_init_blob(&blob, r, NULL);
3012         if (pull == NULL) {
3013                 talloc_free(r);
3014                 return false;
3015         }
3016
3017         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
3018         ndr_err = call->ndr_pull(pull, NDR_IN, r);
3019         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3020                 talloc_free(r);
3021                 return false;
3022         }
3023
3024         if (DEBUGLEVEL >= 10) {
3025                 NDR_PRINT_IN_DEBUG(netr_DsRAddressToSitenamesExW, r);
3026         }
3027
3028         ZERO_STRUCT(r->out);
3029         r->out.ctr = talloc_zero(r, struct netr_DsRAddressToSitenamesExWCtr *);
3030         if (r->out.ctr == NULL) {
3031                 talloc_free(r);
3032                 return false;
3033         }
3034
3035         r->out.result = _netr_DsRAddressToSitenamesExW(p, r);
3036
3037         if (p->rng_fault_state) {
3038                 talloc_free(r);
3039                 /* Return true here, srv_pipe_hnd.c will take care */
3040                 return true;
3041         }
3042
3043         if (DEBUGLEVEL >= 10) {
3044                 NDR_PRINT_OUT_DEBUG(netr_DsRAddressToSitenamesExW, r);
3045         }
3046
3047         push = ndr_push_init_ctx(r, NULL);
3048         if (push == NULL) {
3049                 talloc_free(r);
3050                 return false;
3051         }
3052
3053         ndr_err = call->ndr_push(push, NDR_OUT, r);
3054         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3055                 talloc_free(r);
3056                 return false;
3057         }
3058
3059         blob = ndr_push_blob(push);
3060         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
3061                 talloc_free(r);
3062                 return false;
3063         }
3064
3065         talloc_free(r);
3066
3067         return true;
3068 }
3069
3070 static bool api_netr_DsrGetDcSiteCoverageW(pipes_struct *p)
3071 {
3072         const struct ndr_interface_call *call;
3073         struct ndr_pull *pull;
3074         struct ndr_push *push;
3075         enum ndr_err_code ndr_err;
3076         DATA_BLOB blob;
3077         struct netr_DsrGetDcSiteCoverageW *r;
3078
3079         call = &ndr_table_netlogon.calls[NDR_NETR_DSRGETDCSITECOVERAGEW];
3080
3081         r = talloc(talloc_tos(), struct netr_DsrGetDcSiteCoverageW);
3082         if (r == NULL) {
3083                 return false;
3084         }
3085
3086         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
3087                 talloc_free(r);
3088                 return false;
3089         }
3090
3091         pull = ndr_pull_init_blob(&blob, r, NULL);
3092         if (pull == NULL) {
3093                 talloc_free(r);
3094                 return false;
3095         }
3096
3097         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
3098         ndr_err = call->ndr_pull(pull, NDR_IN, r);
3099         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3100                 talloc_free(r);
3101                 return false;
3102         }
3103
3104         if (DEBUGLEVEL >= 10) {
3105                 NDR_PRINT_IN_DEBUG(netr_DsrGetDcSiteCoverageW, r);
3106         }
3107
3108         ZERO_STRUCT(r->out);
3109         r->out.ctr = talloc_zero(r, struct DcSitesCtr *);
3110         if (r->out.ctr == NULL) {
3111                 talloc_free(r);
3112                 return false;
3113         }
3114
3115         r->out.result = _netr_DsrGetDcSiteCoverageW(p, r);
3116
3117         if (p->rng_fault_state) {
3118                 talloc_free(r);
3119                 /* Return true here, srv_pipe_hnd.c will take care */
3120                 return true;
3121         }
3122
3123         if (DEBUGLEVEL >= 10) {
3124                 NDR_PRINT_OUT_DEBUG(netr_DsrGetDcSiteCoverageW, r);
3125         }
3126
3127         push = ndr_push_init_ctx(r, NULL);
3128         if (push == NULL) {
3129                 talloc_free(r);
3130                 return false;
3131         }
3132
3133         ndr_err = call->ndr_push(push, NDR_OUT, r);
3134         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3135                 talloc_free(r);
3136                 return false;
3137         }
3138
3139         blob = ndr_push_blob(push);
3140         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
3141                 talloc_free(r);
3142                 return false;
3143         }
3144
3145         talloc_free(r);
3146
3147         return true;
3148 }
3149
3150 static bool api_netr_LogonSamLogonEx(pipes_struct *p)
3151 {
3152         const struct ndr_interface_call *call;
3153         struct ndr_pull *pull;
3154         struct ndr_push *push;
3155         enum ndr_err_code ndr_err;
3156         DATA_BLOB blob;
3157         struct netr_LogonSamLogonEx *r;
3158
3159         call = &ndr_table_netlogon.calls[NDR_NETR_LOGONSAMLOGONEX];
3160
3161         r = talloc(talloc_tos(), struct netr_LogonSamLogonEx);
3162         if (r == NULL) {
3163                 return false;
3164         }
3165
3166         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
3167                 talloc_free(r);
3168                 return false;
3169         }
3170
3171         pull = ndr_pull_init_blob(&blob, r, NULL);
3172         if (pull == NULL) {
3173                 talloc_free(r);
3174                 return false;
3175         }
3176
3177         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
3178         ndr_err = call->ndr_pull(pull, NDR_IN, r);
3179         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3180                 talloc_free(r);
3181                 return false;
3182         }
3183
3184         if (DEBUGLEVEL >= 10) {
3185                 NDR_PRINT_IN_DEBUG(netr_LogonSamLogonEx, r);
3186         }
3187
3188         ZERO_STRUCT(r->out);
3189         r->out.flags = r->in.flags;
3190         r->out.validation = talloc_zero(r, union netr_Validation);
3191         if (r->out.validation == NULL) {
3192                 talloc_free(r);
3193                 return false;
3194         }
3195
3196         r->out.authoritative = talloc_zero(r, uint8_t);
3197         if (r->out.authoritative == NULL) {
3198                 talloc_free(r);
3199                 return false;
3200         }
3201
3202         r->out.result = _netr_LogonSamLogonEx(p, r);
3203
3204         if (p->rng_fault_state) {
3205                 talloc_free(r);
3206                 /* Return true here, srv_pipe_hnd.c will take care */
3207                 return true;
3208         }
3209
3210         if (DEBUGLEVEL >= 10) {
3211                 NDR_PRINT_OUT_DEBUG(netr_LogonSamLogonEx, r);
3212         }
3213
3214         push = ndr_push_init_ctx(r, NULL);
3215         if (push == NULL) {
3216                 talloc_free(r);
3217                 return false;
3218         }
3219
3220         ndr_err = call->ndr_push(push, NDR_OUT, r);
3221         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3222                 talloc_free(r);
3223                 return false;
3224         }
3225
3226         blob = ndr_push_blob(push);
3227         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
3228                 talloc_free(r);
3229                 return false;
3230         }
3231
3232         talloc_free(r);
3233
3234         return true;
3235 }
3236
3237 static bool api_netr_DsrEnumerateDomainTrusts(pipes_struct *p)
3238 {
3239         const struct ndr_interface_call *call;
3240         struct ndr_pull *pull;
3241         struct ndr_push *push;
3242         enum ndr_err_code ndr_err;
3243         DATA_BLOB blob;
3244         struct netr_DsrEnumerateDomainTrusts *r;
3245
3246         call = &ndr_table_netlogon.calls[NDR_NETR_DSRENUMERATEDOMAINTRUSTS];
3247
3248         r = talloc(talloc_tos(), struct netr_DsrEnumerateDomainTrusts);
3249         if (r == NULL) {
3250                 return false;
3251         }
3252
3253         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
3254                 talloc_free(r);
3255                 return false;
3256         }
3257
3258         pull = ndr_pull_init_blob(&blob, r, NULL);
3259         if (pull == NULL) {
3260                 talloc_free(r);
3261                 return false;
3262         }
3263
3264         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
3265         ndr_err = call->ndr_pull(pull, NDR_IN, r);
3266         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3267                 talloc_free(r);
3268                 return false;
3269         }
3270
3271         if (DEBUGLEVEL >= 10) {
3272                 NDR_PRINT_IN_DEBUG(netr_DsrEnumerateDomainTrusts, r);
3273         }
3274
3275         ZERO_STRUCT(r->out);
3276         r->out.trusts = talloc_zero(r, struct netr_DomainTrustList);
3277         if (r->out.trusts == NULL) {
3278                 talloc_free(r);
3279                 return false;
3280         }
3281
3282         r->out.result = _netr_DsrEnumerateDomainTrusts(p, r);
3283
3284         if (p->rng_fault_state) {
3285                 talloc_free(r);
3286                 /* Return true here, srv_pipe_hnd.c will take care */
3287                 return true;
3288         }
3289
3290         if (DEBUGLEVEL >= 10) {
3291                 NDR_PRINT_OUT_DEBUG(netr_DsrEnumerateDomainTrusts, r);
3292         }
3293
3294         push = ndr_push_init_ctx(r, NULL);
3295         if (push == NULL) {
3296                 talloc_free(r);
3297                 return false;
3298         }
3299
3300         ndr_err = call->ndr_push(push, NDR_OUT, r);
3301         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3302                 talloc_free(r);
3303                 return false;
3304         }
3305
3306         blob = ndr_push_blob(push);
3307         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
3308                 talloc_free(r);
3309                 return false;
3310         }
3311
3312         talloc_free(r);
3313
3314         return true;
3315 }
3316
3317 static bool api_netr_DsrDeregisterDNSHostRecords(pipes_struct *p)
3318 {
3319         const struct ndr_interface_call *call;
3320         struct ndr_pull *pull;
3321         struct ndr_push *push;
3322         enum ndr_err_code ndr_err;
3323         DATA_BLOB blob;
3324         struct netr_DsrDeregisterDNSHostRecords *r;
3325
3326         call = &ndr_table_netlogon.calls[NDR_NETR_DSRDEREGISTERDNSHOSTRECORDS];
3327
3328         r = talloc(talloc_tos(), struct netr_DsrDeregisterDNSHostRecords);
3329         if (r == NULL) {
3330                 return false;
3331         }
3332
3333         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
3334                 talloc_free(r);
3335                 return false;
3336         }
3337
3338         pull = ndr_pull_init_blob(&blob, r, NULL);
3339         if (pull == NULL) {
3340                 talloc_free(r);
3341                 return false;
3342         }
3343
3344         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
3345         ndr_err = call->ndr_pull(pull, NDR_IN, r);
3346         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3347                 talloc_free(r);
3348                 return false;
3349         }
3350
3351         if (DEBUGLEVEL >= 10) {
3352                 NDR_PRINT_IN_DEBUG(netr_DsrDeregisterDNSHostRecords, r);
3353         }
3354
3355         r->out.result = _netr_DsrDeregisterDNSHostRecords(p, r);
3356
3357         if (p->rng_fault_state) {
3358                 talloc_free(r);
3359                 /* Return true here, srv_pipe_hnd.c will take care */
3360                 return true;
3361         }
3362
3363         if (DEBUGLEVEL >= 10) {
3364                 NDR_PRINT_OUT_DEBUG(netr_DsrDeregisterDNSHostRecords, r);
3365         }
3366
3367         push = ndr_push_init_ctx(r, NULL);
3368         if (push == NULL) {
3369                 talloc_free(r);
3370                 return false;
3371         }
3372
3373         ndr_err = call->ndr_push(push, NDR_OUT, r);
3374         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3375                 talloc_free(r);
3376                 return false;
3377         }
3378
3379         blob = ndr_push_blob(push);
3380         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
3381                 talloc_free(r);
3382                 return false;
3383         }
3384
3385         talloc_free(r);
3386
3387         return true;
3388 }
3389
3390 static bool api_netr_ServerTrustPasswordsGet(pipes_struct *p)
3391 {
3392         const struct ndr_interface_call *call;
3393         struct ndr_pull *pull;
3394         struct ndr_push *push;
3395         enum ndr_err_code ndr_err;
3396         DATA_BLOB blob;
3397         struct netr_ServerTrustPasswordsGet *r;
3398
3399         call = &ndr_table_netlogon.calls[NDR_NETR_SERVERTRUSTPASSWORDSGET];
3400
3401         r = talloc(talloc_tos(), struct netr_ServerTrustPasswordsGet);
3402         if (r == NULL) {
3403                 return false;
3404         }
3405
3406         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
3407                 talloc_free(r);
3408                 return false;
3409         }
3410
3411         pull = ndr_pull_init_blob(&blob, r, NULL);
3412         if (pull == NULL) {
3413                 talloc_free(r);
3414                 return false;
3415         }
3416
3417         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
3418         ndr_err = call->ndr_pull(pull, NDR_IN, r);
3419         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3420                 talloc_free(r);
3421                 return false;
3422         }
3423
3424         if (DEBUGLEVEL >= 10) {
3425                 NDR_PRINT_IN_DEBUG(netr_ServerTrustPasswordsGet, r);
3426         }
3427
3428         ZERO_STRUCT(r->out);
3429         r->out.return_authenticator = talloc_zero(r, struct netr_Authenticator);
3430         if (r->out.return_authenticator == NULL) {
3431                 talloc_free(r);
3432                 return false;
3433         }
3434
3435         r->out.password = talloc_zero(r, struct samr_Password);
3436         if (r->out.password == NULL) {
3437                 talloc_free(r);
3438                 return false;
3439         }
3440
3441         r->out.password2 = talloc_zero(r, struct samr_Password);
3442         if (r->out.password2 == NULL) {
3443                 talloc_free(r);
3444                 return false;
3445         }
3446
3447         r->out.result = _netr_ServerTrustPasswordsGet(p, r);
3448
3449         if (p->rng_fault_state) {
3450                 talloc_free(r);
3451                 /* Return true here, srv_pipe_hnd.c will take care */
3452                 return true;
3453         }
3454
3455         if (DEBUGLEVEL >= 10) {
3456                 NDR_PRINT_OUT_DEBUG(netr_ServerTrustPasswordsGet, r);
3457         }
3458
3459         push = ndr_push_init_ctx(r, NULL);
3460         if (push == NULL) {
3461                 talloc_free(r);
3462                 return false;
3463         }
3464
3465         ndr_err = call->ndr_push(push, NDR_OUT, r);
3466         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3467                 talloc_free(r);
3468                 return false;
3469         }
3470
3471         blob = ndr_push_blob(push);
3472         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
3473                 talloc_free(r);
3474                 return false;
3475         }
3476
3477         talloc_free(r);
3478
3479         return true;
3480 }
3481
3482 static bool api_netr_DsRGetForestTrustInformation(pipes_struct *p)
3483 {
3484         const struct ndr_interface_call *call;
3485         struct ndr_pull *pull;
3486         struct ndr_push *push;
3487         enum ndr_err_code ndr_err;
3488         DATA_BLOB blob;
3489         struct netr_DsRGetForestTrustInformation *r;
3490
3491         call = &ndr_table_netlogon.calls[NDR_NETR_DSRGETFORESTTRUSTINFORMATION];
3492
3493         r = talloc(talloc_tos(), struct netr_DsRGetForestTrustInformation);
3494         if (r == NULL) {
3495                 return false;
3496         }
3497
3498         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
3499                 talloc_free(r);
3500                 return false;
3501         }
3502
3503         pull = ndr_pull_init_blob(&blob, r, NULL);
3504         if (pull == NULL) {
3505                 talloc_free(r);
3506                 return false;
3507         }
3508
3509         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
3510         ndr_err = call->ndr_pull(pull, NDR_IN, r);
3511         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3512                 talloc_free(r);
3513                 return false;
3514         }
3515
3516         if (DEBUGLEVEL >= 10) {
3517                 NDR_PRINT_IN_DEBUG(netr_DsRGetForestTrustInformation, r);
3518         }
3519
3520         ZERO_STRUCT(r->out);
3521         r->out.forest_trust_info = talloc_zero(r, struct lsa_ForestTrustInformation *);
3522         if (r->out.forest_trust_info == NULL) {
3523                 talloc_free(r);
3524                 return false;
3525         }
3526
3527         r->out.result = _netr_DsRGetForestTrustInformation(p, r);
3528
3529         if (p->rng_fault_state) {
3530                 talloc_free(r);
3531                 /* Return true here, srv_pipe_hnd.c will take care */
3532                 return true;
3533         }
3534
3535         if (DEBUGLEVEL >= 10) {
3536                 NDR_PRINT_OUT_DEBUG(netr_DsRGetForestTrustInformation, r);
3537         }
3538
3539         push = ndr_push_init_ctx(r, NULL);
3540         if (push == NULL) {
3541                 talloc_free(r);
3542                 return false;
3543         }
3544
3545         ndr_err = call->ndr_push(push, NDR_OUT, r);
3546         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3547                 talloc_free(r);
3548                 return false;
3549         }
3550
3551         blob = ndr_push_blob(push);
3552         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
3553                 talloc_free(r);
3554                 return false;
3555         }
3556
3557         talloc_free(r);
3558
3559         return true;
3560 }
3561
3562 static bool api_netr_GetForestTrustInformation(pipes_struct *p)
3563 {
3564         const struct ndr_interface_call *call;
3565         struct ndr_pull *pull;
3566         struct ndr_push *push;
3567         enum ndr_err_code ndr_err;
3568         DATA_BLOB blob;
3569         struct netr_GetForestTrustInformation *r;
3570
3571         call = &ndr_table_netlogon.calls[NDR_NETR_GETFORESTTRUSTINFORMATION];
3572
3573         r = talloc(talloc_tos(), struct netr_GetForestTrustInformation);
3574         if (r == NULL) {
3575                 return false;
3576         }
3577
3578         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
3579                 talloc_free(r);
3580                 return false;
3581         }
3582
3583         pull = ndr_pull_init_blob(&blob, r, NULL);
3584         if (pull == NULL) {
3585                 talloc_free(r);
3586                 return false;
3587         }
3588
3589         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
3590         ndr_err = call->ndr_pull(pull, NDR_IN, r);
3591         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3592                 talloc_free(r);
3593                 return false;
3594         }
3595
3596         if (DEBUGLEVEL >= 10) {
3597                 NDR_PRINT_IN_DEBUG(netr_GetForestTrustInformation, r);
3598         }
3599
3600         ZERO_STRUCT(r->out);
3601         r->out.return_authenticator = talloc_zero(r, struct netr_Authenticator);
3602         if (r->out.return_authenticator == NULL) {
3603                 talloc_free(r);
3604                 return false;
3605         }
3606
3607         r->out.forest_trust_info = talloc_zero(r, struct lsa_ForestTrustInformation *);
3608         if (r->out.forest_trust_info == NULL) {
3609                 talloc_free(r);
3610                 return false;
3611         }
3612
3613         r->out.result = _netr_GetForestTrustInformation(p, r);
3614
3615         if (p->rng_fault_state) {
3616                 talloc_free(r);
3617                 /* Return true here, srv_pipe_hnd.c will take care */
3618                 return true;
3619         }
3620
3621         if (DEBUGLEVEL >= 10) {
3622                 NDR_PRINT_OUT_DEBUG(netr_GetForestTrustInformation, r);
3623         }
3624
3625         push = ndr_push_init_ctx(r, NULL);
3626         if (push == NULL) {
3627                 talloc_free(r);
3628                 return false;
3629         }
3630
3631         ndr_err = call->ndr_push(push, NDR_OUT, r);
3632         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3633                 talloc_free(r);
3634                 return false;
3635         }
3636
3637         blob = ndr_push_blob(push);
3638         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
3639                 talloc_free(r);
3640                 return false;
3641         }
3642
3643         talloc_free(r);
3644
3645         return true;
3646 }
3647
3648 static bool api_netr_LogonSamLogonWithFlags(pipes_struct *p)
3649 {
3650         const struct ndr_interface_call *call;
3651         struct ndr_pull *pull;
3652         struct ndr_push *push;
3653         enum ndr_err_code ndr_err;
3654         DATA_BLOB blob;
3655         struct netr_LogonSamLogonWithFlags *r;
3656
3657         call = &ndr_table_netlogon.calls[NDR_NETR_LOGONSAMLOGONWITHFLAGS];
3658
3659         r = talloc(talloc_tos(), struct netr_LogonSamLogonWithFlags);
3660         if (r == NULL) {
3661                 return false;
3662         }
3663
3664         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
3665                 talloc_free(r);
3666                 return false;
3667         }
3668
3669         pull = ndr_pull_init_blob(&blob, r, NULL);
3670         if (pull == NULL) {
3671                 talloc_free(r);
3672                 return false;
3673         }
3674
3675         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
3676         ndr_err = call->ndr_pull(pull, NDR_IN, r);
3677         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3678                 talloc_free(r);
3679                 return false;
3680         }
3681
3682         if (DEBUGLEVEL >= 10) {
3683                 NDR_PRINT_IN_DEBUG(netr_LogonSamLogonWithFlags, r);
3684         }
3685
3686         ZERO_STRUCT(r->out);
3687         r->out.return_authenticator = r->in.return_authenticator;
3688         r->out.flags = r->in.flags;
3689         r->out.validation = talloc_zero(r, union netr_Validation);
3690         if (r->out.validation == NULL) {
3691                 talloc_free(r);
3692                 return false;
3693         }
3694
3695         r->out.authoritative = talloc_zero(r, uint8_t);
3696         if (r->out.authoritative == NULL) {
3697                 talloc_free(r);
3698                 return false;
3699         }
3700
3701         r->out.result = _netr_LogonSamLogonWithFlags(p, r);
3702
3703         if (p->rng_fault_state) {
3704                 talloc_free(r);
3705                 /* Return true here, srv_pipe_hnd.c will take care */
3706                 return true;
3707         }
3708
3709         if (DEBUGLEVEL >= 10) {
3710                 NDR_PRINT_OUT_DEBUG(netr_LogonSamLogonWithFlags, r);
3711         }
3712
3713         push = ndr_push_init_ctx(r, NULL);
3714         if (push == NULL) {
3715                 talloc_free(r);
3716                 return false;
3717         }
3718
3719         ndr_err = call->ndr_push(push, NDR_OUT, r);
3720         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3721                 talloc_free(r);
3722                 return false;
3723         }
3724
3725         blob = ndr_push_blob(push);
3726         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
3727                 talloc_free(r);
3728                 return false;
3729         }
3730
3731         talloc_free(r);
3732
3733         return true;
3734 }
3735
3736 static bool api_netr_ServerGetTrustInfo(pipes_struct *p)
3737 {
3738         const struct ndr_interface_call *call;
3739         struct ndr_pull *pull;
3740         struct ndr_push *push;
3741         enum ndr_err_code ndr_err;
3742         DATA_BLOB blob;
3743         struct netr_ServerGetTrustInfo *r;
3744
3745         call = &ndr_table_netlogon.calls[NDR_NETR_SERVERGETTRUSTINFO];
3746
3747         r = talloc(talloc_tos(), struct netr_ServerGetTrustInfo);
3748         if (r == NULL) {
3749                 return false;
3750         }
3751
3752         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
3753                 talloc_free(r);
3754                 return false;
3755         }
3756
3757         pull = ndr_pull_init_blob(&blob, r, NULL);
3758         if (pull == NULL) {
3759                 talloc_free(r);
3760                 return false;
3761         }
3762
3763         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
3764         ndr_err = call->ndr_pull(pull, NDR_IN, r);
3765         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3766                 talloc_free(r);
3767                 return false;
3768         }
3769
3770         if (DEBUGLEVEL >= 10) {
3771                 NDR_PRINT_IN_DEBUG(netr_ServerGetTrustInfo, r);
3772         }
3773
3774         ZERO_STRUCT(r->out);
3775         r->out.return_authenticator = talloc_zero(r, struct netr_Authenticator);
3776         if (r->out.return_authenticator == NULL) {
3777                 talloc_free(r);
3778                 return false;
3779         }
3780
3781         r->out.new_owf_password = talloc_zero(r, struct samr_Password);
3782         if (r->out.new_owf_password == NULL) {
3783                 talloc_free(r);
3784                 return false;
3785         }
3786
3787         r->out.old_owf_password = talloc_zero(r, struct samr_Password);
3788         if (r->out.old_owf_password == NULL) {
3789                 talloc_free(r);
3790                 return false;
3791         }
3792
3793         r->out.trust_info = talloc_zero(r, struct netr_TrustInfo *);
3794         if (r->out.trust_info == NULL) {
3795                 talloc_free(r);
3796                 return false;
3797         }
3798
3799         r->out.result = _netr_ServerGetTrustInfo(p, r);
3800
3801         if (p->rng_fault_state) {
3802                 talloc_free(r);
3803                 /* Return true here, srv_pipe_hnd.c will take care */
3804                 return true;
3805         }
3806
3807         if (DEBUGLEVEL >= 10) {
3808                 NDR_PRINT_OUT_DEBUG(netr_ServerGetTrustInfo, r);
3809         }
3810
3811         push = ndr_push_init_ctx(r, NULL);
3812         if (push == NULL) {
3813                 talloc_free(r);
3814                 return false;
3815         }
3816
3817         ndr_err = call->ndr_push(push, NDR_OUT, r);
3818         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
3819                 talloc_free(r);
3820                 return false;
3821         }
3822
3823         blob = ndr_push_blob(push);
3824         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
3825                 talloc_free(r);
3826                 return false;
3827         }
3828
3829         talloc_free(r);
3830
3831         return true;
3832 }
3833
3834
3835 /* Tables */
3836 static struct api_struct api_netlogon_cmds[] = 
3837 {
3838         {"NETR_LOGONUASLOGON", NDR_NETR_LOGONUASLOGON, api_netr_LogonUasLogon},
3839         {"NETR_LOGONUASLOGOFF", NDR_NETR_LOGONUASLOGOFF, api_netr_LogonUasLogoff},
3840         {"NETR_LOGONSAMLOGON", NDR_NETR_LOGONSAMLOGON, api_netr_LogonSamLogon},
3841         {"NETR_LOGONSAMLOGOFF", NDR_NETR_LOGONSAMLOGOFF, api_netr_LogonSamLogoff},
3842         {"NETR_SERVERREQCHALLENGE", NDR_NETR_SERVERREQCHALLENGE, api_netr_ServerReqChallenge},
3843         {"NETR_SERVERAUTHENTICATE", NDR_NETR_SERVERAUTHENTICATE, api_netr_ServerAuthenticate},
3844         {"NETR_SERVERPASSWORDSET", NDR_NETR_SERVERPASSWORDSET, api_netr_ServerPasswordSet},
3845         {"NETR_DATABASEDELTAS", NDR_NETR_DATABASEDELTAS, api_netr_DatabaseDeltas},
3846         {"NETR_DATABASESYNC", NDR_NETR_DATABASESYNC, api_netr_DatabaseSync},
3847         {"NETR_ACCOUNTDELTAS", NDR_NETR_ACCOUNTDELTAS, api_netr_AccountDeltas},
3848         {"NETR_ACCOUNTSYNC", NDR_NETR_ACCOUNTSYNC, api_netr_AccountSync},
3849         {"NETR_GETDCNAME", NDR_NETR_GETDCNAME, api_netr_GetDcName},
3850         {"NETR_LOGONCONTROL", NDR_NETR_LOGONCONTROL, api_netr_LogonControl},
3851         {"NETR_GETANYDCNAME", NDR_NETR_GETANYDCNAME, api_netr_GetAnyDCName},
3852         {"NETR_LOGONCONTROL2", NDR_NETR_LOGONCONTROL2, api_netr_LogonControl2},
3853         {"NETR_SERVERAUTHENTICATE2", NDR_NETR_SERVERAUTHENTICATE2, api_netr_ServerAuthenticate2},
3854         {"NETR_DATABASESYNC2", NDR_NETR_DATABASESYNC2, api_netr_DatabaseSync2},
3855         {"NETR_DATABASEREDO", NDR_NETR_DATABASEREDO, api_netr_DatabaseRedo},
3856         {"NETR_LOGONCONTROL2EX", NDR_NETR_LOGONCONTROL2EX, api_netr_LogonControl2Ex},
3857         {"NETR_NETRENUMERATETRUSTEDDOMAINS", NDR_NETR_NETRENUMERATETRUSTEDDOMAINS, api_netr_NetrEnumerateTrustedDomains},
3858         {"NETR_DSRGETDCNAME", NDR_NETR_DSRGETDCNAME, api_netr_DsRGetDCName},
3859         {"NETR_NETRLOGONDUMMYROUTINE1", NDR_NETR_NETRLOGONDUMMYROUTINE1, api_netr_NETRLOGONDUMMYROUTINE1},
3860         {"NETR_NETRLOGONSETSERVICEBITS", NDR_NETR_NETRLOGONSETSERVICEBITS, api_netr_NETRLOGONSETSERVICEBITS},
3861         {"NETR_LOGONGETTRUSTRID", NDR_NETR_LOGONGETTRUSTRID, api_netr_LogonGetTrustRid},
3862         {"NETR_NETRLOGONCOMPUTESERVERDIGEST", NDR_NETR_NETRLOGONCOMPUTESERVERDIGEST, api_netr_NETRLOGONCOMPUTESERVERDIGEST},
3863         {"NETR_NETRLOGONCOMPUTECLIENTDIGEST", NDR_NETR_NETRLOGONCOMPUTECLIENTDIGEST, api_netr_NETRLOGONCOMPUTECLIENTDIGEST},
3864         {"NETR_SERVERAUTHENTICATE3", NDR_NETR_SERVERAUTHENTICATE3, api_netr_ServerAuthenticate3},
3865         {"NETR_DSRGETDCNAMEEX", NDR_NETR_DSRGETDCNAMEEX, api_netr_DsRGetDCNameEx},
3866         {"NETR_DSRGETSITENAME", NDR_NETR_DSRGETSITENAME, api_netr_DsRGetSiteName},
3867         {"NETR_LOGONGETDOMAININFO", NDR_NETR_LOGONGETDOMAININFO, api_netr_LogonGetDomainInfo},
3868         {"NETR_SERVERPASSWORDSET2", NDR_NETR_SERVERPASSWORDSET2, api_netr_ServerPasswordSet2},
3869         {"NETR_SERVERPASSWORDGET", NDR_NETR_SERVERPASSWORDGET, api_netr_ServerPasswordGet},
3870         {"NETR_NETRLOGONSENDTOSAM", NDR_NETR_NETRLOGONSENDTOSAM, api_netr_NETRLOGONSENDTOSAM},
3871         {"NETR_DSRADDRESSTOSITENAMESW", NDR_NETR_DSRADDRESSTOSITENAMESW, api_netr_DsRAddressToSitenamesW},
3872         {"NETR_DSRGETDCNAMEEX2", NDR_NETR_DSRGETDCNAMEEX2, api_netr_DsRGetDCNameEx2},
3873         {"NETR_NETRLOGONGETTIMESERVICEPARENTDOMAIN", NDR_NETR_NETRLOGONGETTIMESERVICEPARENTDOMAIN, api_netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN},
3874         {"NETR_NETRENUMERATETRUSTEDDOMAINSEX", NDR_NETR_NETRENUMERATETRUSTEDDOMAINSEX, api_netr_NetrEnumerateTrustedDomainsEx},
3875         {"NETR_DSRADDRESSTOSITENAMESEXW", NDR_NETR_DSRADDRESSTOSITENAMESEXW, api_netr_DsRAddressToSitenamesExW},
3876         {"NETR_DSRGETDCSITECOVERAGEW", NDR_NETR_DSRGETDCSITECOVERAGEW, api_netr_DsrGetDcSiteCoverageW},
3877         {"NETR_LOGONSAMLOGONEX", NDR_NETR_LOGONSAMLOGONEX, api_netr_LogonSamLogonEx},
3878         {"NETR_DSRENUMERATEDOMAINTRUSTS", NDR_NETR_DSRENUMERATEDOMAINTRUSTS, api_netr_DsrEnumerateDomainTrusts},
3879         {"NETR_DSRDEREGISTERDNSHOSTRECORDS", NDR_NETR_DSRDEREGISTERDNSHOSTRECORDS, api_netr_DsrDeregisterDNSHostRecords},
3880         {"NETR_SERVERTRUSTPASSWORDSGET", NDR_NETR_SERVERTRUSTPASSWORDSGET, api_netr_ServerTrustPasswordsGet},
3881         {"NETR_DSRGETFORESTTRUSTINFORMATION", NDR_NETR_DSRGETFORESTTRUSTINFORMATION, api_netr_DsRGetForestTrustInformation},
3882         {"NETR_GETFORESTTRUSTINFORMATION", NDR_NETR_GETFORESTTRUSTINFORMATION, api_netr_GetForestTrustInformation},
3883         {"NETR_LOGONSAMLOGONWITHFLAGS", NDR_NETR_LOGONSAMLOGONWITHFLAGS, api_netr_LogonSamLogonWithFlags},
3884         {"NETR_SERVERGETTRUSTINFO", NDR_NETR_SERVERGETTRUSTINFO, api_netr_ServerGetTrustInfo},
3885 };
3886
3887 void netlogon_get_pipe_fns(struct api_struct **fns, int *n_fns)
3888 {
3889         *fns = api_netlogon_cmds;
3890         *n_fns = sizeof(api_netlogon_cmds) / sizeof(struct api_struct);
3891 }
3892
3893 NTSTATUS rpc_netlogon_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *_r)
3894 {
3895         if (cli->pipes_struct == NULL) {
3896                 return NT_STATUS_INVALID_PARAMETER;
3897         }
3898
3899         switch (opnum)
3900         {
3901                 case NDR_NETR_LOGONUASLOGON: {
3902                         struct netr_LogonUasLogon *r = (struct netr_LogonUasLogon *)_r;
3903                         ZERO_STRUCT(r->out);
3904                         r->out.info = talloc_zero(mem_ctx, struct netr_UasInfo *);
3905                         if (r->out.info == NULL) {
3906                         return NT_STATUS_NO_MEMORY;
3907                         }
3908
3909                         r->out.result = _netr_LogonUasLogon(cli->pipes_struct, r);
3910                         return NT_STATUS_OK;
3911                 }
3912
3913                 case NDR_NETR_LOGONUASLOGOFF: {
3914                         struct netr_LogonUasLogoff *r = (struct netr_LogonUasLogoff *)_r;
3915                         ZERO_STRUCT(r->out);
3916                         r->out.info = talloc_zero(mem_ctx, struct netr_UasLogoffInfo);
3917                         if (r->out.info == NULL) {
3918                         return NT_STATUS_NO_MEMORY;
3919                         }
3920
3921                         r->out.result = _netr_LogonUasLogoff(cli->pipes_struct, r);
3922                         return NT_STATUS_OK;
3923                 }
3924
3925                 case NDR_NETR_LOGONSAMLOGON: {
3926                         struct netr_LogonSamLogon *r = (struct netr_LogonSamLogon *)_r;
3927                         ZERO_STRUCT(r->out);
3928                         r->out.return_authenticator = r->in.return_authenticator;
3929                         r->out.validation = talloc_zero(mem_ctx, union netr_Validation);
3930                         if (r->out.validation == NULL) {
3931                         return NT_STATUS_NO_MEMORY;
3932                         }
3933
3934                         r->out.authoritative = talloc_zero(mem_ctx, uint8_t);
3935                         if (r->out.authoritative == NULL) {
3936                         return NT_STATUS_NO_MEMORY;
3937                         }
3938
3939                         r->out.result = _netr_LogonSamLogon(cli->pipes_struct, r);
3940                         return NT_STATUS_OK;
3941                 }
3942
3943                 case NDR_NETR_LOGONSAMLOGOFF: {
3944                         struct netr_LogonSamLogoff *r = (struct netr_LogonSamLogoff *)_r;
3945                         ZERO_STRUCT(r->out);
3946                         r->out.return_authenticator = r->in.return_authenticator;
3947                         r->out.result = _netr_LogonSamLogoff(cli->pipes_struct, r);
3948                         return NT_STATUS_OK;
3949                 }
3950
3951                 case NDR_NETR_SERVERREQCHALLENGE: {
3952                         struct netr_ServerReqChallenge *r = (struct netr_ServerReqChallenge *)_r;
3953                         ZERO_STRUCT(r->out);
3954                         r->out.return_credentials = talloc_zero(mem_ctx, struct netr_Credential);
3955                         if (r->out.return_credentials == NULL) {
3956                         return NT_STATUS_NO_MEMORY;
3957                         }
3958
3959                         r->out.result = _netr_ServerReqChallenge(cli->pipes_struct, r);
3960                         return NT_STATUS_OK;
3961                 }
3962
3963                 case NDR_NETR_SERVERAUTHENTICATE: {
3964                         struct netr_ServerAuthenticate *r = (struct netr_ServerAuthenticate *)_r;
3965                         ZERO_STRUCT(r->out);
3966                         r->out.return_credentials = talloc_zero(mem_ctx, struct netr_Credential);
3967                         if (r->out.return_credentials == NULL) {
3968                         return NT_STATUS_NO_MEMORY;
3969                         }
3970
3971                         r->out.result = _netr_ServerAuthenticate(cli->pipes_struct, r);
3972                         return NT_STATUS_OK;
3973                 }
3974
3975                 case NDR_NETR_SERVERPASSWORDSET: {
3976                         struct netr_ServerPasswordSet *r = (struct netr_ServerPasswordSet *)_r;
3977                         ZERO_STRUCT(r->out);
3978                         r->out.return_authenticator = talloc_zero(mem_ctx, struct netr_Authenticator);
3979                         if (r->out.return_authenticator == NULL) {
3980                         return NT_STATUS_NO_MEMORY;
3981                         }
3982
3983                         r->out.result = _netr_ServerPasswordSet(cli->pipes_struct, r);
3984                         return NT_STATUS_OK;
3985                 }
3986
3987                 case NDR_NETR_DATABASEDELTAS: {
3988                         struct netr_DatabaseDeltas *r = (struct netr_DatabaseDeltas *)_r;
3989                         ZERO_STRUCT(r->out);
3990                         r->out.return_authenticator = r->in.return_authenticator;
3991                         r->out.sequence_num = r->in.sequence_num;
3992                         r->out.delta_enum_array = talloc_zero(mem_ctx, struct netr_DELTA_ENUM_ARRAY *);
3993                         if (r->out.delta_enum_array == NULL) {
3994                         return NT_STATUS_NO_MEMORY;
3995                         }
3996
3997                         r->out.result = _netr_DatabaseDeltas(cli->pipes_struct, r);
3998                         return NT_STATUS_OK;
3999                 }
4000
4001                 case NDR_NETR_DATABASESYNC: {
4002                         struct netr_DatabaseSync *r = (struct netr_DatabaseSync *)_r;
4003                         ZERO_STRUCT(r->out);
4004                         r->out.return_authenticator = r->in.return_authenticator;
4005                         r->out.sync_context = r->in.sync_context;
4006                         r->out.delta_enum_array = talloc_zero(mem_ctx, struct netr_DELTA_ENUM_ARRAY *);
4007                         if (r->out.delta_enum_array == NULL) {
4008                         return NT_STATUS_NO_MEMORY;
4009                         }
4010
4011                         r->out.result = _netr_DatabaseSync(cli->pipes_struct, r);
4012                         return NT_STATUS_OK;
4013                 }
4014
4015                 case NDR_NETR_ACCOUNTDELTAS: {
4016                         struct netr_AccountDeltas *r = (struct netr_AccountDeltas *)_r;
4017                         ZERO_STRUCT(r->out);
4018                         r->out.return_authenticator = r->in.return_authenticator;
4019                         r->out.buffer = talloc_zero(mem_ctx, struct netr_AccountBuffer);
4020                         if (r->out.buffer == NULL) {
4021                         return NT_STATUS_NO_MEMORY;
4022                         }
4023
4024                         r->out.count_returned = talloc_zero(mem_ctx, uint32_t);
4025                         if (r->out.count_returned == NULL) {
4026                         return NT_STATUS_NO_MEMORY;
4027                         }
4028
4029                         r->out.total_entries = talloc_zero(mem_ctx, uint32_t);
4030                         if (r->out.total_entries == NULL) {
4031                         return NT_STATUS_NO_MEMORY;
4032                         }
4033
4034                         r->out.recordid = talloc_zero(mem_ctx, struct netr_UAS_INFO_0);
4035                         if (r->out.recordid == NULL) {
4036                         return NT_STATUS_NO_MEMORY;
4037                         }
4038
4039                         r->out.result = _netr_AccountDeltas(cli->pipes_struct, r);
4040                         return NT_STATUS_OK;
4041                 }
4042
4043                 case NDR_NETR_ACCOUNTSYNC: {
4044                         struct netr_AccountSync *r = (struct netr_AccountSync *)_r;
4045                         ZERO_STRUCT(r->out);
4046                         r->out.return_authenticator = r->in.return_authenticator;
4047                         r->out.recordid = r->in.recordid;
4048                         r->out.buffer = talloc_zero(mem_ctx, struct netr_AccountBuffer);
4049                         if (r->out.buffer == NULL) {
4050                         return NT_STATUS_NO_MEMORY;
4051                         }
4052
4053                         r->out.count_returned = talloc_zero(mem_ctx, uint32_t);
4054                         if (r->out.count_returned == NULL) {
4055                         return NT_STATUS_NO_MEMORY;
4056                         }
4057
4058                         r->out.total_entries = talloc_zero(mem_ctx, uint32_t);
4059                         if (r->out.total_entries == NULL) {
4060                         return NT_STATUS_NO_MEMORY;
4061                         }
4062
4063                         r->out.next_reference = talloc_zero(mem_ctx, uint32_t);
4064                         if (r->out.next_reference == NULL) {
4065                         return NT_STATUS_NO_MEMORY;
4066                         }
4067
4068                         r->out.result = _netr_AccountSync(cli->pipes_struct, r);
4069                         return NT_STATUS_OK;
4070                 }
4071
4072                 case NDR_NETR_GETDCNAME: {
4073                         struct netr_GetDcName *r = (struct netr_GetDcName *)_r;
4074                         ZERO_STRUCT(r->out);
4075                         r->out.dcname = talloc_zero(mem_ctx, const char *);
4076                         if (r->out.dcname == NULL) {
4077                         return NT_STATUS_NO_MEMORY;
4078                         }
4079
4080                         r->out.result = _netr_GetDcName(cli->pipes_struct, r);
4081                         return NT_STATUS_OK;
4082                 }
4083
4084                 case NDR_NETR_LOGONCONTROL: {
4085                         struct netr_LogonControl *r = (struct netr_LogonControl *)_r;
4086                         ZERO_STRUCT(r->out);
4087                         r->out.info = talloc_zero(mem_ctx, union netr_CONTROL_QUERY_INFORMATION);
4088                         if (r->out.info == NULL) {
4089                         return NT_STATUS_NO_MEMORY;
4090                         }
4091
4092                         r->out.result = _netr_LogonControl(cli->pipes_struct, r);
4093                         return NT_STATUS_OK;
4094                 }
4095
4096                 case NDR_NETR_GETANYDCNAME: {
4097                         struct netr_GetAnyDCName *r = (struct netr_GetAnyDCName *)_r;
4098                         ZERO_STRUCT(r->out);
4099                         r->out.dcname = talloc_zero(mem_ctx, const char *);
4100                         if (r->out.dcname == NULL) {
4101                         return NT_STATUS_NO_MEMORY;
4102                         }
4103
4104                         r->out.result = _netr_GetAnyDCName(cli->pipes_struct, r);
4105                         return NT_STATUS_OK;
4106                 }
4107
4108                 case NDR_NETR_LOGONCONTROL2: {
4109                         struct netr_LogonControl2 *r = (struct netr_LogonControl2 *)_r;
4110                         ZERO_STRUCT(r->out);
4111                         r->out.query = talloc_zero(mem_ctx, union netr_CONTROL_QUERY_INFORMATION);
4112                         if (r->out.query == NULL) {
4113                         return NT_STATUS_NO_MEMORY;
4114                         }
4115
4116                         r->out.result = _netr_LogonControl2(cli->pipes_struct, r);
4117                         return NT_STATUS_OK;
4118                 }
4119
4120                 case NDR_NETR_SERVERAUTHENTICATE2: {
4121                         struct netr_ServerAuthenticate2 *r = (struct netr_ServerAuthenticate2 *)_r;
4122                         ZERO_STRUCT(r->out);
4123                         r->out.negotiate_flags = r->in.negotiate_flags;
4124                         r->out.return_credentials = talloc_zero(mem_ctx, struct netr_Credential);
4125                         if (r->out.return_credentials == NULL) {
4126                         return NT_STATUS_NO_MEMORY;
4127                         }
4128
4129                         r->out.result = _netr_ServerAuthenticate2(cli->pipes_struct, r);
4130                         return NT_STATUS_OK;
4131                 }
4132
4133                 case NDR_NETR_DATABASESYNC2: {
4134                         struct netr_DatabaseSync2 *r = (struct netr_DatabaseSync2 *)_r;
4135                         ZERO_STRUCT(r->out);
4136                         r->out.return_authenticator = r->in.return_authenticator;
4137                         r->out.sync_context = r->in.sync_context;
4138                         r->out.delta_enum_array = talloc_zero(mem_ctx, struct netr_DELTA_ENUM_ARRAY *);
4139                         if (r->out.delta_enum_array == NULL) {
4140                         return NT_STATUS_NO_MEMORY;
4141                         }
4142
4143                         r->out.result = _netr_DatabaseSync2(cli->pipes_struct, r);
4144                         return NT_STATUS_OK;
4145                 }
4146
4147                 case NDR_NETR_DATABASEREDO: {
4148                         struct netr_DatabaseRedo *r = (struct netr_DatabaseRedo *)_r;
4149                         ZERO_STRUCT(r->out);
4150                         r->out.return_authenticator = r->in.return_authenticator;
4151                         r->out.delta_enum_array = talloc_zero(mem_ctx, struct netr_DELTA_ENUM_ARRAY *);
4152                         if (r->out.delta_enum_array == NULL) {
4153                         return NT_STATUS_NO_MEMORY;
4154                         }
4155
4156                         r->out.result = _netr_DatabaseRedo(cli->pipes_struct, r);
4157                         return NT_STATUS_OK;
4158                 }
4159
4160                 case NDR_NETR_LOGONCONTROL2EX: {
4161                         struct netr_LogonControl2Ex *r = (struct netr_LogonControl2Ex *)_r;
4162                         ZERO_STRUCT(r->out);
4163                         r->out.query = talloc_zero(mem_ctx, union netr_CONTROL_QUERY_INFORMATION);
4164                         if (r->out.query == NULL) {
4165                         return NT_STATUS_NO_MEMORY;
4166                         }
4167
4168                         r->out.result = _netr_LogonControl2Ex(cli->pipes_struct, r);
4169                         return NT_STATUS_OK;
4170                 }
4171
4172                 case NDR_NETR_NETRENUMERATETRUSTEDDOMAINS: {
4173                         struct netr_NetrEnumerateTrustedDomains *r = (struct netr_NetrEnumerateTrustedDomains *)_r;
4174                         ZERO_STRUCT(r->out);
4175                         r->out.trusted_domains_blob = talloc_zero(mem_ctx, struct netr_Blob);
4176                         if (r->out.trusted_domains_blob == NULL) {
4177                         return NT_STATUS_NO_MEMORY;
4178                         }
4179
4180                         r->out.result = _netr_NetrEnumerateTrustedDomains(cli->pipes_struct, r);
4181                         return NT_STATUS_OK;
4182                 }
4183
4184                 case NDR_NETR_DSRGETDCNAME: {
4185                         struct netr_DsRGetDCName *r = (struct netr_DsRGetDCName *)_r;
4186                         ZERO_STRUCT(r->out);
4187                         r->out.info = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo *);
4188                         if (r->out.info == NULL) {
4189                         return NT_STATUS_NO_MEMORY;
4190                         }
4191
4192                         r->out.result = _netr_DsRGetDCName(cli->pipes_struct, r);
4193                         return NT_STATUS_OK;
4194                 }
4195
4196                 case NDR_NETR_NETRLOGONDUMMYROUTINE1: {
4197                         struct netr_NETRLOGONDUMMYROUTINE1 *r = (struct netr_NETRLOGONDUMMYROUTINE1 *)_r;
4198                         r->out.result = _netr_NETRLOGONDUMMYROUTINE1(cli->pipes_struct, r);
4199                         return NT_STATUS_OK;
4200                 }
4201
4202                 case NDR_NETR_NETRLOGONSETSERVICEBITS: {
4203                         struct netr_NETRLOGONSETSERVICEBITS *r = (struct netr_NETRLOGONSETSERVICEBITS *)_r;
4204                         r->out.result = _netr_NETRLOGONSETSERVICEBITS(cli->pipes_struct, r);
4205                         return NT_STATUS_OK;
4206                 }
4207
4208                 case NDR_NETR_LOGONGETTRUSTRID: {
4209                         struct netr_LogonGetTrustRid *r = (struct netr_LogonGetTrustRid *)_r;
4210                         ZERO_STRUCT(r->out);
4211                         r->out.rid = talloc_zero(mem_ctx, uint32_t);
4212                         if (r->out.rid == NULL) {
4213                         return NT_STATUS_NO_MEMORY;
4214                         }
4215
4216                         r->out.result = _netr_LogonGetTrustRid(cli->pipes_struct, r);
4217                         return NT_STATUS_OK;
4218                 }
4219
4220                 case NDR_NETR_NETRLOGONCOMPUTESERVERDIGEST: {
4221                         struct netr_NETRLOGONCOMPUTESERVERDIGEST *r = (struct netr_NETRLOGONCOMPUTESERVERDIGEST *)_r;
4222                         r->out.result = _netr_NETRLOGONCOMPUTESERVERDIGEST(cli->pipes_struct, r);
4223                         return NT_STATUS_OK;
4224                 }
4225
4226                 case NDR_NETR_NETRLOGONCOMPUTECLIENTDIGEST: {
4227                         struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r = (struct netr_NETRLOGONCOMPUTECLIENTDIGEST *)_r;
4228                         r->out.result = _netr_NETRLOGONCOMPUTECLIENTDIGEST(cli->pipes_struct, r);
4229                         return NT_STATUS_OK;
4230                 }
4231
4232                 case NDR_NETR_SERVERAUTHENTICATE3: {
4233                         struct netr_ServerAuthenticate3 *r = (struct netr_ServerAuthenticate3 *)_r;
4234                         ZERO_STRUCT(r->out);
4235                         r->out.negotiate_flags = r->in.negotiate_flags;
4236                         r->out.return_credentials = talloc_zero(mem_ctx, struct netr_Credential);
4237                         if (r->out.return_credentials == NULL) {
4238                         return NT_STATUS_NO_MEMORY;
4239                         }
4240
4241                         r->out.rid = talloc_zero(mem_ctx, uint32_t);
4242                         if (r->out.rid == NULL) {
4243                         return NT_STATUS_NO_MEMORY;
4244                         }
4245
4246                         r->out.result = _netr_ServerAuthenticate3(cli->pipes_struct, r);
4247                         return NT_STATUS_OK;
4248                 }
4249
4250                 case NDR_NETR_DSRGETDCNAMEEX: {
4251                         struct netr_DsRGetDCNameEx *r = (struct netr_DsRGetDCNameEx *)_r;
4252                         ZERO_STRUCT(r->out);
4253                         r->out.info = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo *);
4254                         if (r->out.info == NULL) {
4255                         return NT_STATUS_NO_MEMORY;
4256                         }
4257
4258                         r->out.result = _netr_DsRGetDCNameEx(cli->pipes_struct, r);
4259                         return NT_STATUS_OK;
4260                 }
4261
4262                 case NDR_NETR_DSRGETSITENAME: {
4263                         struct netr_DsRGetSiteName *r = (struct netr_DsRGetSiteName *)_r;
4264                         ZERO_STRUCT(r->out);
4265                         r->out.site = talloc_zero(mem_ctx, const char *);
4266                         if (r->out.site == NULL) {
4267                         return NT_STATUS_NO_MEMORY;
4268                         }
4269
4270                         r->out.result = _netr_DsRGetSiteName(cli->pipes_struct, r);
4271                         return NT_STATUS_OK;
4272                 }
4273
4274                 case NDR_NETR_LOGONGETDOMAININFO: {
4275                         struct netr_LogonGetDomainInfo *r = (struct netr_LogonGetDomainInfo *)_r;
4276                         ZERO_STRUCT(r->out);
4277                         r->out.return_authenticator = r->in.return_authenticator;
4278                         r->out.info = talloc_zero(mem_ctx, union netr_DomainInfo);
4279                         if (r->out.info == NULL) {
4280                         return NT_STATUS_NO_MEMORY;
4281                         }
4282
4283                         r->out.result = _netr_LogonGetDomainInfo(cli->pipes_struct, r);
4284                         return NT_STATUS_OK;
4285                 }
4286
4287                 case NDR_NETR_SERVERPASSWORDSET2: {
4288                         struct netr_ServerPasswordSet2 *r = (struct netr_ServerPasswordSet2 *)_r;
4289                         ZERO_STRUCT(r->out);
4290                         r->out.return_authenticator = talloc_zero(mem_ctx, struct netr_Authenticator);
4291                         if (r->out.return_authenticator == NULL) {
4292                         return NT_STATUS_NO_MEMORY;
4293                         }
4294
4295                         r->out.result = _netr_ServerPasswordSet2(cli->pipes_struct, r);
4296                         return NT_STATUS_OK;
4297                 }
4298
4299                 case NDR_NETR_SERVERPASSWORDGET: {
4300                         struct netr_ServerPasswordGet *r = (struct netr_ServerPasswordGet *)_r;
4301                         ZERO_STRUCT(r->out);
4302                         r->out.return_authenticator = talloc_zero(mem_ctx, struct netr_Authenticator);
4303                         if (r->out.return_authenticator == NULL) {
4304                         return NT_STATUS_NO_MEMORY;
4305                         }
4306
4307                         r->out.password = talloc_zero(mem_ctx, struct samr_Password);
4308                         if (r->out.password == NULL) {
4309                         return NT_STATUS_NO_MEMORY;
4310                         }
4311
4312                         r->out.result = _netr_ServerPasswordGet(cli->pipes_struct, r);
4313                         return NT_STATUS_OK;
4314                 }
4315
4316                 case NDR_NETR_NETRLOGONSENDTOSAM: {
4317                         struct netr_NETRLOGONSENDTOSAM *r = (struct netr_NETRLOGONSENDTOSAM *)_r;
4318                         r->out.result = _netr_NETRLOGONSENDTOSAM(cli->pipes_struct, r);
4319                         return NT_STATUS_OK;
4320                 }
4321
4322                 case NDR_NETR_DSRADDRESSTOSITENAMESW: {
4323                         struct netr_DsRAddressToSitenamesW *r = (struct netr_DsRAddressToSitenamesW *)_r;
4324                         ZERO_STRUCT(r->out);
4325                         r->out.ctr = talloc_zero(mem_ctx, struct netr_DsRAddressToSitenamesWCtr *);
4326                         if (r->out.ctr == NULL) {
4327                         return NT_STATUS_NO_MEMORY;
4328                         }
4329
4330                         r->out.result = _netr_DsRAddressToSitenamesW(cli->pipes_struct, r);
4331                         return NT_STATUS_OK;
4332                 }
4333
4334                 case NDR_NETR_DSRGETDCNAMEEX2: {
4335                         struct netr_DsRGetDCNameEx2 *r = (struct netr_DsRGetDCNameEx2 *)_r;
4336                         ZERO_STRUCT(r->out);
4337                         r->out.info = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo *);
4338                         if (r->out.info == NULL) {
4339                         return NT_STATUS_NO_MEMORY;
4340                         }
4341
4342                         r->out.result = _netr_DsRGetDCNameEx2(cli->pipes_struct, r);
4343                         return NT_STATUS_OK;
4344                 }
4345
4346                 case NDR_NETR_NETRLOGONGETTIMESERVICEPARENTDOMAIN: {
4347                         struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r = (struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *)_r;
4348                         r->out.result = _netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(cli->pipes_struct, r);
4349                         return NT_STATUS_OK;
4350                 }
4351
4352                 case NDR_NETR_NETRENUMERATETRUSTEDDOMAINSEX: {
4353                         struct netr_NetrEnumerateTrustedDomainsEx *r = (struct netr_NetrEnumerateTrustedDomainsEx *)_r;
4354                         ZERO_STRUCT(r->out);
4355                         r->out.dom_trust_list = talloc_zero(mem_ctx, struct netr_DomainTrustList);
4356                         if (r->out.dom_trust_list == NULL) {
4357                         return NT_STATUS_NO_MEMORY;
4358                         }
4359
4360                         r->out.result = _netr_NetrEnumerateTrustedDomainsEx(cli->pipes_struct, r);
4361                         return NT_STATUS_OK;
4362                 }
4363
4364                 case NDR_NETR_DSRADDRESSTOSITENAMESEXW: {
4365                         struct netr_DsRAddressToSitenamesExW *r = (struct netr_DsRAddressToSitenamesExW *)_r;
4366                         ZERO_STRUCT(r->out);
4367                         r->out.ctr = talloc_zero(mem_ctx, struct netr_DsRAddressToSitenamesExWCtr *);
4368                         if (r->out.ctr == NULL) {
4369                         return NT_STATUS_NO_MEMORY;
4370                         }
4371
4372                         r->out.result = _netr_DsRAddressToSitenamesExW(cli->pipes_struct, r);
4373                         return NT_STATUS_OK;
4374                 }
4375
4376                 case NDR_NETR_DSRGETDCSITECOVERAGEW: {
4377                         struct netr_DsrGetDcSiteCoverageW *r = (struct netr_DsrGetDcSiteCoverageW *)_r;
4378                         ZERO_STRUCT(r->out);
4379                         r->out.ctr = talloc_zero(mem_ctx, struct DcSitesCtr *);
4380                         if (r->out.ctr == NULL) {
4381                         return NT_STATUS_NO_MEMORY;
4382                         }
4383
4384                         r->out.result = _netr_DsrGetDcSiteCoverageW(cli->pipes_struct, r);
4385                         return NT_STATUS_OK;
4386                 }
4387
4388                 case NDR_NETR_LOGONSAMLOGONEX: {
4389                         struct netr_LogonSamLogonEx *r = (struct netr_LogonSamLogonEx *)_r;
4390                         ZERO_STRUCT(r->out);
4391                         r->out.flags = r->in.flags;
4392                         r->out.validation = talloc_zero(mem_ctx, union netr_Validation);
4393                         if (r->out.validation == NULL) {
4394                         return NT_STATUS_NO_MEMORY;
4395                         }
4396
4397                         r->out.authoritative = talloc_zero(mem_ctx, uint8_t);
4398                         if (r->out.authoritative == NULL) {
4399                         return NT_STATUS_NO_MEMORY;
4400                         }
4401
4402                         r->out.result = _netr_LogonSamLogonEx(cli->pipes_struct, r);
4403                         return NT_STATUS_OK;
4404                 }
4405
4406                 case NDR_NETR_DSRENUMERATEDOMAINTRUSTS: {
4407                         struct netr_DsrEnumerateDomainTrusts *r = (struct netr_DsrEnumerateDomainTrusts *)_r;
4408                         ZERO_STRUCT(r->out);
4409                         r->out.trusts = talloc_zero(mem_ctx, struct netr_DomainTrustList);
4410                         if (r->out.trusts == NULL) {
4411                         return NT_STATUS_NO_MEMORY;
4412                         }
4413
4414                         r->out.result = _netr_DsrEnumerateDomainTrusts(cli->pipes_struct, r);
4415                         return NT_STATUS_OK;
4416                 }
4417
4418                 case NDR_NETR_DSRDEREGISTERDNSHOSTRECORDS: {
4419                         struct netr_DsrDeregisterDNSHostRecords *r = (struct netr_DsrDeregisterDNSHostRecords *)_r;
4420                         r->out.result = _netr_DsrDeregisterDNSHostRecords(cli->pipes_struct, r);
4421                         return NT_STATUS_OK;
4422                 }
4423
4424                 case NDR_NETR_SERVERTRUSTPASSWORDSGET: {
4425                         struct netr_ServerTrustPasswordsGet *r = (struct netr_ServerTrustPasswordsGet *)_r;
4426                         ZERO_STRUCT(r->out);
4427                         r->out.return_authenticator = talloc_zero(mem_ctx, struct netr_Authenticator);
4428                         if (r->out.return_authenticator == NULL) {
4429                         return NT_STATUS_NO_MEMORY;
4430                         }
4431
4432                         r->out.password = talloc_zero(mem_ctx, struct samr_Password);
4433                         if (r->out.password == NULL) {
4434                         return NT_STATUS_NO_MEMORY;
4435                         }
4436
4437                         r->out.password2 = talloc_zero(mem_ctx, struct samr_Password);
4438                         if (r->out.password2 == NULL) {
4439                         return NT_STATUS_NO_MEMORY;
4440                         }
4441
4442                         r->out.result = _netr_ServerTrustPasswordsGet(cli->pipes_struct, r);
4443                         return NT_STATUS_OK;
4444                 }
4445
4446                 case NDR_NETR_DSRGETFORESTTRUSTINFORMATION: {
4447                         struct netr_DsRGetForestTrustInformation *r = (struct netr_DsRGetForestTrustInformation *)_r;
4448                         ZERO_STRUCT(r->out);
4449                         r->out.forest_trust_info = talloc_zero(mem_ctx, struct lsa_ForestTrustInformation *);
4450                         if (r->out.forest_trust_info == NULL) {
4451                         return NT_STATUS_NO_MEMORY;
4452                         }
4453
4454                         r->out.result = _netr_DsRGetForestTrustInformation(cli->pipes_struct, r);
4455                         return NT_STATUS_OK;
4456                 }
4457
4458                 case NDR_NETR_GETFORESTTRUSTINFORMATION: {
4459                         struct netr_GetForestTrustInformation *r = (struct netr_GetForestTrustInformation *)_r;
4460                         ZERO_STRUCT(r->out);
4461                         r->out.return_authenticator = talloc_zero(mem_ctx, struct netr_Authenticator);
4462                         if (r->out.return_authenticator == NULL) {
4463                         return NT_STATUS_NO_MEMORY;
4464                         }
4465
4466                         r->out.forest_trust_info = talloc_zero(mem_ctx, struct lsa_ForestTrustInformation *);
4467                         if (r->out.forest_trust_info == NULL) {
4468                         return NT_STATUS_NO_MEMORY;
4469                         }
4470
4471                         r->out.result = _netr_GetForestTrustInformation(cli->pipes_struct, r);
4472                         return NT_STATUS_OK;
4473                 }
4474
4475                 case NDR_NETR_LOGONSAMLOGONWITHFLAGS: {
4476                         struct netr_LogonSamLogonWithFlags *r = (struct netr_LogonSamLogonWithFlags *)_r;
4477                         ZERO_STRUCT(r->out);
4478                         r->out.return_authenticator = r->in.return_authenticator;
4479                         r->out.flags = r->in.flags;
4480                         r->out.validation = talloc_zero(mem_ctx, union netr_Validation);
4481                         if (r->out.validation == NULL) {
4482                         return NT_STATUS_NO_MEMORY;
4483                         }
4484
4485                         r->out.authoritative = talloc_zero(mem_ctx, uint8_t);
4486                         if (r->out.authoritative == NULL) {
4487                         return NT_STATUS_NO_MEMORY;
4488                         }
4489
4490                         r->out.result = _netr_LogonSamLogonWithFlags(cli->pipes_struct, r);
4491                         return NT_STATUS_OK;
4492                 }
4493
4494                 case NDR_NETR_SERVERGETTRUSTINFO: {
4495                         struct netr_ServerGetTrustInfo *r = (struct netr_ServerGetTrustInfo *)_r;
4496                         ZERO_STRUCT(r->out);
4497                         r->out.return_authenticator = talloc_zero(mem_ctx, struct netr_Authenticator);
4498                         if (r->out.return_authenticator == NULL) {
4499                         return NT_STATUS_NO_MEMORY;
4500                         }
4501
4502                         r->out.new_owf_password = talloc_zero(mem_ctx, struct samr_Password);
4503                         if (r->out.new_owf_password == NULL) {
4504                         return NT_STATUS_NO_MEMORY;
4505                         }
4506
4507                         r->out.old_owf_password = talloc_zero(mem_ctx, struct samr_Password);
4508                         if (r->out.old_owf_password == NULL) {
4509                         return NT_STATUS_NO_MEMORY;
4510                         }
4511
4512                         r->out.trust_info = talloc_zero(mem_ctx, struct netr_TrustInfo *);
4513                         if (r->out.trust_info == NULL) {
4514                         return NT_STATUS_NO_MEMORY;
4515                         }
4516
4517                         r->out.result = _netr_ServerGetTrustInfo(cli->pipes_struct, r);
4518                         return NT_STATUS_OK;
4519                 }
4520
4521                 default:
4522                         return NT_STATUS_NOT_IMPLEMENTED;
4523         }
4524 }
4525
4526 NTSTATUS rpc_netlogon_init(void)
4527 {
4528         return rpc_srv_register(SMB_RPC_INTERFACE_VERSION, "netlogon", "netlogon", &ndr_table_netlogon, api_netlogon_cmds, sizeof(api_netlogon_cmds) / sizeof(struct api_struct));
4529 }