netapi: add skeleton for NetGroupEnum().
[samba.git] / source3 / lib / netapi / libnetapi.c
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  NetApi Support
4  *  Copyright (C) Guenther Deschner 2007-2008
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #include "includes.h"
21 #include "librpc/gen_ndr/libnetapi.h"
22 #include "lib/netapi/netapi.h"
23 #include "lib/netapi/netapi_private.h"
24 #include "lib/netapi/libnetapi.h"
25 #include "librpc/gen_ndr/ndr_libnetapi.h"
26
27 /****************************************************************
28  NetJoinDomain
29 ****************************************************************/
30
31 NET_API_STATUS NetJoinDomain(const char * server /* [in] [unique] */,
32                              const char * domain /* [in] [ref] */,
33                              const char * account_ou /* [in] [unique] */,
34                              const char * account /* [in] [unique] */,
35                              const char * password /* [in] [unique] */,
36                              uint32_t join_flags /* [in] */)
37 {
38         struct NetJoinDomain r;
39         struct libnetapi_ctx *ctx = NULL;
40         NET_API_STATUS status;
41         WERROR werr;
42
43         status = libnetapi_getctx(&ctx);
44         if (status != 0) {
45                 return status;
46         }
47
48         /* In parameters */
49         r.in.server = server;
50         r.in.domain = domain;
51         r.in.account_ou = account_ou;
52         r.in.account = account;
53         r.in.password = password;
54         r.in.join_flags = join_flags;
55
56         /* Out parameters */
57
58         if (DEBUGLEVEL >= 10) {
59                 NDR_PRINT_IN_DEBUG(NetJoinDomain, &r);
60         }
61
62         if (LIBNETAPI_LOCAL_SERVER(server)) {
63                 werr = NetJoinDomain_l(ctx, &r);
64         } else {
65                 werr = NetJoinDomain_r(ctx, &r);
66         }
67
68         r.out.result = W_ERROR_V(werr);
69
70         if (DEBUGLEVEL >= 10) {
71                 NDR_PRINT_OUT_DEBUG(NetJoinDomain, &r);
72         }
73
74         return r.out.result;
75 }
76
77 /****************************************************************
78  NetUnjoinDomain
79 ****************************************************************/
80
81 NET_API_STATUS NetUnjoinDomain(const char * server_name /* [in] [unique] */,
82                                const char * account /* [in] [unique] */,
83                                const char * password /* [in] [unique] */,
84                                uint32_t unjoin_flags /* [in] */)
85 {
86         struct NetUnjoinDomain r;
87         struct libnetapi_ctx *ctx = NULL;
88         NET_API_STATUS status;
89         WERROR werr;
90
91         status = libnetapi_getctx(&ctx);
92         if (status != 0) {
93                 return status;
94         }
95
96         /* In parameters */
97         r.in.server_name = server_name;
98         r.in.account = account;
99         r.in.password = password;
100         r.in.unjoin_flags = unjoin_flags;
101
102         /* Out parameters */
103
104         if (DEBUGLEVEL >= 10) {
105                 NDR_PRINT_IN_DEBUG(NetUnjoinDomain, &r);
106         }
107
108         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
109                 werr = NetUnjoinDomain_l(ctx, &r);
110         } else {
111                 werr = NetUnjoinDomain_r(ctx, &r);
112         }
113
114         r.out.result = W_ERROR_V(werr);
115
116         if (DEBUGLEVEL >= 10) {
117                 NDR_PRINT_OUT_DEBUG(NetUnjoinDomain, &r);
118         }
119
120         return r.out.result;
121 }
122
123 /****************************************************************
124  NetGetJoinInformation
125 ****************************************************************/
126
127 NET_API_STATUS NetGetJoinInformation(const char * server_name /* [in] [unique] */,
128                                      const char * *name_buffer /* [out] [ref] */,
129                                      uint16_t *name_type /* [out] [ref] */)
130 {
131         struct NetGetJoinInformation r;
132         struct libnetapi_ctx *ctx = NULL;
133         NET_API_STATUS status;
134         WERROR werr;
135
136         status = libnetapi_getctx(&ctx);
137         if (status != 0) {
138                 return status;
139         }
140
141         /* In parameters */
142         r.in.server_name = server_name;
143
144         /* Out parameters */
145         r.out.name_buffer = name_buffer;
146         r.out.name_type = name_type;
147
148         if (DEBUGLEVEL >= 10) {
149                 NDR_PRINT_IN_DEBUG(NetGetJoinInformation, &r);
150         }
151
152         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
153                 werr = NetGetJoinInformation_l(ctx, &r);
154         } else {
155                 werr = NetGetJoinInformation_r(ctx, &r);
156         }
157
158         r.out.result = W_ERROR_V(werr);
159
160         if (DEBUGLEVEL >= 10) {
161                 NDR_PRINT_OUT_DEBUG(NetGetJoinInformation, &r);
162         }
163
164         return r.out.result;
165 }
166
167 /****************************************************************
168  NetGetJoinableOUs
169 ****************************************************************/
170
171 NET_API_STATUS NetGetJoinableOUs(const char * server_name /* [in] [unique] */,
172                                  const char * domain /* [in] [ref] */,
173                                  const char * account /* [in] [unique] */,
174                                  const char * password /* [in] [unique] */,
175                                  uint32_t *ou_count /* [out] [ref] */,
176                                  const char * **ous /* [out] [ref] */)
177 {
178         struct NetGetJoinableOUs r;
179         struct libnetapi_ctx *ctx = NULL;
180         NET_API_STATUS status;
181         WERROR werr;
182
183         status = libnetapi_getctx(&ctx);
184         if (status != 0) {
185                 return status;
186         }
187
188         /* In parameters */
189         r.in.server_name = server_name;
190         r.in.domain = domain;
191         r.in.account = account;
192         r.in.password = password;
193
194         /* Out parameters */
195         r.out.ou_count = ou_count;
196         r.out.ous = ous;
197
198         if (DEBUGLEVEL >= 10) {
199                 NDR_PRINT_IN_DEBUG(NetGetJoinableOUs, &r);
200         }
201
202         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
203                 werr = NetGetJoinableOUs_l(ctx, &r);
204         } else {
205                 werr = NetGetJoinableOUs_r(ctx, &r);
206         }
207
208         r.out.result = W_ERROR_V(werr);
209
210         if (DEBUGLEVEL >= 10) {
211                 NDR_PRINT_OUT_DEBUG(NetGetJoinableOUs, &r);
212         }
213
214         return r.out.result;
215 }
216
217 /****************************************************************
218  NetServerGetInfo
219 ****************************************************************/
220
221 NET_API_STATUS NetServerGetInfo(const char * server_name /* [in] [unique] */,
222                                 uint32_t level /* [in] */,
223                                 uint8_t **buffer /* [out] [ref] */)
224 {
225         struct NetServerGetInfo r;
226         struct libnetapi_ctx *ctx = NULL;
227         NET_API_STATUS status;
228         WERROR werr;
229
230         status = libnetapi_getctx(&ctx);
231         if (status != 0) {
232                 return status;
233         }
234
235         /* In parameters */
236         r.in.server_name = server_name;
237         r.in.level = level;
238
239         /* Out parameters */
240         r.out.buffer = buffer;
241
242         if (DEBUGLEVEL >= 10) {
243                 NDR_PRINT_IN_DEBUG(NetServerGetInfo, &r);
244         }
245
246         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
247                 werr = NetServerGetInfo_l(ctx, &r);
248         } else {
249                 werr = NetServerGetInfo_r(ctx, &r);
250         }
251
252         r.out.result = W_ERROR_V(werr);
253
254         if (DEBUGLEVEL >= 10) {
255                 NDR_PRINT_OUT_DEBUG(NetServerGetInfo, &r);
256         }
257
258         return r.out.result;
259 }
260
261 /****************************************************************
262  NetServerSetInfo
263 ****************************************************************/
264
265 NET_API_STATUS NetServerSetInfo(const char * server_name /* [in] [unique] */,
266                                 uint32_t level /* [in] */,
267                                 uint8_t *buffer /* [in] [ref] */,
268                                 uint32_t *parm_error /* [out] [ref] */)
269 {
270         struct NetServerSetInfo r;
271         struct libnetapi_ctx *ctx = NULL;
272         NET_API_STATUS status;
273         WERROR werr;
274
275         status = libnetapi_getctx(&ctx);
276         if (status != 0) {
277                 return status;
278         }
279
280         /* In parameters */
281         r.in.server_name = server_name;
282         r.in.level = level;
283         r.in.buffer = buffer;
284
285         /* Out parameters */
286         r.out.parm_error = parm_error;
287
288         if (DEBUGLEVEL >= 10) {
289                 NDR_PRINT_IN_DEBUG(NetServerSetInfo, &r);
290         }
291
292         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
293                 werr = NetServerSetInfo_l(ctx, &r);
294         } else {
295                 werr = NetServerSetInfo_r(ctx, &r);
296         }
297
298         r.out.result = W_ERROR_V(werr);
299
300         if (DEBUGLEVEL >= 10) {
301                 NDR_PRINT_OUT_DEBUG(NetServerSetInfo, &r);
302         }
303
304         return r.out.result;
305 }
306
307 /****************************************************************
308  NetGetDCName
309 ****************************************************************/
310
311 NET_API_STATUS NetGetDCName(const char * server_name /* [in] [unique] */,
312                             const char * domain_name /* [in] [unique] */,
313                             uint8_t **buffer /* [out] [ref] */)
314 {
315         struct NetGetDCName r;
316         struct libnetapi_ctx *ctx = NULL;
317         NET_API_STATUS status;
318         WERROR werr;
319
320         status = libnetapi_getctx(&ctx);
321         if (status != 0) {
322                 return status;
323         }
324
325         /* In parameters */
326         r.in.server_name = server_name;
327         r.in.domain_name = domain_name;
328
329         /* Out parameters */
330         r.out.buffer = buffer;
331
332         if (DEBUGLEVEL >= 10) {
333                 NDR_PRINT_IN_DEBUG(NetGetDCName, &r);
334         }
335
336         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
337                 werr = NetGetDCName_l(ctx, &r);
338         } else {
339                 werr = NetGetDCName_r(ctx, &r);
340         }
341
342         r.out.result = W_ERROR_V(werr);
343
344         if (DEBUGLEVEL >= 10) {
345                 NDR_PRINT_OUT_DEBUG(NetGetDCName, &r);
346         }
347
348         return r.out.result;
349 }
350
351 /****************************************************************
352  NetGetAnyDCName
353 ****************************************************************/
354
355 NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] [unique] */,
356                                const char * domain_name /* [in] [unique] */,
357                                uint8_t **buffer /* [out] [ref] */)
358 {
359         struct NetGetAnyDCName r;
360         struct libnetapi_ctx *ctx = NULL;
361         NET_API_STATUS status;
362         WERROR werr;
363
364         status = libnetapi_getctx(&ctx);
365         if (status != 0) {
366                 return status;
367         }
368
369         /* In parameters */
370         r.in.server_name = server_name;
371         r.in.domain_name = domain_name;
372
373         /* Out parameters */
374         r.out.buffer = buffer;
375
376         if (DEBUGLEVEL >= 10) {
377                 NDR_PRINT_IN_DEBUG(NetGetAnyDCName, &r);
378         }
379
380         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
381                 werr = NetGetAnyDCName_l(ctx, &r);
382         } else {
383                 werr = NetGetAnyDCName_r(ctx, &r);
384         }
385
386         r.out.result = W_ERROR_V(werr);
387
388         if (DEBUGLEVEL >= 10) {
389                 NDR_PRINT_OUT_DEBUG(NetGetAnyDCName, &r);
390         }
391
392         return r.out.result;
393 }
394
395 /****************************************************************
396  DsGetDcName
397 ****************************************************************/
398
399 NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
400                            const char * domain_name /* [in] [ref] */,
401                            struct GUID *domain_guid /* [in] [unique] */,
402                            const char * site_name /* [in] [unique] */,
403                            uint32_t flags /* [in] */,
404                            struct DOMAIN_CONTROLLER_INFO **dc_info /* [out] [ref] */)
405 {
406         struct DsGetDcName r;
407         struct libnetapi_ctx *ctx = NULL;
408         NET_API_STATUS status;
409         WERROR werr;
410
411         status = libnetapi_getctx(&ctx);
412         if (status != 0) {
413                 return status;
414         }
415
416         /* In parameters */
417         r.in.server_name = server_name;
418         r.in.domain_name = domain_name;
419         r.in.domain_guid = domain_guid;
420         r.in.site_name = site_name;
421         r.in.flags = flags;
422
423         /* Out parameters */
424         r.out.dc_info = dc_info;
425
426         if (DEBUGLEVEL >= 10) {
427                 NDR_PRINT_IN_DEBUG(DsGetDcName, &r);
428         }
429
430         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
431                 werr = DsGetDcName_l(ctx, &r);
432         } else {
433                 werr = DsGetDcName_r(ctx, &r);
434         }
435
436         r.out.result = W_ERROR_V(werr);
437
438         if (DEBUGLEVEL >= 10) {
439                 NDR_PRINT_OUT_DEBUG(DsGetDcName, &r);
440         }
441
442         return r.out.result;
443 }
444
445 /****************************************************************
446  NetUserAdd
447 ****************************************************************/
448
449 NET_API_STATUS NetUserAdd(const char * server_name /* [in] [unique] */,
450                           uint32_t level /* [in] */,
451                           uint8_t *buffer /* [in] [ref] */,
452                           uint32_t *parm_error /* [out] [ref] */)
453 {
454         struct NetUserAdd r;
455         struct libnetapi_ctx *ctx = NULL;
456         NET_API_STATUS status;
457         WERROR werr;
458
459         status = libnetapi_getctx(&ctx);
460         if (status != 0) {
461                 return status;
462         }
463
464         /* In parameters */
465         r.in.server_name = server_name;
466         r.in.level = level;
467         r.in.buffer = buffer;
468
469         /* Out parameters */
470         r.out.parm_error = parm_error;
471
472         if (DEBUGLEVEL >= 10) {
473                 NDR_PRINT_IN_DEBUG(NetUserAdd, &r);
474         }
475
476         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
477                 werr = NetUserAdd_l(ctx, &r);
478         } else {
479                 werr = NetUserAdd_r(ctx, &r);
480         }
481
482         r.out.result = W_ERROR_V(werr);
483
484         if (DEBUGLEVEL >= 10) {
485                 NDR_PRINT_OUT_DEBUG(NetUserAdd, &r);
486         }
487
488         return r.out.result;
489 }
490
491 /****************************************************************
492  NetUserDel
493 ****************************************************************/
494
495 NET_API_STATUS NetUserDel(const char * server_name /* [in] [unique] */,
496                           const char * user_name /* [in] [ref] */)
497 {
498         struct NetUserDel r;
499         struct libnetapi_ctx *ctx = NULL;
500         NET_API_STATUS status;
501         WERROR werr;
502
503         status = libnetapi_getctx(&ctx);
504         if (status != 0) {
505                 return status;
506         }
507
508         /* In parameters */
509         r.in.server_name = server_name;
510         r.in.user_name = user_name;
511
512         /* Out parameters */
513
514         if (DEBUGLEVEL >= 10) {
515                 NDR_PRINT_IN_DEBUG(NetUserDel, &r);
516         }
517
518         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
519                 werr = NetUserDel_l(ctx, &r);
520         } else {
521                 werr = NetUserDel_r(ctx, &r);
522         }
523
524         r.out.result = W_ERROR_V(werr);
525
526         if (DEBUGLEVEL >= 10) {
527                 NDR_PRINT_OUT_DEBUG(NetUserDel, &r);
528         }
529
530         return r.out.result;
531 }
532
533 /****************************************************************
534  NetUserEnum
535 ****************************************************************/
536
537 NET_API_STATUS NetUserEnum(const char * server_name /* [in] [unique] */,
538                            uint32_t level /* [in] */,
539                            uint32_t filter /* [in] */,
540                            uint8_t **buffer /* [out] [ref] */,
541                            uint32_t prefmaxlen /* [in] */,
542                            uint32_t *entries_read /* [out] [ref] */,
543                            uint32_t *total_entries /* [out] [ref] */,
544                            uint32_t *resume_handle /* [in,out] [ref] */)
545 {
546         struct NetUserEnum r;
547         struct libnetapi_ctx *ctx = NULL;
548         NET_API_STATUS status;
549         WERROR werr;
550
551         status = libnetapi_getctx(&ctx);
552         if (status != 0) {
553                 return status;
554         }
555
556         /* In parameters */
557         r.in.server_name = server_name;
558         r.in.level = level;
559         r.in.filter = filter;
560         r.in.prefmaxlen = prefmaxlen;
561         r.in.resume_handle = resume_handle;
562
563         /* Out parameters */
564         r.out.buffer = buffer;
565         r.out.entries_read = entries_read;
566         r.out.total_entries = total_entries;
567         r.out.resume_handle = resume_handle;
568
569         if (DEBUGLEVEL >= 10) {
570                 NDR_PRINT_IN_DEBUG(NetUserEnum, &r);
571         }
572
573         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
574                 werr = NetUserEnum_l(ctx, &r);
575         } else {
576                 werr = NetUserEnum_r(ctx, &r);
577         }
578
579         r.out.result = W_ERROR_V(werr);
580
581         if (DEBUGLEVEL >= 10) {
582                 NDR_PRINT_OUT_DEBUG(NetUserEnum, &r);
583         }
584
585         return r.out.result;
586 }
587
588 /****************************************************************
589  NetUserChangePassword
590 ****************************************************************/
591
592 NET_API_STATUS NetUserChangePassword(const char * domain_name /* [in] */,
593                                      const char * user_name /* [in] */,
594                                      const char * old_password /* [in] */,
595                                      const char * new_password /* [in] */)
596 {
597         struct NetUserChangePassword r;
598         struct libnetapi_ctx *ctx = NULL;
599         NET_API_STATUS status;
600         WERROR werr;
601
602         status = libnetapi_getctx(&ctx);
603         if (status != 0) {
604                 return status;
605         }
606
607         /* In parameters */
608         r.in.domain_name = domain_name;
609         r.in.user_name = user_name;
610         r.in.old_password = old_password;
611         r.in.new_password = new_password;
612
613         /* Out parameters */
614
615         if (DEBUGLEVEL >= 10) {
616                 NDR_PRINT_IN_DEBUG(NetUserChangePassword, &r);
617         }
618
619         if (LIBNETAPI_LOCAL_SERVER(domain_name)) {
620                 werr = NetUserChangePassword_l(ctx, &r);
621         } else {
622                 werr = NetUserChangePassword_r(ctx, &r);
623         }
624
625         r.out.result = W_ERROR_V(werr);
626
627         if (DEBUGLEVEL >= 10) {
628                 NDR_PRINT_OUT_DEBUG(NetUserChangePassword, &r);
629         }
630
631         return r.out.result;
632 }
633
634 /****************************************************************
635  NetQueryDisplayInformation
636 ****************************************************************/
637
638 NET_API_STATUS NetQueryDisplayInformation(const char * server_name /* [in] [unique] */,
639                                           uint32_t level /* [in] */,
640                                           uint32_t idx /* [in] */,
641                                           uint32_t entries_requested /* [in] */,
642                                           uint32_t prefmaxlen /* [in] */,
643                                           uint32_t *entries_read /* [out] [ref] */,
644                                           void **buffer /* [out] [noprint,ref] */)
645 {
646         struct NetQueryDisplayInformation r;
647         struct libnetapi_ctx *ctx = NULL;
648         NET_API_STATUS status;
649         WERROR werr;
650
651         status = libnetapi_getctx(&ctx);
652         if (status != 0) {
653                 return status;
654         }
655
656         /* In parameters */
657         r.in.server_name = server_name;
658         r.in.level = level;
659         r.in.idx = idx;
660         r.in.entries_requested = entries_requested;
661         r.in.prefmaxlen = prefmaxlen;
662
663         /* Out parameters */
664         r.out.entries_read = entries_read;
665         r.out.buffer = buffer;
666
667         if (DEBUGLEVEL >= 10) {
668                 NDR_PRINT_IN_DEBUG(NetQueryDisplayInformation, &r);
669         }
670
671         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
672                 werr = NetQueryDisplayInformation_l(ctx, &r);
673         } else {
674                 werr = NetQueryDisplayInformation_r(ctx, &r);
675         }
676
677         r.out.result = W_ERROR_V(werr);
678
679         if (DEBUGLEVEL >= 10) {
680                 NDR_PRINT_OUT_DEBUG(NetQueryDisplayInformation, &r);
681         }
682
683         return r.out.result;
684 }
685
686 /****************************************************************
687  NetGroupAdd
688 ****************************************************************/
689
690 NET_API_STATUS NetGroupAdd(const char * server_name /* [in] */,
691                            uint32_t level /* [in] */,
692                            uint8_t *buf /* [in] [ref] */,
693                            uint32_t *parm_err /* [out] [ref] */)
694 {
695         struct NetGroupAdd r;
696         struct libnetapi_ctx *ctx = NULL;
697         NET_API_STATUS status;
698         WERROR werr;
699
700         status = libnetapi_getctx(&ctx);
701         if (status != 0) {
702                 return status;
703         }
704
705         /* In parameters */
706         r.in.server_name = server_name;
707         r.in.level = level;
708         r.in.buf = buf;
709
710         /* Out parameters */
711         r.out.parm_err = parm_err;
712
713         if (DEBUGLEVEL >= 10) {
714                 NDR_PRINT_IN_DEBUG(NetGroupAdd, &r);
715         }
716
717         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
718                 werr = NetGroupAdd_l(ctx, &r);
719         } else {
720                 werr = NetGroupAdd_r(ctx, &r);
721         }
722
723         r.out.result = W_ERROR_V(werr);
724
725         if (DEBUGLEVEL >= 10) {
726                 NDR_PRINT_OUT_DEBUG(NetGroupAdd, &r);
727         }
728
729         return r.out.result;
730 }
731
732 /****************************************************************
733  NetGroupDel
734 ****************************************************************/
735
736 NET_API_STATUS NetGroupDel(const char * server_name /* [in] */,
737                            const char * group_name /* [in] */)
738 {
739         struct NetGroupDel r;
740         struct libnetapi_ctx *ctx = NULL;
741         NET_API_STATUS status;
742         WERROR werr;
743
744         status = libnetapi_getctx(&ctx);
745         if (status != 0) {
746                 return status;
747         }
748
749         /* In parameters */
750         r.in.server_name = server_name;
751         r.in.group_name = group_name;
752
753         /* Out parameters */
754
755         if (DEBUGLEVEL >= 10) {
756                 NDR_PRINT_IN_DEBUG(NetGroupDel, &r);
757         }
758
759         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
760                 werr = NetGroupDel_l(ctx, &r);
761         } else {
762                 werr = NetGroupDel_r(ctx, &r);
763         }
764
765         r.out.result = W_ERROR_V(werr);
766
767         if (DEBUGLEVEL >= 10) {
768                 NDR_PRINT_OUT_DEBUG(NetGroupDel, &r);
769         }
770
771         return r.out.result;
772 }
773
774 /****************************************************************
775  NetGroupEnum
776 ****************************************************************/
777
778 NET_API_STATUS NetGroupEnum(const char * server_name /* [in] */,
779                             uint32_t level /* [in] */,
780                             uint8_t **buffer /* [out] [ref] */,
781                             uint32_t prefmaxlen /* [in] */,
782                             uint32_t *entries_read /* [out] [ref] */,
783                             uint32_t *total_entries /* [out] [ref] */,
784                             uint32_t *resume_handle /* [in,out] [ref] */)
785 {
786         struct NetGroupEnum r;
787         struct libnetapi_ctx *ctx = NULL;
788         NET_API_STATUS status;
789         WERROR werr;
790
791         status = libnetapi_getctx(&ctx);
792         if (status != 0) {
793                 return status;
794         }
795
796         /* In parameters */
797         r.in.server_name = server_name;
798         r.in.level = level;
799         r.in.prefmaxlen = prefmaxlen;
800         r.in.resume_handle = resume_handle;
801
802         /* Out parameters */
803         r.out.buffer = buffer;
804         r.out.entries_read = entries_read;
805         r.out.total_entries = total_entries;
806         r.out.resume_handle = resume_handle;
807
808         if (DEBUGLEVEL >= 10) {
809                 NDR_PRINT_IN_DEBUG(NetGroupEnum, &r);
810         }
811
812         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
813                 werr = NetGroupEnum_l(ctx, &r);
814         } else {
815                 werr = NetGroupEnum_r(ctx, &r);
816         }
817
818         r.out.result = W_ERROR_V(werr);
819
820         if (DEBUGLEVEL >= 10) {
821                 NDR_PRINT_OUT_DEBUG(NetGroupEnum, &r);
822         }
823
824         return r.out.result;
825 }
826
827 /****************************************************************
828  NetGroupSetInfo
829 ****************************************************************/
830
831 NET_API_STATUS NetGroupSetInfo(const char * server_name /* [in] */,
832                                const char * group_name /* [in] */,
833                                uint32_t level /* [in] */,
834                                uint8_t *buf /* [in] [ref] */,
835                                uint32_t *parm_err /* [out] [ref] */)
836 {
837         struct NetGroupSetInfo r;
838         struct libnetapi_ctx *ctx = NULL;
839         NET_API_STATUS status;
840         WERROR werr;
841
842         status = libnetapi_getctx(&ctx);
843         if (status != 0) {
844                 return status;
845         }
846
847         /* In parameters */
848         r.in.server_name = server_name;
849         r.in.group_name = group_name;
850         r.in.level = level;
851         r.in.buf = buf;
852
853         /* Out parameters */
854         r.out.parm_err = parm_err;
855
856         if (DEBUGLEVEL >= 10) {
857                 NDR_PRINT_IN_DEBUG(NetGroupSetInfo, &r);
858         }
859
860         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
861                 werr = NetGroupSetInfo_l(ctx, &r);
862         } else {
863                 werr = NetGroupSetInfo_r(ctx, &r);
864         }
865
866         r.out.result = W_ERROR_V(werr);
867
868         if (DEBUGLEVEL >= 10) {
869                 NDR_PRINT_OUT_DEBUG(NetGroupSetInfo, &r);
870         }
871
872         return r.out.result;
873 }
874
875 /****************************************************************
876  NetGroupGetInfo
877 ****************************************************************/
878
879 NET_API_STATUS NetGroupGetInfo(const char * server_name /* [in] */,
880                                const char * group_name /* [in] */,
881                                uint32_t level /* [in] */,
882                                uint8_t **buf /* [out] [ref] */)
883 {
884         struct NetGroupGetInfo r;
885         struct libnetapi_ctx *ctx = NULL;
886         NET_API_STATUS status;
887         WERROR werr;
888
889         status = libnetapi_getctx(&ctx);
890         if (status != 0) {
891                 return status;
892         }
893
894         /* In parameters */
895         r.in.server_name = server_name;
896         r.in.group_name = group_name;
897         r.in.level = level;
898
899         /* Out parameters */
900         r.out.buf = buf;
901
902         if (DEBUGLEVEL >= 10) {
903                 NDR_PRINT_IN_DEBUG(NetGroupGetInfo, &r);
904         }
905
906         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
907                 werr = NetGroupGetInfo_l(ctx, &r);
908         } else {
909                 werr = NetGroupGetInfo_r(ctx, &r);
910         }
911
912         r.out.result = W_ERROR_V(werr);
913
914         if (DEBUGLEVEL >= 10) {
915                 NDR_PRINT_OUT_DEBUG(NetGroupGetInfo, &r);
916         }
917
918         return r.out.result;
919 }
920
921 /****************************************************************
922  NetGroupAddUser
923 ****************************************************************/
924
925 NET_API_STATUS NetGroupAddUser(const char * server_name /* [in] */,
926                                const char * group_name /* [in] */,
927                                const char * user_name /* [in] */)
928 {
929         struct NetGroupAddUser r;
930         struct libnetapi_ctx *ctx = NULL;
931         NET_API_STATUS status;
932         WERROR werr;
933
934         status = libnetapi_getctx(&ctx);
935         if (status != 0) {
936                 return status;
937         }
938
939         /* In parameters */
940         r.in.server_name = server_name;
941         r.in.group_name = group_name;
942         r.in.user_name = user_name;
943
944         /* Out parameters */
945
946         if (DEBUGLEVEL >= 10) {
947                 NDR_PRINT_IN_DEBUG(NetGroupAddUser, &r);
948         }
949
950         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
951                 werr = NetGroupAddUser_l(ctx, &r);
952         } else {
953                 werr = NetGroupAddUser_r(ctx, &r);
954         }
955
956         r.out.result = W_ERROR_V(werr);
957
958         if (DEBUGLEVEL >= 10) {
959                 NDR_PRINT_OUT_DEBUG(NetGroupAddUser, &r);
960         }
961
962         return r.out.result;
963 }
964
965 /****************************************************************
966  NetGroupDelUser
967 ****************************************************************/
968
969 NET_API_STATUS NetGroupDelUser(const char * server_name /* [in] */,
970                                const char * group_name /* [in] */,
971                                const char * user_name /* [in] */)
972 {
973         struct NetGroupDelUser r;
974         struct libnetapi_ctx *ctx = NULL;
975         NET_API_STATUS status;
976         WERROR werr;
977
978         status = libnetapi_getctx(&ctx);
979         if (status != 0) {
980                 return status;
981         }
982
983         /* In parameters */
984         r.in.server_name = server_name;
985         r.in.group_name = group_name;
986         r.in.user_name = user_name;
987
988         /* Out parameters */
989
990         if (DEBUGLEVEL >= 10) {
991                 NDR_PRINT_IN_DEBUG(NetGroupDelUser, &r);
992         }
993
994         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
995                 werr = NetGroupDelUser_l(ctx, &r);
996         } else {
997                 werr = NetGroupDelUser_r(ctx, &r);
998         }
999
1000         r.out.result = W_ERROR_V(werr);
1001
1002         if (DEBUGLEVEL >= 10) {
1003                 NDR_PRINT_OUT_DEBUG(NetGroupDelUser, &r);
1004         }
1005
1006         return r.out.result;
1007 }
1008
1009 /****************************************************************
1010  NetLocalGroupAdd
1011 ****************************************************************/
1012
1013 NET_API_STATUS NetLocalGroupAdd(const char * server_name /* [in] */,
1014                                 uint32_t level /* [in] */,
1015                                 uint8_t *buf /* [in] [ref] */,
1016                                 uint32_t *parm_err /* [out] [ref] */)
1017 {
1018         struct NetLocalGroupAdd r;
1019         struct libnetapi_ctx *ctx = NULL;
1020         NET_API_STATUS status;
1021         WERROR werr;
1022
1023         status = libnetapi_getctx(&ctx);
1024         if (status != 0) {
1025                 return status;
1026         }
1027
1028         /* In parameters */
1029         r.in.server_name = server_name;
1030         r.in.level = level;
1031         r.in.buf = buf;
1032
1033         /* Out parameters */
1034         r.out.parm_err = parm_err;
1035
1036         if (DEBUGLEVEL >= 10) {
1037                 NDR_PRINT_IN_DEBUG(NetLocalGroupAdd, &r);
1038         }
1039
1040         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1041                 werr = NetLocalGroupAdd_l(ctx, &r);
1042         } else {
1043                 werr = NetLocalGroupAdd_r(ctx, &r);
1044         }
1045
1046         r.out.result = W_ERROR_V(werr);
1047
1048         if (DEBUGLEVEL >= 10) {
1049                 NDR_PRINT_OUT_DEBUG(NetLocalGroupAdd, &r);
1050         }
1051
1052         return r.out.result;
1053 }
1054
1055 /****************************************************************
1056  NetLocalGroupDel
1057 ****************************************************************/
1058
1059 NET_API_STATUS NetLocalGroupDel(const char * server_name /* [in] */,
1060                                 const char * group_name /* [in] */)
1061 {
1062         struct NetLocalGroupDel r;
1063         struct libnetapi_ctx *ctx = NULL;
1064         NET_API_STATUS status;
1065         WERROR werr;
1066
1067         status = libnetapi_getctx(&ctx);
1068         if (status != 0) {
1069                 return status;
1070         }
1071
1072         /* In parameters */
1073         r.in.server_name = server_name;
1074         r.in.group_name = group_name;
1075
1076         /* Out parameters */
1077
1078         if (DEBUGLEVEL >= 10) {
1079                 NDR_PRINT_IN_DEBUG(NetLocalGroupDel, &r);
1080         }
1081
1082         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1083                 werr = NetLocalGroupDel_l(ctx, &r);
1084         } else {
1085                 werr = NetLocalGroupDel_r(ctx, &r);
1086         }
1087
1088         r.out.result = W_ERROR_V(werr);
1089
1090         if (DEBUGLEVEL >= 10) {
1091                 NDR_PRINT_OUT_DEBUG(NetLocalGroupDel, &r);
1092         }
1093
1094         return r.out.result;
1095 }
1096
1097 /****************************************************************
1098  NetLocalGroupGetInfo
1099 ****************************************************************/
1100
1101 NET_API_STATUS NetLocalGroupGetInfo(const char * server_name /* [in] */,
1102                                     const char * group_name /* [in] */,
1103                                     uint32_t level /* [in] */,
1104                                     uint8_t **buf /* [out] [ref] */)
1105 {
1106         struct NetLocalGroupGetInfo r;
1107         struct libnetapi_ctx *ctx = NULL;
1108         NET_API_STATUS status;
1109         WERROR werr;
1110
1111         status = libnetapi_getctx(&ctx);
1112         if (status != 0) {
1113                 return status;
1114         }
1115
1116         /* In parameters */
1117         r.in.server_name = server_name;
1118         r.in.group_name = group_name;
1119         r.in.level = level;
1120
1121         /* Out parameters */
1122         r.out.buf = buf;
1123
1124         if (DEBUGLEVEL >= 10) {
1125                 NDR_PRINT_IN_DEBUG(NetLocalGroupGetInfo, &r);
1126         }
1127
1128         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1129                 werr = NetLocalGroupGetInfo_l(ctx, &r);
1130         } else {
1131                 werr = NetLocalGroupGetInfo_r(ctx, &r);
1132         }
1133
1134         r.out.result = W_ERROR_V(werr);
1135
1136         if (DEBUGLEVEL >= 10) {
1137                 NDR_PRINT_OUT_DEBUG(NetLocalGroupGetInfo, &r);
1138         }
1139
1140         return r.out.result;
1141 }
1142
1143 /****************************************************************
1144  NetLocalGroupSetInfo
1145 ****************************************************************/
1146
1147 NET_API_STATUS NetLocalGroupSetInfo(const char * server_name /* [in] */,
1148                                     const char * group_name /* [in] */,
1149                                     uint32_t level /* [in] */,
1150                                     uint8_t *buf /* [in] [ref] */,
1151                                     uint32_t *parm_err /* [out] [ref] */)
1152 {
1153         struct NetLocalGroupSetInfo r;
1154         struct libnetapi_ctx *ctx = NULL;
1155         NET_API_STATUS status;
1156         WERROR werr;
1157
1158         status = libnetapi_getctx(&ctx);
1159         if (status != 0) {
1160                 return status;
1161         }
1162
1163         /* In parameters */
1164         r.in.server_name = server_name;
1165         r.in.group_name = group_name;
1166         r.in.level = level;
1167         r.in.buf = buf;
1168
1169         /* Out parameters */
1170         r.out.parm_err = parm_err;
1171
1172         if (DEBUGLEVEL >= 10) {
1173                 NDR_PRINT_IN_DEBUG(NetLocalGroupSetInfo, &r);
1174         }
1175
1176         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1177                 werr = NetLocalGroupSetInfo_l(ctx, &r);
1178         } else {
1179                 werr = NetLocalGroupSetInfo_r(ctx, &r);
1180         }
1181
1182         r.out.result = W_ERROR_V(werr);
1183
1184         if (DEBUGLEVEL >= 10) {
1185                 NDR_PRINT_OUT_DEBUG(NetLocalGroupSetInfo, &r);
1186         }
1187
1188         return r.out.result;
1189 }
1190
1191 /****************************************************************
1192  NetRemoteTOD
1193 ****************************************************************/
1194
1195 NET_API_STATUS NetRemoteTOD(const char * server_name /* [in] */,
1196                             uint8_t **buf /* [out] [ref] */)
1197 {
1198         struct NetRemoteTOD r;
1199         struct libnetapi_ctx *ctx = NULL;
1200         NET_API_STATUS status;
1201         WERROR werr;
1202
1203         status = libnetapi_getctx(&ctx);
1204         if (status != 0) {
1205                 return status;
1206         }
1207
1208         /* In parameters */
1209         r.in.server_name = server_name;
1210
1211         /* Out parameters */
1212         r.out.buf = buf;
1213
1214         if (DEBUGLEVEL >= 10) {
1215                 NDR_PRINT_IN_DEBUG(NetRemoteTOD, &r);
1216         }
1217
1218         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1219                 werr = NetRemoteTOD_l(ctx, &r);
1220         } else {
1221                 werr = NetRemoteTOD_r(ctx, &r);
1222         }
1223
1224         r.out.result = W_ERROR_V(werr);
1225
1226         if (DEBUGLEVEL >= 10) {
1227                 NDR_PRINT_OUT_DEBUG(NetRemoteTOD, &r);
1228         }
1229
1230         return r.out.result;
1231 }
1232