s3:winbind: Add async query_user_list
[sfrench/samba-autobuild/.git] / source3 / librpc / gen_ndr / srv_wbint.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_wbint.h"
8
9 static bool api_wbint_Ping(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 wbint_Ping *r;
17
18         call = &ndr_table_wbint.calls[NDR_WBINT_PING];
19
20         r = talloc(talloc_tos(), struct wbint_Ping);
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(wbint_Ping, r);
45         }
46
47         ZERO_STRUCT(r->out);
48         r->out.out_data = talloc_zero(r, uint32_t);
49         if (r->out.out_data == NULL) {
50                 talloc_free(r);
51                 return false;
52         }
53
54         _wbint_Ping(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(wbint_Ping, 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_wbint_LookupSid(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 wbint_LookupSid *r;
97
98         call = &ndr_table_wbint.calls[NDR_WBINT_LOOKUPSID];
99
100         r = talloc(talloc_tos(), struct wbint_LookupSid);
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(wbint_LookupSid, r);
125         }
126
127         ZERO_STRUCT(r->out);
128         r->out.type = talloc_zero(r, enum lsa_SidType);
129         if (r->out.type == NULL) {
130                 talloc_free(r);
131                 return false;
132         }
133
134         r->out.domain = talloc_zero(r, const char *);
135         if (r->out.domain == NULL) {
136                 talloc_free(r);
137                 return false;
138         }
139
140         r->out.name = talloc_zero(r, const char *);
141         if (r->out.name == NULL) {
142                 talloc_free(r);
143                 return false;
144         }
145
146         r->out.result = _wbint_LookupSid(p, r);
147
148         if (p->rng_fault_state) {
149                 talloc_free(r);
150                 /* Return true here, srv_pipe_hnd.c will take care */
151                 return true;
152         }
153
154         if (DEBUGLEVEL >= 10) {
155                 NDR_PRINT_OUT_DEBUG(wbint_LookupSid, r);
156         }
157
158         push = ndr_push_init_ctx(r, NULL);
159         if (push == NULL) {
160                 talloc_free(r);
161                 return false;
162         }
163
164         ndr_err = call->ndr_push(push, NDR_OUT, r);
165         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
166                 talloc_free(r);
167                 return false;
168         }
169
170         blob = ndr_push_blob(push);
171         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
172                 talloc_free(r);
173                 return false;
174         }
175
176         talloc_free(r);
177
178         return true;
179 }
180
181 static bool api_wbint_LookupName(pipes_struct *p)
182 {
183         const struct ndr_interface_call *call;
184         struct ndr_pull *pull;
185         struct ndr_push *push;
186         enum ndr_err_code ndr_err;
187         DATA_BLOB blob;
188         struct wbint_LookupName *r;
189
190         call = &ndr_table_wbint.calls[NDR_WBINT_LOOKUPNAME];
191
192         r = talloc(talloc_tos(), struct wbint_LookupName);
193         if (r == NULL) {
194                 return false;
195         }
196
197         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
198                 talloc_free(r);
199                 return false;
200         }
201
202         pull = ndr_pull_init_blob(&blob, r, NULL);
203         if (pull == NULL) {
204                 talloc_free(r);
205                 return false;
206         }
207
208         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
209         ndr_err = call->ndr_pull(pull, NDR_IN, r);
210         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
211                 talloc_free(r);
212                 return false;
213         }
214
215         if (DEBUGLEVEL >= 10) {
216                 NDR_PRINT_IN_DEBUG(wbint_LookupName, r);
217         }
218
219         ZERO_STRUCT(r->out);
220         r->out.type = talloc_zero(r, enum lsa_SidType);
221         if (r->out.type == NULL) {
222                 talloc_free(r);
223                 return false;
224         }
225
226         r->out.sid = talloc_zero(r, struct dom_sid);
227         if (r->out.sid == NULL) {
228                 talloc_free(r);
229                 return false;
230         }
231
232         r->out.result = _wbint_LookupName(p, r);
233
234         if (p->rng_fault_state) {
235                 talloc_free(r);
236                 /* Return true here, srv_pipe_hnd.c will take care */
237                 return true;
238         }
239
240         if (DEBUGLEVEL >= 10) {
241                 NDR_PRINT_OUT_DEBUG(wbint_LookupName, r);
242         }
243
244         push = ndr_push_init_ctx(r, NULL);
245         if (push == NULL) {
246                 talloc_free(r);
247                 return false;
248         }
249
250         ndr_err = call->ndr_push(push, NDR_OUT, r);
251         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
252                 talloc_free(r);
253                 return false;
254         }
255
256         blob = ndr_push_blob(push);
257         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
258                 talloc_free(r);
259                 return false;
260         }
261
262         talloc_free(r);
263
264         return true;
265 }
266
267 static bool api_wbint_Sid2Uid(pipes_struct *p)
268 {
269         const struct ndr_interface_call *call;
270         struct ndr_pull *pull;
271         struct ndr_push *push;
272         enum ndr_err_code ndr_err;
273         DATA_BLOB blob;
274         struct wbint_Sid2Uid *r;
275
276         call = &ndr_table_wbint.calls[NDR_WBINT_SID2UID];
277
278         r = talloc(talloc_tos(), struct wbint_Sid2Uid);
279         if (r == NULL) {
280                 return false;
281         }
282
283         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
284                 talloc_free(r);
285                 return false;
286         }
287
288         pull = ndr_pull_init_blob(&blob, r, NULL);
289         if (pull == NULL) {
290                 talloc_free(r);
291                 return false;
292         }
293
294         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
295         ndr_err = call->ndr_pull(pull, NDR_IN, r);
296         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
297                 talloc_free(r);
298                 return false;
299         }
300
301         if (DEBUGLEVEL >= 10) {
302                 NDR_PRINT_IN_DEBUG(wbint_Sid2Uid, r);
303         }
304
305         ZERO_STRUCT(r->out);
306         r->out.uid = talloc_zero(r, uint64_t);
307         if (r->out.uid == NULL) {
308                 talloc_free(r);
309                 return false;
310         }
311
312         r->out.result = _wbint_Sid2Uid(p, r);
313
314         if (p->rng_fault_state) {
315                 talloc_free(r);
316                 /* Return true here, srv_pipe_hnd.c will take care */
317                 return true;
318         }
319
320         if (DEBUGLEVEL >= 10) {
321                 NDR_PRINT_OUT_DEBUG(wbint_Sid2Uid, r);
322         }
323
324         push = ndr_push_init_ctx(r, NULL);
325         if (push == NULL) {
326                 talloc_free(r);
327                 return false;
328         }
329
330         ndr_err = call->ndr_push(push, NDR_OUT, r);
331         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
332                 talloc_free(r);
333                 return false;
334         }
335
336         blob = ndr_push_blob(push);
337         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
338                 talloc_free(r);
339                 return false;
340         }
341
342         talloc_free(r);
343
344         return true;
345 }
346
347 static bool api_wbint_Sid2Gid(pipes_struct *p)
348 {
349         const struct ndr_interface_call *call;
350         struct ndr_pull *pull;
351         struct ndr_push *push;
352         enum ndr_err_code ndr_err;
353         DATA_BLOB blob;
354         struct wbint_Sid2Gid *r;
355
356         call = &ndr_table_wbint.calls[NDR_WBINT_SID2GID];
357
358         r = talloc(talloc_tos(), struct wbint_Sid2Gid);
359         if (r == NULL) {
360                 return false;
361         }
362
363         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
364                 talloc_free(r);
365                 return false;
366         }
367
368         pull = ndr_pull_init_blob(&blob, r, NULL);
369         if (pull == NULL) {
370                 talloc_free(r);
371                 return false;
372         }
373
374         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
375         ndr_err = call->ndr_pull(pull, NDR_IN, r);
376         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
377                 talloc_free(r);
378                 return false;
379         }
380
381         if (DEBUGLEVEL >= 10) {
382                 NDR_PRINT_IN_DEBUG(wbint_Sid2Gid, r);
383         }
384
385         ZERO_STRUCT(r->out);
386         r->out.gid = talloc_zero(r, uint64_t);
387         if (r->out.gid == NULL) {
388                 talloc_free(r);
389                 return false;
390         }
391
392         r->out.result = _wbint_Sid2Gid(p, r);
393
394         if (p->rng_fault_state) {
395                 talloc_free(r);
396                 /* Return true here, srv_pipe_hnd.c will take care */
397                 return true;
398         }
399
400         if (DEBUGLEVEL >= 10) {
401                 NDR_PRINT_OUT_DEBUG(wbint_Sid2Gid, r);
402         }
403
404         push = ndr_push_init_ctx(r, NULL);
405         if (push == NULL) {
406                 talloc_free(r);
407                 return false;
408         }
409
410         ndr_err = call->ndr_push(push, NDR_OUT, r);
411         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
412                 talloc_free(r);
413                 return false;
414         }
415
416         blob = ndr_push_blob(push);
417         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
418                 talloc_free(r);
419                 return false;
420         }
421
422         talloc_free(r);
423
424         return true;
425 }
426
427 static bool api_wbint_Uid2Sid(pipes_struct *p)
428 {
429         const struct ndr_interface_call *call;
430         struct ndr_pull *pull;
431         struct ndr_push *push;
432         enum ndr_err_code ndr_err;
433         DATA_BLOB blob;
434         struct wbint_Uid2Sid *r;
435
436         call = &ndr_table_wbint.calls[NDR_WBINT_UID2SID];
437
438         r = talloc(talloc_tos(), struct wbint_Uid2Sid);
439         if (r == NULL) {
440                 return false;
441         }
442
443         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
444                 talloc_free(r);
445                 return false;
446         }
447
448         pull = ndr_pull_init_blob(&blob, r, NULL);
449         if (pull == NULL) {
450                 talloc_free(r);
451                 return false;
452         }
453
454         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
455         ndr_err = call->ndr_pull(pull, NDR_IN, r);
456         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
457                 talloc_free(r);
458                 return false;
459         }
460
461         if (DEBUGLEVEL >= 10) {
462                 NDR_PRINT_IN_DEBUG(wbint_Uid2Sid, r);
463         }
464
465         ZERO_STRUCT(r->out);
466         r->out.sid = talloc_zero(r, struct dom_sid);
467         if (r->out.sid == NULL) {
468                 talloc_free(r);
469                 return false;
470         }
471
472         r->out.result = _wbint_Uid2Sid(p, r);
473
474         if (p->rng_fault_state) {
475                 talloc_free(r);
476                 /* Return true here, srv_pipe_hnd.c will take care */
477                 return true;
478         }
479
480         if (DEBUGLEVEL >= 10) {
481                 NDR_PRINT_OUT_DEBUG(wbint_Uid2Sid, r);
482         }
483
484         push = ndr_push_init_ctx(r, NULL);
485         if (push == NULL) {
486                 talloc_free(r);
487                 return false;
488         }
489
490         ndr_err = call->ndr_push(push, NDR_OUT, r);
491         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
492                 talloc_free(r);
493                 return false;
494         }
495
496         blob = ndr_push_blob(push);
497         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
498                 talloc_free(r);
499                 return false;
500         }
501
502         talloc_free(r);
503
504         return true;
505 }
506
507 static bool api_wbint_Gid2Sid(pipes_struct *p)
508 {
509         const struct ndr_interface_call *call;
510         struct ndr_pull *pull;
511         struct ndr_push *push;
512         enum ndr_err_code ndr_err;
513         DATA_BLOB blob;
514         struct wbint_Gid2Sid *r;
515
516         call = &ndr_table_wbint.calls[NDR_WBINT_GID2SID];
517
518         r = talloc(talloc_tos(), struct wbint_Gid2Sid);
519         if (r == NULL) {
520                 return false;
521         }
522
523         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
524                 talloc_free(r);
525                 return false;
526         }
527
528         pull = ndr_pull_init_blob(&blob, r, NULL);
529         if (pull == NULL) {
530                 talloc_free(r);
531                 return false;
532         }
533
534         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
535         ndr_err = call->ndr_pull(pull, NDR_IN, r);
536         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
537                 talloc_free(r);
538                 return false;
539         }
540
541         if (DEBUGLEVEL >= 10) {
542                 NDR_PRINT_IN_DEBUG(wbint_Gid2Sid, r);
543         }
544
545         ZERO_STRUCT(r->out);
546         r->out.sid = talloc_zero(r, struct dom_sid);
547         if (r->out.sid == NULL) {
548                 talloc_free(r);
549                 return false;
550         }
551
552         r->out.result = _wbint_Gid2Sid(p, r);
553
554         if (p->rng_fault_state) {
555                 talloc_free(r);
556                 /* Return true here, srv_pipe_hnd.c will take care */
557                 return true;
558         }
559
560         if (DEBUGLEVEL >= 10) {
561                 NDR_PRINT_OUT_DEBUG(wbint_Gid2Sid, r);
562         }
563
564         push = ndr_push_init_ctx(r, NULL);
565         if (push == NULL) {
566                 talloc_free(r);
567                 return false;
568         }
569
570         ndr_err = call->ndr_push(push, NDR_OUT, r);
571         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
572                 talloc_free(r);
573                 return false;
574         }
575
576         blob = ndr_push_blob(push);
577         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
578                 talloc_free(r);
579                 return false;
580         }
581
582         talloc_free(r);
583
584         return true;
585 }
586
587 static bool api_wbint_QueryUser(pipes_struct *p)
588 {
589         const struct ndr_interface_call *call;
590         struct ndr_pull *pull;
591         struct ndr_push *push;
592         enum ndr_err_code ndr_err;
593         DATA_BLOB blob;
594         struct wbint_QueryUser *r;
595
596         call = &ndr_table_wbint.calls[NDR_WBINT_QUERYUSER];
597
598         r = talloc(talloc_tos(), struct wbint_QueryUser);
599         if (r == NULL) {
600                 return false;
601         }
602
603         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
604                 talloc_free(r);
605                 return false;
606         }
607
608         pull = ndr_pull_init_blob(&blob, r, NULL);
609         if (pull == NULL) {
610                 talloc_free(r);
611                 return false;
612         }
613
614         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
615         ndr_err = call->ndr_pull(pull, NDR_IN, r);
616         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
617                 talloc_free(r);
618                 return false;
619         }
620
621         if (DEBUGLEVEL >= 10) {
622                 NDR_PRINT_IN_DEBUG(wbint_QueryUser, r);
623         }
624
625         ZERO_STRUCT(r->out);
626         r->out.info = talloc_zero(r, struct wbint_userinfo);
627         if (r->out.info == NULL) {
628                 talloc_free(r);
629                 return false;
630         }
631
632         r->out.result = _wbint_QueryUser(p, r);
633
634         if (p->rng_fault_state) {
635                 talloc_free(r);
636                 /* Return true here, srv_pipe_hnd.c will take care */
637                 return true;
638         }
639
640         if (DEBUGLEVEL >= 10) {
641                 NDR_PRINT_OUT_DEBUG(wbint_QueryUser, r);
642         }
643
644         push = ndr_push_init_ctx(r, NULL);
645         if (push == NULL) {
646                 talloc_free(r);
647                 return false;
648         }
649
650         ndr_err = call->ndr_push(push, NDR_OUT, r);
651         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
652                 talloc_free(r);
653                 return false;
654         }
655
656         blob = ndr_push_blob(push);
657         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
658                 talloc_free(r);
659                 return false;
660         }
661
662         talloc_free(r);
663
664         return true;
665 }
666
667 static bool api_wbint_LookupUserAliases(pipes_struct *p)
668 {
669         const struct ndr_interface_call *call;
670         struct ndr_pull *pull;
671         struct ndr_push *push;
672         enum ndr_err_code ndr_err;
673         DATA_BLOB blob;
674         struct wbint_LookupUserAliases *r;
675
676         call = &ndr_table_wbint.calls[NDR_WBINT_LOOKUPUSERALIASES];
677
678         r = talloc(talloc_tos(), struct wbint_LookupUserAliases);
679         if (r == NULL) {
680                 return false;
681         }
682
683         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
684                 talloc_free(r);
685                 return false;
686         }
687
688         pull = ndr_pull_init_blob(&blob, r, NULL);
689         if (pull == NULL) {
690                 talloc_free(r);
691                 return false;
692         }
693
694         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
695         ndr_err = call->ndr_pull(pull, NDR_IN, r);
696         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
697                 talloc_free(r);
698                 return false;
699         }
700
701         if (DEBUGLEVEL >= 10) {
702                 NDR_PRINT_IN_DEBUG(wbint_LookupUserAliases, r);
703         }
704
705         ZERO_STRUCT(r->out);
706         r->out.rids = talloc_zero(r, struct wbint_RidArray);
707         if (r->out.rids == NULL) {
708                 talloc_free(r);
709                 return false;
710         }
711
712         r->out.result = _wbint_LookupUserAliases(p, r);
713
714         if (p->rng_fault_state) {
715                 talloc_free(r);
716                 /* Return true here, srv_pipe_hnd.c will take care */
717                 return true;
718         }
719
720         if (DEBUGLEVEL >= 10) {
721                 NDR_PRINT_OUT_DEBUG(wbint_LookupUserAliases, r);
722         }
723
724         push = ndr_push_init_ctx(r, NULL);
725         if (push == NULL) {
726                 talloc_free(r);
727                 return false;
728         }
729
730         ndr_err = call->ndr_push(push, NDR_OUT, r);
731         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
732                 talloc_free(r);
733                 return false;
734         }
735
736         blob = ndr_push_blob(push);
737         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
738                 talloc_free(r);
739                 return false;
740         }
741
742         talloc_free(r);
743
744         return true;
745 }
746
747 static bool api_wbint_LookupUserGroups(pipes_struct *p)
748 {
749         const struct ndr_interface_call *call;
750         struct ndr_pull *pull;
751         struct ndr_push *push;
752         enum ndr_err_code ndr_err;
753         DATA_BLOB blob;
754         struct wbint_LookupUserGroups *r;
755
756         call = &ndr_table_wbint.calls[NDR_WBINT_LOOKUPUSERGROUPS];
757
758         r = talloc(talloc_tos(), struct wbint_LookupUserGroups);
759         if (r == NULL) {
760                 return false;
761         }
762
763         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
764                 talloc_free(r);
765                 return false;
766         }
767
768         pull = ndr_pull_init_blob(&blob, r, NULL);
769         if (pull == NULL) {
770                 talloc_free(r);
771                 return false;
772         }
773
774         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
775         ndr_err = call->ndr_pull(pull, NDR_IN, r);
776         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
777                 talloc_free(r);
778                 return false;
779         }
780
781         if (DEBUGLEVEL >= 10) {
782                 NDR_PRINT_IN_DEBUG(wbint_LookupUserGroups, r);
783         }
784
785         ZERO_STRUCT(r->out);
786         r->out.sids = talloc_zero(r, struct wbint_SidArray);
787         if (r->out.sids == NULL) {
788                 talloc_free(r);
789                 return false;
790         }
791
792         r->out.result = _wbint_LookupUserGroups(p, r);
793
794         if (p->rng_fault_state) {
795                 talloc_free(r);
796                 /* Return true here, srv_pipe_hnd.c will take care */
797                 return true;
798         }
799
800         if (DEBUGLEVEL >= 10) {
801                 NDR_PRINT_OUT_DEBUG(wbint_LookupUserGroups, r);
802         }
803
804         push = ndr_push_init_ctx(r, NULL);
805         if (push == NULL) {
806                 talloc_free(r);
807                 return false;
808         }
809
810         ndr_err = call->ndr_push(push, NDR_OUT, r);
811         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
812                 talloc_free(r);
813                 return false;
814         }
815
816         blob = ndr_push_blob(push);
817         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
818                 talloc_free(r);
819                 return false;
820         }
821
822         talloc_free(r);
823
824         return true;
825 }
826
827 static bool api_wbint_QuerySequenceNumber(pipes_struct *p)
828 {
829         const struct ndr_interface_call *call;
830         struct ndr_pull *pull;
831         struct ndr_push *push;
832         enum ndr_err_code ndr_err;
833         DATA_BLOB blob;
834         struct wbint_QuerySequenceNumber *r;
835
836         call = &ndr_table_wbint.calls[NDR_WBINT_QUERYSEQUENCENUMBER];
837
838         r = talloc(talloc_tos(), struct wbint_QuerySequenceNumber);
839         if (r == NULL) {
840                 return false;
841         }
842
843         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
844                 talloc_free(r);
845                 return false;
846         }
847
848         pull = ndr_pull_init_blob(&blob, r, NULL);
849         if (pull == NULL) {
850                 talloc_free(r);
851                 return false;
852         }
853
854         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
855         ndr_err = call->ndr_pull(pull, NDR_IN, r);
856         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
857                 talloc_free(r);
858                 return false;
859         }
860
861         if (DEBUGLEVEL >= 10) {
862                 NDR_PRINT_IN_DEBUG(wbint_QuerySequenceNumber, r);
863         }
864
865         ZERO_STRUCT(r->out);
866         r->out.sequence = talloc_zero(r, uint32_t);
867         if (r->out.sequence == NULL) {
868                 talloc_free(r);
869                 return false;
870         }
871
872         r->out.result = _wbint_QuerySequenceNumber(p, r);
873
874         if (p->rng_fault_state) {
875                 talloc_free(r);
876                 /* Return true here, srv_pipe_hnd.c will take care */
877                 return true;
878         }
879
880         if (DEBUGLEVEL >= 10) {
881                 NDR_PRINT_OUT_DEBUG(wbint_QuerySequenceNumber, r);
882         }
883
884         push = ndr_push_init_ctx(r, NULL);
885         if (push == NULL) {
886                 talloc_free(r);
887                 return false;
888         }
889
890         ndr_err = call->ndr_push(push, NDR_OUT, r);
891         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
892                 talloc_free(r);
893                 return false;
894         }
895
896         blob = ndr_push_blob(push);
897         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
898                 talloc_free(r);
899                 return false;
900         }
901
902         talloc_free(r);
903
904         return true;
905 }
906
907 static bool api_wbint_LookupGroupMembers(pipes_struct *p)
908 {
909         const struct ndr_interface_call *call;
910         struct ndr_pull *pull;
911         struct ndr_push *push;
912         enum ndr_err_code ndr_err;
913         DATA_BLOB blob;
914         struct wbint_LookupGroupMembers *r;
915
916         call = &ndr_table_wbint.calls[NDR_WBINT_LOOKUPGROUPMEMBERS];
917
918         r = talloc(talloc_tos(), struct wbint_LookupGroupMembers);
919         if (r == NULL) {
920                 return false;
921         }
922
923         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
924                 talloc_free(r);
925                 return false;
926         }
927
928         pull = ndr_pull_init_blob(&blob, r, NULL);
929         if (pull == NULL) {
930                 talloc_free(r);
931                 return false;
932         }
933
934         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
935         ndr_err = call->ndr_pull(pull, NDR_IN, r);
936         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
937                 talloc_free(r);
938                 return false;
939         }
940
941         if (DEBUGLEVEL >= 10) {
942                 NDR_PRINT_IN_DEBUG(wbint_LookupGroupMembers, r);
943         }
944
945         ZERO_STRUCT(r->out);
946         r->out.members = talloc_zero(r, struct wbint_Principals);
947         if (r->out.members == NULL) {
948                 talloc_free(r);
949                 return false;
950         }
951
952         r->out.result = _wbint_LookupGroupMembers(p, r);
953
954         if (p->rng_fault_state) {
955                 talloc_free(r);
956                 /* Return true here, srv_pipe_hnd.c will take care */
957                 return true;
958         }
959
960         if (DEBUGLEVEL >= 10) {
961                 NDR_PRINT_OUT_DEBUG(wbint_LookupGroupMembers, r);
962         }
963
964         push = ndr_push_init_ctx(r, NULL);
965         if (push == NULL) {
966                 talloc_free(r);
967                 return false;
968         }
969
970         ndr_err = call->ndr_push(push, NDR_OUT, r);
971         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
972                 talloc_free(r);
973                 return false;
974         }
975
976         blob = ndr_push_blob(push);
977         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
978                 talloc_free(r);
979                 return false;
980         }
981
982         talloc_free(r);
983
984         return true;
985 }
986
987 static bool api_wbint_QueryUserList(pipes_struct *p)
988 {
989         const struct ndr_interface_call *call;
990         struct ndr_pull *pull;
991         struct ndr_push *push;
992         enum ndr_err_code ndr_err;
993         DATA_BLOB blob;
994         struct wbint_QueryUserList *r;
995
996         call = &ndr_table_wbint.calls[NDR_WBINT_QUERYUSERLIST];
997
998         r = talloc(talloc_tos(), struct wbint_QueryUserList);
999         if (r == NULL) {
1000                 return false;
1001         }
1002
1003         if (!prs_data_blob(&p->in_data.data, &blob, r)) {
1004                 talloc_free(r);
1005                 return false;
1006         }
1007
1008         pull = ndr_pull_init_blob(&blob, r, NULL);
1009         if (pull == NULL) {
1010                 talloc_free(r);
1011                 return false;
1012         }
1013
1014         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
1015         ndr_err = call->ndr_pull(pull, NDR_IN, r);
1016         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1017                 talloc_free(r);
1018                 return false;
1019         }
1020
1021         if (DEBUGLEVEL >= 10) {
1022                 NDR_PRINT_IN_DEBUG(wbint_QueryUserList, r);
1023         }
1024
1025         ZERO_STRUCT(r->out);
1026         r->out.users = talloc_zero(r, struct wbint_userinfos);
1027         if (r->out.users == NULL) {
1028                 talloc_free(r);
1029                 return false;
1030         }
1031
1032         r->out.result = _wbint_QueryUserList(p, r);
1033
1034         if (p->rng_fault_state) {
1035                 talloc_free(r);
1036                 /* Return true here, srv_pipe_hnd.c will take care */
1037                 return true;
1038         }
1039
1040         if (DEBUGLEVEL >= 10) {
1041                 NDR_PRINT_OUT_DEBUG(wbint_QueryUserList, r);
1042         }
1043
1044         push = ndr_push_init_ctx(r, NULL);
1045         if (push == NULL) {
1046                 talloc_free(r);
1047                 return false;
1048         }
1049
1050         ndr_err = call->ndr_push(push, NDR_OUT, r);
1051         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1052                 talloc_free(r);
1053                 return false;
1054         }
1055
1056         blob = ndr_push_blob(push);
1057         if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
1058                 talloc_free(r);
1059                 return false;
1060         }
1061
1062         talloc_free(r);
1063
1064         return true;
1065 }
1066
1067
1068 /* Tables */
1069 static struct api_struct api_wbint_cmds[] = 
1070 {
1071         {"WBINT_PING", NDR_WBINT_PING, api_wbint_Ping},
1072         {"WBINT_LOOKUPSID", NDR_WBINT_LOOKUPSID, api_wbint_LookupSid},
1073         {"WBINT_LOOKUPNAME", NDR_WBINT_LOOKUPNAME, api_wbint_LookupName},
1074         {"WBINT_SID2UID", NDR_WBINT_SID2UID, api_wbint_Sid2Uid},
1075         {"WBINT_SID2GID", NDR_WBINT_SID2GID, api_wbint_Sid2Gid},
1076         {"WBINT_UID2SID", NDR_WBINT_UID2SID, api_wbint_Uid2Sid},
1077         {"WBINT_GID2SID", NDR_WBINT_GID2SID, api_wbint_Gid2Sid},
1078         {"WBINT_QUERYUSER", NDR_WBINT_QUERYUSER, api_wbint_QueryUser},
1079         {"WBINT_LOOKUPUSERALIASES", NDR_WBINT_LOOKUPUSERALIASES, api_wbint_LookupUserAliases},
1080         {"WBINT_LOOKUPUSERGROUPS", NDR_WBINT_LOOKUPUSERGROUPS, api_wbint_LookupUserGroups},
1081         {"WBINT_QUERYSEQUENCENUMBER", NDR_WBINT_QUERYSEQUENCENUMBER, api_wbint_QuerySequenceNumber},
1082         {"WBINT_LOOKUPGROUPMEMBERS", NDR_WBINT_LOOKUPGROUPMEMBERS, api_wbint_LookupGroupMembers},
1083         {"WBINT_QUERYUSERLIST", NDR_WBINT_QUERYUSERLIST, api_wbint_QueryUserList},
1084 };
1085
1086 void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns)
1087 {
1088         *fns = api_wbint_cmds;
1089         *n_fns = sizeof(api_wbint_cmds) / sizeof(struct api_struct);
1090 }
1091
1092 NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *_r)
1093 {
1094         if (cli->pipes_struct == NULL) {
1095                 return NT_STATUS_INVALID_PARAMETER;
1096         }
1097
1098         switch (opnum)
1099         {
1100                 case NDR_WBINT_PING: {
1101                         struct wbint_Ping *r = (struct wbint_Ping *)_r;
1102                         ZERO_STRUCT(r->out);
1103                         r->out.out_data = talloc_zero(mem_ctx, uint32_t);
1104                         if (r->out.out_data == NULL) {
1105                         return NT_STATUS_NO_MEMORY;
1106                         }
1107
1108                         _wbint_Ping(cli->pipes_struct, r);
1109                         return NT_STATUS_OK;
1110                 }
1111
1112                 case NDR_WBINT_LOOKUPSID: {
1113                         struct wbint_LookupSid *r = (struct wbint_LookupSid *)_r;
1114                         ZERO_STRUCT(r->out);
1115                         r->out.type = talloc_zero(mem_ctx, enum lsa_SidType);
1116                         if (r->out.type == NULL) {
1117                         return NT_STATUS_NO_MEMORY;
1118                         }
1119
1120                         r->out.domain = talloc_zero(mem_ctx, const char *);
1121                         if (r->out.domain == NULL) {
1122                         return NT_STATUS_NO_MEMORY;
1123                         }
1124
1125                         r->out.name = talloc_zero(mem_ctx, const char *);
1126                         if (r->out.name == NULL) {
1127                         return NT_STATUS_NO_MEMORY;
1128                         }
1129
1130                         r->out.result = _wbint_LookupSid(cli->pipes_struct, r);
1131                         return NT_STATUS_OK;
1132                 }
1133
1134                 case NDR_WBINT_LOOKUPNAME: {
1135                         struct wbint_LookupName *r = (struct wbint_LookupName *)_r;
1136                         ZERO_STRUCT(r->out);
1137                         r->out.type = talloc_zero(mem_ctx, enum lsa_SidType);
1138                         if (r->out.type == NULL) {
1139                         return NT_STATUS_NO_MEMORY;
1140                         }
1141
1142                         r->out.sid = talloc_zero(mem_ctx, struct dom_sid);
1143                         if (r->out.sid == NULL) {
1144                         return NT_STATUS_NO_MEMORY;
1145                         }
1146
1147                         r->out.result = _wbint_LookupName(cli->pipes_struct, r);
1148                         return NT_STATUS_OK;
1149                 }
1150
1151                 case NDR_WBINT_SID2UID: {
1152                         struct wbint_Sid2Uid *r = (struct wbint_Sid2Uid *)_r;
1153                         ZERO_STRUCT(r->out);
1154                         r->out.uid = talloc_zero(mem_ctx, uint64_t);
1155                         if (r->out.uid == NULL) {
1156                         return NT_STATUS_NO_MEMORY;
1157                         }
1158
1159                         r->out.result = _wbint_Sid2Uid(cli->pipes_struct, r);
1160                         return NT_STATUS_OK;
1161                 }
1162
1163                 case NDR_WBINT_SID2GID: {
1164                         struct wbint_Sid2Gid *r = (struct wbint_Sid2Gid *)_r;
1165                         ZERO_STRUCT(r->out);
1166                         r->out.gid = talloc_zero(mem_ctx, uint64_t);
1167                         if (r->out.gid == NULL) {
1168                         return NT_STATUS_NO_MEMORY;
1169                         }
1170
1171                         r->out.result = _wbint_Sid2Gid(cli->pipes_struct, r);
1172                         return NT_STATUS_OK;
1173                 }
1174
1175                 case NDR_WBINT_UID2SID: {
1176                         struct wbint_Uid2Sid *r = (struct wbint_Uid2Sid *)_r;
1177                         ZERO_STRUCT(r->out);
1178                         r->out.sid = talloc_zero(mem_ctx, struct dom_sid);
1179                         if (r->out.sid == NULL) {
1180                         return NT_STATUS_NO_MEMORY;
1181                         }
1182
1183                         r->out.result = _wbint_Uid2Sid(cli->pipes_struct, r);
1184                         return NT_STATUS_OK;
1185                 }
1186
1187                 case NDR_WBINT_GID2SID: {
1188                         struct wbint_Gid2Sid *r = (struct wbint_Gid2Sid *)_r;
1189                         ZERO_STRUCT(r->out);
1190                         r->out.sid = talloc_zero(mem_ctx, struct dom_sid);
1191                         if (r->out.sid == NULL) {
1192                         return NT_STATUS_NO_MEMORY;
1193                         }
1194
1195                         r->out.result = _wbint_Gid2Sid(cli->pipes_struct, r);
1196                         return NT_STATUS_OK;
1197                 }
1198
1199                 case NDR_WBINT_QUERYUSER: {
1200                         struct wbint_QueryUser *r = (struct wbint_QueryUser *)_r;
1201                         ZERO_STRUCT(r->out);
1202                         r->out.info = talloc_zero(mem_ctx, struct wbint_userinfo);
1203                         if (r->out.info == NULL) {
1204                         return NT_STATUS_NO_MEMORY;
1205                         }
1206
1207                         r->out.result = _wbint_QueryUser(cli->pipes_struct, r);
1208                         return NT_STATUS_OK;
1209                 }
1210
1211                 case NDR_WBINT_LOOKUPUSERALIASES: {
1212                         struct wbint_LookupUserAliases *r = (struct wbint_LookupUserAliases *)_r;
1213                         ZERO_STRUCT(r->out);
1214                         r->out.rids = talloc_zero(mem_ctx, struct wbint_RidArray);
1215                         if (r->out.rids == NULL) {
1216                         return NT_STATUS_NO_MEMORY;
1217                         }
1218
1219                         r->out.result = _wbint_LookupUserAliases(cli->pipes_struct, r);
1220                         return NT_STATUS_OK;
1221                 }
1222
1223                 case NDR_WBINT_LOOKUPUSERGROUPS: {
1224                         struct wbint_LookupUserGroups *r = (struct wbint_LookupUserGroups *)_r;
1225                         ZERO_STRUCT(r->out);
1226                         r->out.sids = talloc_zero(mem_ctx, struct wbint_SidArray);
1227                         if (r->out.sids == NULL) {
1228                         return NT_STATUS_NO_MEMORY;
1229                         }
1230
1231                         r->out.result = _wbint_LookupUserGroups(cli->pipes_struct, r);
1232                         return NT_STATUS_OK;
1233                 }
1234
1235                 case NDR_WBINT_QUERYSEQUENCENUMBER: {
1236                         struct wbint_QuerySequenceNumber *r = (struct wbint_QuerySequenceNumber *)_r;
1237                         ZERO_STRUCT(r->out);
1238                         r->out.sequence = talloc_zero(mem_ctx, uint32_t);
1239                         if (r->out.sequence == NULL) {
1240                         return NT_STATUS_NO_MEMORY;
1241                         }
1242
1243                         r->out.result = _wbint_QuerySequenceNumber(cli->pipes_struct, r);
1244                         return NT_STATUS_OK;
1245                 }
1246
1247                 case NDR_WBINT_LOOKUPGROUPMEMBERS: {
1248                         struct wbint_LookupGroupMembers *r = (struct wbint_LookupGroupMembers *)_r;
1249                         ZERO_STRUCT(r->out);
1250                         r->out.members = talloc_zero(mem_ctx, struct wbint_Principals);
1251                         if (r->out.members == NULL) {
1252                         return NT_STATUS_NO_MEMORY;
1253                         }
1254
1255                         r->out.result = _wbint_LookupGroupMembers(cli->pipes_struct, r);
1256                         return NT_STATUS_OK;
1257                 }
1258
1259                 case NDR_WBINT_QUERYUSERLIST: {
1260                         struct wbint_QueryUserList *r = (struct wbint_QueryUserList *)_r;
1261                         ZERO_STRUCT(r->out);
1262                         r->out.users = talloc_zero(mem_ctx, struct wbint_userinfos);
1263                         if (r->out.users == NULL) {
1264                         return NT_STATUS_NO_MEMORY;
1265                         }
1266
1267                         r->out.result = _wbint_QueryUserList(cli->pipes_struct, r);
1268                         return NT_STATUS_OK;
1269                 }
1270
1271                 default:
1272                         return NT_STATUS_NOT_IMPLEMENTED;
1273         }
1274 }
1275
1276 NTSTATUS rpc_wbint_init(void)
1277 {
1278         return rpc_srv_register(SMB_RPC_INTERFACE_VERSION, "wbint", "wbint", &ndr_table_wbint, api_wbint_cmds, sizeof(api_wbint_cmds) / sizeof(struct api_struct));
1279 }