e8c69ae837f914343e11389677847fc3cb18da76
[metze/samba/wip.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  NetRenameMachineInDomain
219 ****************************************************************/
220
221 NET_API_STATUS NetRenameMachineInDomain(const char * server_name /* [in] */,
222                                         const char * new_machine_name /* [in] */,
223                                         const char * account /* [in] */,
224                                         const char * password /* [in] */,
225                                         uint32_t rename_options /* [in] */)
226 {
227         struct NetRenameMachineInDomain r;
228         struct libnetapi_ctx *ctx = NULL;
229         NET_API_STATUS status;
230         WERROR werr;
231
232         status = libnetapi_getctx(&ctx);
233         if (status != 0) {
234                 return status;
235         }
236
237         /* In parameters */
238         r.in.server_name = server_name;
239         r.in.new_machine_name = new_machine_name;
240         r.in.account = account;
241         r.in.password = password;
242         r.in.rename_options = rename_options;
243
244         /* Out parameters */
245
246         if (DEBUGLEVEL >= 10) {
247                 NDR_PRINT_IN_DEBUG(NetRenameMachineInDomain, &r);
248         }
249
250         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
251                 werr = NetRenameMachineInDomain_l(ctx, &r);
252         } else {
253                 werr = NetRenameMachineInDomain_r(ctx, &r);
254         }
255
256         r.out.result = W_ERROR_V(werr);
257
258         if (DEBUGLEVEL >= 10) {
259                 NDR_PRINT_OUT_DEBUG(NetRenameMachineInDomain, &r);
260         }
261
262         return r.out.result;
263 }
264
265 /****************************************************************
266  NetServerGetInfo
267 ****************************************************************/
268
269 NET_API_STATUS NetServerGetInfo(const char * server_name /* [in] [unique] */,
270                                 uint32_t level /* [in] */,
271                                 uint8_t **buffer /* [out] [ref] */)
272 {
273         struct NetServerGetInfo r;
274         struct libnetapi_ctx *ctx = NULL;
275         NET_API_STATUS status;
276         WERROR werr;
277
278         status = libnetapi_getctx(&ctx);
279         if (status != 0) {
280                 return status;
281         }
282
283         /* In parameters */
284         r.in.server_name = server_name;
285         r.in.level = level;
286
287         /* Out parameters */
288         r.out.buffer = buffer;
289
290         if (DEBUGLEVEL >= 10) {
291                 NDR_PRINT_IN_DEBUG(NetServerGetInfo, &r);
292         }
293
294         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
295                 werr = NetServerGetInfo_l(ctx, &r);
296         } else {
297                 werr = NetServerGetInfo_r(ctx, &r);
298         }
299
300         r.out.result = W_ERROR_V(werr);
301
302         if (DEBUGLEVEL >= 10) {
303                 NDR_PRINT_OUT_DEBUG(NetServerGetInfo, &r);
304         }
305
306         return r.out.result;
307 }
308
309 /****************************************************************
310  NetServerSetInfo
311 ****************************************************************/
312
313 NET_API_STATUS NetServerSetInfo(const char * server_name /* [in] [unique] */,
314                                 uint32_t level /* [in] */,
315                                 uint8_t *buffer /* [in] [ref] */,
316                                 uint32_t *parm_error /* [out] [ref] */)
317 {
318         struct NetServerSetInfo r;
319         struct libnetapi_ctx *ctx = NULL;
320         NET_API_STATUS status;
321         WERROR werr;
322
323         status = libnetapi_getctx(&ctx);
324         if (status != 0) {
325                 return status;
326         }
327
328         /* In parameters */
329         r.in.server_name = server_name;
330         r.in.level = level;
331         r.in.buffer = buffer;
332
333         /* Out parameters */
334         r.out.parm_error = parm_error;
335
336         if (DEBUGLEVEL >= 10) {
337                 NDR_PRINT_IN_DEBUG(NetServerSetInfo, &r);
338         }
339
340         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
341                 werr = NetServerSetInfo_l(ctx, &r);
342         } else {
343                 werr = NetServerSetInfo_r(ctx, &r);
344         }
345
346         r.out.result = W_ERROR_V(werr);
347
348         if (DEBUGLEVEL >= 10) {
349                 NDR_PRINT_OUT_DEBUG(NetServerSetInfo, &r);
350         }
351
352         return r.out.result;
353 }
354
355 /****************************************************************
356  NetGetDCName
357 ****************************************************************/
358
359 NET_API_STATUS NetGetDCName(const char * server_name /* [in] [unique] */,
360                             const char * domain_name /* [in] [unique] */,
361                             uint8_t **buffer /* [out] [ref] */)
362 {
363         struct NetGetDCName r;
364         struct libnetapi_ctx *ctx = NULL;
365         NET_API_STATUS status;
366         WERROR werr;
367
368         status = libnetapi_getctx(&ctx);
369         if (status != 0) {
370                 return status;
371         }
372
373         /* In parameters */
374         r.in.server_name = server_name;
375         r.in.domain_name = domain_name;
376
377         /* Out parameters */
378         r.out.buffer = buffer;
379
380         if (DEBUGLEVEL >= 10) {
381                 NDR_PRINT_IN_DEBUG(NetGetDCName, &r);
382         }
383
384         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
385                 werr = NetGetDCName_l(ctx, &r);
386         } else {
387                 werr = NetGetDCName_r(ctx, &r);
388         }
389
390         r.out.result = W_ERROR_V(werr);
391
392         if (DEBUGLEVEL >= 10) {
393                 NDR_PRINT_OUT_DEBUG(NetGetDCName, &r);
394         }
395
396         return r.out.result;
397 }
398
399 /****************************************************************
400  NetGetAnyDCName
401 ****************************************************************/
402
403 NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] [unique] */,
404                                const char * domain_name /* [in] [unique] */,
405                                uint8_t **buffer /* [out] [ref] */)
406 {
407         struct NetGetAnyDCName r;
408         struct libnetapi_ctx *ctx = NULL;
409         NET_API_STATUS status;
410         WERROR werr;
411
412         status = libnetapi_getctx(&ctx);
413         if (status != 0) {
414                 return status;
415         }
416
417         /* In parameters */
418         r.in.server_name = server_name;
419         r.in.domain_name = domain_name;
420
421         /* Out parameters */
422         r.out.buffer = buffer;
423
424         if (DEBUGLEVEL >= 10) {
425                 NDR_PRINT_IN_DEBUG(NetGetAnyDCName, &r);
426         }
427
428         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
429                 werr = NetGetAnyDCName_l(ctx, &r);
430         } else {
431                 werr = NetGetAnyDCName_r(ctx, &r);
432         }
433
434         r.out.result = W_ERROR_V(werr);
435
436         if (DEBUGLEVEL >= 10) {
437                 NDR_PRINT_OUT_DEBUG(NetGetAnyDCName, &r);
438         }
439
440         return r.out.result;
441 }
442
443 /****************************************************************
444  DsGetDcName
445 ****************************************************************/
446
447 NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
448                            const char * domain_name /* [in] [ref] */,
449                            struct GUID *domain_guid /* [in] [unique] */,
450                            const char * site_name /* [in] [unique] */,
451                            uint32_t flags /* [in] */,
452                            struct DOMAIN_CONTROLLER_INFO **dc_info /* [out] [ref] */)
453 {
454         struct DsGetDcName 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.domain_name = domain_name;
467         r.in.domain_guid = domain_guid;
468         r.in.site_name = site_name;
469         r.in.flags = flags;
470
471         /* Out parameters */
472         r.out.dc_info = dc_info;
473
474         if (DEBUGLEVEL >= 10) {
475                 NDR_PRINT_IN_DEBUG(DsGetDcName, &r);
476         }
477
478         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
479                 werr = DsGetDcName_l(ctx, &r);
480         } else {
481                 werr = DsGetDcName_r(ctx, &r);
482         }
483
484         r.out.result = W_ERROR_V(werr);
485
486         if (DEBUGLEVEL >= 10) {
487                 NDR_PRINT_OUT_DEBUG(DsGetDcName, &r);
488         }
489
490         return r.out.result;
491 }
492
493 /****************************************************************
494  NetUserAdd
495 ****************************************************************/
496
497 NET_API_STATUS NetUserAdd(const char * server_name /* [in] [unique] */,
498                           uint32_t level /* [in] */,
499                           uint8_t *buffer /* [in] [ref] */,
500                           uint32_t *parm_error /* [out] [ref] */)
501 {
502         struct NetUserAdd r;
503         struct libnetapi_ctx *ctx = NULL;
504         NET_API_STATUS status;
505         WERROR werr;
506
507         status = libnetapi_getctx(&ctx);
508         if (status != 0) {
509                 return status;
510         }
511
512         /* In parameters */
513         r.in.server_name = server_name;
514         r.in.level = level;
515         r.in.buffer = buffer;
516
517         /* Out parameters */
518         r.out.parm_error = parm_error;
519
520         if (DEBUGLEVEL >= 10) {
521                 NDR_PRINT_IN_DEBUG(NetUserAdd, &r);
522         }
523
524         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
525                 werr = NetUserAdd_l(ctx, &r);
526         } else {
527                 werr = NetUserAdd_r(ctx, &r);
528         }
529
530         r.out.result = W_ERROR_V(werr);
531
532         if (DEBUGLEVEL >= 10) {
533                 NDR_PRINT_OUT_DEBUG(NetUserAdd, &r);
534         }
535
536         return r.out.result;
537 }
538
539 /****************************************************************
540  NetUserDel
541 ****************************************************************/
542
543 NET_API_STATUS NetUserDel(const char * server_name /* [in] [unique] */,
544                           const char * user_name /* [in] [ref] */)
545 {
546         struct NetUserDel 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.user_name = user_name;
559
560         /* Out parameters */
561
562         if (DEBUGLEVEL >= 10) {
563                 NDR_PRINT_IN_DEBUG(NetUserDel, &r);
564         }
565
566         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
567                 werr = NetUserDel_l(ctx, &r);
568         } else {
569                 werr = NetUserDel_r(ctx, &r);
570         }
571
572         r.out.result = W_ERROR_V(werr);
573
574         if (DEBUGLEVEL >= 10) {
575                 NDR_PRINT_OUT_DEBUG(NetUserDel, &r);
576         }
577
578         return r.out.result;
579 }
580
581 /****************************************************************
582  NetUserEnum
583 ****************************************************************/
584
585 NET_API_STATUS NetUserEnum(const char * server_name /* [in] [unique] */,
586                            uint32_t level /* [in] */,
587                            uint32_t filter /* [in] */,
588                            uint8_t **buffer /* [out] [ref] */,
589                            uint32_t prefmaxlen /* [in] */,
590                            uint32_t *entries_read /* [out] [ref] */,
591                            uint32_t *total_entries /* [out] [ref] */,
592                            uint32_t *resume_handle /* [in,out] [ref] */)
593 {
594         struct NetUserEnum r;
595         struct libnetapi_ctx *ctx = NULL;
596         NET_API_STATUS status;
597         WERROR werr;
598
599         status = libnetapi_getctx(&ctx);
600         if (status != 0) {
601                 return status;
602         }
603
604         /* In parameters */
605         r.in.server_name = server_name;
606         r.in.level = level;
607         r.in.filter = filter;
608         r.in.prefmaxlen = prefmaxlen;
609         r.in.resume_handle = resume_handle;
610
611         /* Out parameters */
612         r.out.buffer = buffer;
613         r.out.entries_read = entries_read;
614         r.out.total_entries = total_entries;
615         r.out.resume_handle = resume_handle;
616
617         if (DEBUGLEVEL >= 10) {
618                 NDR_PRINT_IN_DEBUG(NetUserEnum, &r);
619         }
620
621         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
622                 werr = NetUserEnum_l(ctx, &r);
623         } else {
624                 werr = NetUserEnum_r(ctx, &r);
625         }
626
627         r.out.result = W_ERROR_V(werr);
628
629         if (DEBUGLEVEL >= 10) {
630                 NDR_PRINT_OUT_DEBUG(NetUserEnum, &r);
631         }
632
633         return r.out.result;
634 }
635
636 /****************************************************************
637  NetUserChangePassword
638 ****************************************************************/
639
640 NET_API_STATUS NetUserChangePassword(const char * domain_name /* [in] */,
641                                      const char * user_name /* [in] */,
642                                      const char * old_password /* [in] */,
643                                      const char * new_password /* [in] */)
644 {
645         struct NetUserChangePassword r;
646         struct libnetapi_ctx *ctx = NULL;
647         NET_API_STATUS status;
648         WERROR werr;
649
650         status = libnetapi_getctx(&ctx);
651         if (status != 0) {
652                 return status;
653         }
654
655         /* In parameters */
656         r.in.domain_name = domain_name;
657         r.in.user_name = user_name;
658         r.in.old_password = old_password;
659         r.in.new_password = new_password;
660
661         /* Out parameters */
662
663         if (DEBUGLEVEL >= 10) {
664                 NDR_PRINT_IN_DEBUG(NetUserChangePassword, &r);
665         }
666
667         if (LIBNETAPI_LOCAL_SERVER(domain_name)) {
668                 werr = NetUserChangePassword_l(ctx, &r);
669         } else {
670                 werr = NetUserChangePassword_r(ctx, &r);
671         }
672
673         r.out.result = W_ERROR_V(werr);
674
675         if (DEBUGLEVEL >= 10) {
676                 NDR_PRINT_OUT_DEBUG(NetUserChangePassword, &r);
677         }
678
679         return r.out.result;
680 }
681
682 /****************************************************************
683  NetUserGetInfo
684 ****************************************************************/
685
686 NET_API_STATUS NetUserGetInfo(const char * server_name /* [in] */,
687                               const char * user_name /* [in] */,
688                               uint32_t level /* [in] */,
689                               uint8_t **buffer /* [out] [ref] */)
690 {
691         struct NetUserGetInfo r;
692         struct libnetapi_ctx *ctx = NULL;
693         NET_API_STATUS status;
694         WERROR werr;
695
696         status = libnetapi_getctx(&ctx);
697         if (status != 0) {
698                 return status;
699         }
700
701         /* In parameters */
702         r.in.server_name = server_name;
703         r.in.user_name = user_name;
704         r.in.level = level;
705
706         /* Out parameters */
707         r.out.buffer = buffer;
708
709         if (DEBUGLEVEL >= 10) {
710                 NDR_PRINT_IN_DEBUG(NetUserGetInfo, &r);
711         }
712
713         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
714                 werr = NetUserGetInfo_l(ctx, &r);
715         } else {
716                 werr = NetUserGetInfo_r(ctx, &r);
717         }
718
719         r.out.result = W_ERROR_V(werr);
720
721         if (DEBUGLEVEL >= 10) {
722                 NDR_PRINT_OUT_DEBUG(NetUserGetInfo, &r);
723         }
724
725         return r.out.result;
726 }
727
728 /****************************************************************
729  NetUserSetInfo
730 ****************************************************************/
731
732 NET_API_STATUS NetUserSetInfo(const char * server_name /* [in] */,
733                               const char * user_name /* [in] */,
734                               uint32_t level /* [in] */,
735                               uint8_t *buffer /* [in] [ref] */,
736                               uint32_t *parm_err /* [out] [ref] */)
737 {
738         struct NetUserSetInfo r;
739         struct libnetapi_ctx *ctx = NULL;
740         NET_API_STATUS status;
741         WERROR werr;
742
743         status = libnetapi_getctx(&ctx);
744         if (status != 0) {
745                 return status;
746         }
747
748         /* In parameters */
749         r.in.server_name = server_name;
750         r.in.user_name = user_name;
751         r.in.level = level;
752         r.in.buffer = buffer;
753
754         /* Out parameters */
755         r.out.parm_err = parm_err;
756
757         if (DEBUGLEVEL >= 10) {
758                 NDR_PRINT_IN_DEBUG(NetUserSetInfo, &r);
759         }
760
761         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
762                 werr = NetUserSetInfo_l(ctx, &r);
763         } else {
764                 werr = NetUserSetInfo_r(ctx, &r);
765         }
766
767         r.out.result = W_ERROR_V(werr);
768
769         if (DEBUGLEVEL >= 10) {
770                 NDR_PRINT_OUT_DEBUG(NetUserSetInfo, &r);
771         }
772
773         return r.out.result;
774 }
775
776 /****************************************************************
777  NetUserGetGroups
778 ****************************************************************/
779
780 NET_API_STATUS NetUserGetGroups(const char * server_name /* [in] */,
781                                 const char * user_name /* [in] */,
782                                 uint32_t level /* [in] */,
783                                 uint8_t **buffer /* [out] [ref] */,
784                                 uint32_t prefmaxlen /* [in] */,
785                                 uint32_t *entries_read /* [out] [ref] */,
786                                 uint32_t *total_entries /* [out] [ref] */)
787 {
788         struct NetUserGetGroups r;
789         struct libnetapi_ctx *ctx = NULL;
790         NET_API_STATUS status;
791         WERROR werr;
792
793         status = libnetapi_getctx(&ctx);
794         if (status != 0) {
795                 return status;
796         }
797
798         /* In parameters */
799         r.in.server_name = server_name;
800         r.in.user_name = user_name;
801         r.in.level = level;
802         r.in.prefmaxlen = prefmaxlen;
803
804         /* Out parameters */
805         r.out.buffer = buffer;
806         r.out.entries_read = entries_read;
807         r.out.total_entries = total_entries;
808
809         if (DEBUGLEVEL >= 10) {
810                 NDR_PRINT_IN_DEBUG(NetUserGetGroups, &r);
811         }
812
813         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
814                 werr = NetUserGetGroups_l(ctx, &r);
815         } else {
816                 werr = NetUserGetGroups_r(ctx, &r);
817         }
818
819         r.out.result = W_ERROR_V(werr);
820
821         if (DEBUGLEVEL >= 10) {
822                 NDR_PRINT_OUT_DEBUG(NetUserGetGroups, &r);
823         }
824
825         return r.out.result;
826 }
827
828 /****************************************************************
829  NetUserSetGroups
830 ****************************************************************/
831
832 NET_API_STATUS NetUserSetGroups(const char * server_name /* [in] */,
833                                 const char * user_name /* [in] */,
834                                 uint32_t level /* [in] */,
835                                 uint8_t *buffer /* [in] [ref] */,
836                                 uint32_t num_entries /* [in] */)
837 {
838         struct NetUserSetGroups r;
839         struct libnetapi_ctx *ctx = NULL;
840         NET_API_STATUS status;
841         WERROR werr;
842
843         status = libnetapi_getctx(&ctx);
844         if (status != 0) {
845                 return status;
846         }
847
848         /* In parameters */
849         r.in.server_name = server_name;
850         r.in.user_name = user_name;
851         r.in.level = level;
852         r.in.buffer = buffer;
853         r.in.num_entries = num_entries;
854
855         /* Out parameters */
856
857         if (DEBUGLEVEL >= 10) {
858                 NDR_PRINT_IN_DEBUG(NetUserSetGroups, &r);
859         }
860
861         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
862                 werr = NetUserSetGroups_l(ctx, &r);
863         } else {
864                 werr = NetUserSetGroups_r(ctx, &r);
865         }
866
867         r.out.result = W_ERROR_V(werr);
868
869         if (DEBUGLEVEL >= 10) {
870                 NDR_PRINT_OUT_DEBUG(NetUserSetGroups, &r);
871         }
872
873         return r.out.result;
874 }
875
876 /****************************************************************
877  NetUserModalsGet
878 ****************************************************************/
879
880 NET_API_STATUS NetUserModalsGet(const char * server_name /* [in] */,
881                                 uint32_t level /* [in] */,
882                                 uint8_t **buffer /* [out] [ref] */)
883 {
884         struct NetUserModalsGet 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.level = level;
897
898         /* Out parameters */
899         r.out.buffer = buffer;
900
901         if (DEBUGLEVEL >= 10) {
902                 NDR_PRINT_IN_DEBUG(NetUserModalsGet, &r);
903         }
904
905         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
906                 werr = NetUserModalsGet_l(ctx, &r);
907         } else {
908                 werr = NetUserModalsGet_r(ctx, &r);
909         }
910
911         r.out.result = W_ERROR_V(werr);
912
913         if (DEBUGLEVEL >= 10) {
914                 NDR_PRINT_OUT_DEBUG(NetUserModalsGet, &r);
915         }
916
917         return r.out.result;
918 }
919
920 /****************************************************************
921  NetUserModalsSet
922 ****************************************************************/
923
924 NET_API_STATUS NetUserModalsSet(const char * server_name /* [in] */,
925                                 uint32_t level /* [in] */,
926                                 uint8_t *buffer /* [in] [ref] */,
927                                 uint32_t *parm_err /* [out] [ref] */)
928 {
929         struct NetUserModalsSet 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.level = level;
942         r.in.buffer = buffer;
943
944         /* Out parameters */
945         r.out.parm_err = parm_err;
946
947         if (DEBUGLEVEL >= 10) {
948                 NDR_PRINT_IN_DEBUG(NetUserModalsSet, &r);
949         }
950
951         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
952                 werr = NetUserModalsSet_l(ctx, &r);
953         } else {
954                 werr = NetUserModalsSet_r(ctx, &r);
955         }
956
957         r.out.result = W_ERROR_V(werr);
958
959         if (DEBUGLEVEL >= 10) {
960                 NDR_PRINT_OUT_DEBUG(NetUserModalsSet, &r);
961         }
962
963         return r.out.result;
964 }
965
966 /****************************************************************
967  NetQueryDisplayInformation
968 ****************************************************************/
969
970 NET_API_STATUS NetQueryDisplayInformation(const char * server_name /* [in] [unique] */,
971                                           uint32_t level /* [in] */,
972                                           uint32_t idx /* [in] */,
973                                           uint32_t entries_requested /* [in] */,
974                                           uint32_t prefmaxlen /* [in] */,
975                                           uint32_t *entries_read /* [out] [ref] */,
976                                           void **buffer /* [out] [noprint,ref] */)
977 {
978         struct NetQueryDisplayInformation r;
979         struct libnetapi_ctx *ctx = NULL;
980         NET_API_STATUS status;
981         WERROR werr;
982
983         status = libnetapi_getctx(&ctx);
984         if (status != 0) {
985                 return status;
986         }
987
988         /* In parameters */
989         r.in.server_name = server_name;
990         r.in.level = level;
991         r.in.idx = idx;
992         r.in.entries_requested = entries_requested;
993         r.in.prefmaxlen = prefmaxlen;
994
995         /* Out parameters */
996         r.out.entries_read = entries_read;
997         r.out.buffer = buffer;
998
999         if (DEBUGLEVEL >= 10) {
1000                 NDR_PRINT_IN_DEBUG(NetQueryDisplayInformation, &r);
1001         }
1002
1003         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1004                 werr = NetQueryDisplayInformation_l(ctx, &r);
1005         } else {
1006                 werr = NetQueryDisplayInformation_r(ctx, &r);
1007         }
1008
1009         r.out.result = W_ERROR_V(werr);
1010
1011         if (DEBUGLEVEL >= 10) {
1012                 NDR_PRINT_OUT_DEBUG(NetQueryDisplayInformation, &r);
1013         }
1014
1015         return r.out.result;
1016 }
1017
1018 /****************************************************************
1019  NetGroupAdd
1020 ****************************************************************/
1021
1022 NET_API_STATUS NetGroupAdd(const char * server_name /* [in] */,
1023                            uint32_t level /* [in] */,
1024                            uint8_t *buffer /* [in] [ref] */,
1025                            uint32_t *parm_err /* [out] [ref] */)
1026 {
1027         struct NetGroupAdd r;
1028         struct libnetapi_ctx *ctx = NULL;
1029         NET_API_STATUS status;
1030         WERROR werr;
1031
1032         status = libnetapi_getctx(&ctx);
1033         if (status != 0) {
1034                 return status;
1035         }
1036
1037         /* In parameters */
1038         r.in.server_name = server_name;
1039         r.in.level = level;
1040         r.in.buffer = buffer;
1041
1042         /* Out parameters */
1043         r.out.parm_err = parm_err;
1044
1045         if (DEBUGLEVEL >= 10) {
1046                 NDR_PRINT_IN_DEBUG(NetGroupAdd, &r);
1047         }
1048
1049         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1050                 werr = NetGroupAdd_l(ctx, &r);
1051         } else {
1052                 werr = NetGroupAdd_r(ctx, &r);
1053         }
1054
1055         r.out.result = W_ERROR_V(werr);
1056
1057         if (DEBUGLEVEL >= 10) {
1058                 NDR_PRINT_OUT_DEBUG(NetGroupAdd, &r);
1059         }
1060
1061         return r.out.result;
1062 }
1063
1064 /****************************************************************
1065  NetGroupDel
1066 ****************************************************************/
1067
1068 NET_API_STATUS NetGroupDel(const char * server_name /* [in] */,
1069                            const char * group_name /* [in] */)
1070 {
1071         struct NetGroupDel r;
1072         struct libnetapi_ctx *ctx = NULL;
1073         NET_API_STATUS status;
1074         WERROR werr;
1075
1076         status = libnetapi_getctx(&ctx);
1077         if (status != 0) {
1078                 return status;
1079         }
1080
1081         /* In parameters */
1082         r.in.server_name = server_name;
1083         r.in.group_name = group_name;
1084
1085         /* Out parameters */
1086
1087         if (DEBUGLEVEL >= 10) {
1088                 NDR_PRINT_IN_DEBUG(NetGroupDel, &r);
1089         }
1090
1091         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1092                 werr = NetGroupDel_l(ctx, &r);
1093         } else {
1094                 werr = NetGroupDel_r(ctx, &r);
1095         }
1096
1097         r.out.result = W_ERROR_V(werr);
1098
1099         if (DEBUGLEVEL >= 10) {
1100                 NDR_PRINT_OUT_DEBUG(NetGroupDel, &r);
1101         }
1102
1103         return r.out.result;
1104 }
1105
1106 /****************************************************************
1107  NetGroupEnum
1108 ****************************************************************/
1109
1110 NET_API_STATUS NetGroupEnum(const char * server_name /* [in] */,
1111                             uint32_t level /* [in] */,
1112                             uint8_t **buffer /* [out] [ref] */,
1113                             uint32_t prefmaxlen /* [in] */,
1114                             uint32_t *entries_read /* [out] [ref] */,
1115                             uint32_t *total_entries /* [out] [ref] */,
1116                             uint32_t *resume_handle /* [in,out] [ref] */)
1117 {
1118         struct NetGroupEnum r;
1119         struct libnetapi_ctx *ctx = NULL;
1120         NET_API_STATUS status;
1121         WERROR werr;
1122
1123         status = libnetapi_getctx(&ctx);
1124         if (status != 0) {
1125                 return status;
1126         }
1127
1128         /* In parameters */
1129         r.in.server_name = server_name;
1130         r.in.level = level;
1131         r.in.prefmaxlen = prefmaxlen;
1132         r.in.resume_handle = resume_handle;
1133
1134         /* Out parameters */
1135         r.out.buffer = buffer;
1136         r.out.entries_read = entries_read;
1137         r.out.total_entries = total_entries;
1138         r.out.resume_handle = resume_handle;
1139
1140         if (DEBUGLEVEL >= 10) {
1141                 NDR_PRINT_IN_DEBUG(NetGroupEnum, &r);
1142         }
1143
1144         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1145                 werr = NetGroupEnum_l(ctx, &r);
1146         } else {
1147                 werr = NetGroupEnum_r(ctx, &r);
1148         }
1149
1150         r.out.result = W_ERROR_V(werr);
1151
1152         if (DEBUGLEVEL >= 10) {
1153                 NDR_PRINT_OUT_DEBUG(NetGroupEnum, &r);
1154         }
1155
1156         return r.out.result;
1157 }
1158
1159 /****************************************************************
1160  NetGroupSetInfo
1161 ****************************************************************/
1162
1163 NET_API_STATUS NetGroupSetInfo(const char * server_name /* [in] */,
1164                                const char * group_name /* [in] */,
1165                                uint32_t level /* [in] */,
1166                                uint8_t *buffer /* [in] [ref] */,
1167                                uint32_t *parm_err /* [out] [ref] */)
1168 {
1169         struct NetGroupSetInfo r;
1170         struct libnetapi_ctx *ctx = NULL;
1171         NET_API_STATUS status;
1172         WERROR werr;
1173
1174         status = libnetapi_getctx(&ctx);
1175         if (status != 0) {
1176                 return status;
1177         }
1178
1179         /* In parameters */
1180         r.in.server_name = server_name;
1181         r.in.group_name = group_name;
1182         r.in.level = level;
1183         r.in.buffer = buffer;
1184
1185         /* Out parameters */
1186         r.out.parm_err = parm_err;
1187
1188         if (DEBUGLEVEL >= 10) {
1189                 NDR_PRINT_IN_DEBUG(NetGroupSetInfo, &r);
1190         }
1191
1192         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1193                 werr = NetGroupSetInfo_l(ctx, &r);
1194         } else {
1195                 werr = NetGroupSetInfo_r(ctx, &r);
1196         }
1197
1198         r.out.result = W_ERROR_V(werr);
1199
1200         if (DEBUGLEVEL >= 10) {
1201                 NDR_PRINT_OUT_DEBUG(NetGroupSetInfo, &r);
1202         }
1203
1204         return r.out.result;
1205 }
1206
1207 /****************************************************************
1208  NetGroupGetInfo
1209 ****************************************************************/
1210
1211 NET_API_STATUS NetGroupGetInfo(const char * server_name /* [in] */,
1212                                const char * group_name /* [in] */,
1213                                uint32_t level /* [in] */,
1214                                uint8_t **buffer /* [out] [ref] */)
1215 {
1216         struct NetGroupGetInfo r;
1217         struct libnetapi_ctx *ctx = NULL;
1218         NET_API_STATUS status;
1219         WERROR werr;
1220
1221         status = libnetapi_getctx(&ctx);
1222         if (status != 0) {
1223                 return status;
1224         }
1225
1226         /* In parameters */
1227         r.in.server_name = server_name;
1228         r.in.group_name = group_name;
1229         r.in.level = level;
1230
1231         /* Out parameters */
1232         r.out.buffer = buffer;
1233
1234         if (DEBUGLEVEL >= 10) {
1235                 NDR_PRINT_IN_DEBUG(NetGroupGetInfo, &r);
1236         }
1237
1238         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1239                 werr = NetGroupGetInfo_l(ctx, &r);
1240         } else {
1241                 werr = NetGroupGetInfo_r(ctx, &r);
1242         }
1243
1244         r.out.result = W_ERROR_V(werr);
1245
1246         if (DEBUGLEVEL >= 10) {
1247                 NDR_PRINT_OUT_DEBUG(NetGroupGetInfo, &r);
1248         }
1249
1250         return r.out.result;
1251 }
1252
1253 /****************************************************************
1254  NetGroupAddUser
1255 ****************************************************************/
1256
1257 NET_API_STATUS NetGroupAddUser(const char * server_name /* [in] */,
1258                                const char * group_name /* [in] */,
1259                                const char * user_name /* [in] */)
1260 {
1261         struct NetGroupAddUser r;
1262         struct libnetapi_ctx *ctx = NULL;
1263         NET_API_STATUS status;
1264         WERROR werr;
1265
1266         status = libnetapi_getctx(&ctx);
1267         if (status != 0) {
1268                 return status;
1269         }
1270
1271         /* In parameters */
1272         r.in.server_name = server_name;
1273         r.in.group_name = group_name;
1274         r.in.user_name = user_name;
1275
1276         /* Out parameters */
1277
1278         if (DEBUGLEVEL >= 10) {
1279                 NDR_PRINT_IN_DEBUG(NetGroupAddUser, &r);
1280         }
1281
1282         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1283                 werr = NetGroupAddUser_l(ctx, &r);
1284         } else {
1285                 werr = NetGroupAddUser_r(ctx, &r);
1286         }
1287
1288         r.out.result = W_ERROR_V(werr);
1289
1290         if (DEBUGLEVEL >= 10) {
1291                 NDR_PRINT_OUT_DEBUG(NetGroupAddUser, &r);
1292         }
1293
1294         return r.out.result;
1295 }
1296
1297 /****************************************************************
1298  NetGroupDelUser
1299 ****************************************************************/
1300
1301 NET_API_STATUS NetGroupDelUser(const char * server_name /* [in] */,
1302                                const char * group_name /* [in] */,
1303                                const char * user_name /* [in] */)
1304 {
1305         struct NetGroupDelUser r;
1306         struct libnetapi_ctx *ctx = NULL;
1307         NET_API_STATUS status;
1308         WERROR werr;
1309
1310         status = libnetapi_getctx(&ctx);
1311         if (status != 0) {
1312                 return status;
1313         }
1314
1315         /* In parameters */
1316         r.in.server_name = server_name;
1317         r.in.group_name = group_name;
1318         r.in.user_name = user_name;
1319
1320         /* Out parameters */
1321
1322         if (DEBUGLEVEL >= 10) {
1323                 NDR_PRINT_IN_DEBUG(NetGroupDelUser, &r);
1324         }
1325
1326         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1327                 werr = NetGroupDelUser_l(ctx, &r);
1328         } else {
1329                 werr = NetGroupDelUser_r(ctx, &r);
1330         }
1331
1332         r.out.result = W_ERROR_V(werr);
1333
1334         if (DEBUGLEVEL >= 10) {
1335                 NDR_PRINT_OUT_DEBUG(NetGroupDelUser, &r);
1336         }
1337
1338         return r.out.result;
1339 }
1340
1341 /****************************************************************
1342  NetGroupGetUsers
1343 ****************************************************************/
1344
1345 NET_API_STATUS NetGroupGetUsers(const char * server_name /* [in] */,
1346                                 const char * group_name /* [in] */,
1347                                 uint32_t level /* [in] */,
1348                                 uint8_t **buffer /* [out] [ref] */,
1349                                 uint32_t prefmaxlen /* [in] */,
1350                                 uint32_t *entries_read /* [out] [ref] */,
1351                                 uint32_t *total_entries /* [out] [ref] */,
1352                                 uint32_t *resume_handle /* [in,out] [ref] */)
1353 {
1354         struct NetGroupGetUsers r;
1355         struct libnetapi_ctx *ctx = NULL;
1356         NET_API_STATUS status;
1357         WERROR werr;
1358
1359         status = libnetapi_getctx(&ctx);
1360         if (status != 0) {
1361                 return status;
1362         }
1363
1364         /* In parameters */
1365         r.in.server_name = server_name;
1366         r.in.group_name = group_name;
1367         r.in.level = level;
1368         r.in.prefmaxlen = prefmaxlen;
1369         r.in.resume_handle = resume_handle;
1370
1371         /* Out parameters */
1372         r.out.buffer = buffer;
1373         r.out.entries_read = entries_read;
1374         r.out.total_entries = total_entries;
1375         r.out.resume_handle = resume_handle;
1376
1377         if (DEBUGLEVEL >= 10) {
1378                 NDR_PRINT_IN_DEBUG(NetGroupGetUsers, &r);
1379         }
1380
1381         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1382                 werr = NetGroupGetUsers_l(ctx, &r);
1383         } else {
1384                 werr = NetGroupGetUsers_r(ctx, &r);
1385         }
1386
1387         r.out.result = W_ERROR_V(werr);
1388
1389         if (DEBUGLEVEL >= 10) {
1390                 NDR_PRINT_OUT_DEBUG(NetGroupGetUsers, &r);
1391         }
1392
1393         return r.out.result;
1394 }
1395
1396 /****************************************************************
1397  NetLocalGroupAdd
1398 ****************************************************************/
1399
1400 NET_API_STATUS NetLocalGroupAdd(const char * server_name /* [in] */,
1401                                 uint32_t level /* [in] */,
1402                                 uint8_t *buffer /* [in] [ref] */,
1403                                 uint32_t *parm_err /* [out] [ref] */)
1404 {
1405         struct NetLocalGroupAdd r;
1406         struct libnetapi_ctx *ctx = NULL;
1407         NET_API_STATUS status;
1408         WERROR werr;
1409
1410         status = libnetapi_getctx(&ctx);
1411         if (status != 0) {
1412                 return status;
1413         }
1414
1415         /* In parameters */
1416         r.in.server_name = server_name;
1417         r.in.level = level;
1418         r.in.buffer = buffer;
1419
1420         /* Out parameters */
1421         r.out.parm_err = parm_err;
1422
1423         if (DEBUGLEVEL >= 10) {
1424                 NDR_PRINT_IN_DEBUG(NetLocalGroupAdd, &r);
1425         }
1426
1427         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1428                 werr = NetLocalGroupAdd_l(ctx, &r);
1429         } else {
1430                 werr = NetLocalGroupAdd_r(ctx, &r);
1431         }
1432
1433         r.out.result = W_ERROR_V(werr);
1434
1435         if (DEBUGLEVEL >= 10) {
1436                 NDR_PRINT_OUT_DEBUG(NetLocalGroupAdd, &r);
1437         }
1438
1439         return r.out.result;
1440 }
1441
1442 /****************************************************************
1443  NetLocalGroupDel
1444 ****************************************************************/
1445
1446 NET_API_STATUS NetLocalGroupDel(const char * server_name /* [in] */,
1447                                 const char * group_name /* [in] */)
1448 {
1449         struct NetLocalGroupDel r;
1450         struct libnetapi_ctx *ctx = NULL;
1451         NET_API_STATUS status;
1452         WERROR werr;
1453
1454         status = libnetapi_getctx(&ctx);
1455         if (status != 0) {
1456                 return status;
1457         }
1458
1459         /* In parameters */
1460         r.in.server_name = server_name;
1461         r.in.group_name = group_name;
1462
1463         /* Out parameters */
1464
1465         if (DEBUGLEVEL >= 10) {
1466                 NDR_PRINT_IN_DEBUG(NetLocalGroupDel, &r);
1467         }
1468
1469         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1470                 werr = NetLocalGroupDel_l(ctx, &r);
1471         } else {
1472                 werr = NetLocalGroupDel_r(ctx, &r);
1473         }
1474
1475         r.out.result = W_ERROR_V(werr);
1476
1477         if (DEBUGLEVEL >= 10) {
1478                 NDR_PRINT_OUT_DEBUG(NetLocalGroupDel, &r);
1479         }
1480
1481         return r.out.result;
1482 }
1483
1484 /****************************************************************
1485  NetLocalGroupGetInfo
1486 ****************************************************************/
1487
1488 NET_API_STATUS NetLocalGroupGetInfo(const char * server_name /* [in] */,
1489                                     const char * group_name /* [in] */,
1490                                     uint32_t level /* [in] */,
1491                                     uint8_t **buffer /* [out] [ref] */)
1492 {
1493         struct NetLocalGroupGetInfo r;
1494         struct libnetapi_ctx *ctx = NULL;
1495         NET_API_STATUS status;
1496         WERROR werr;
1497
1498         status = libnetapi_getctx(&ctx);
1499         if (status != 0) {
1500                 return status;
1501         }
1502
1503         /* In parameters */
1504         r.in.server_name = server_name;
1505         r.in.group_name = group_name;
1506         r.in.level = level;
1507
1508         /* Out parameters */
1509         r.out.buffer = buffer;
1510
1511         if (DEBUGLEVEL >= 10) {
1512                 NDR_PRINT_IN_DEBUG(NetLocalGroupGetInfo, &r);
1513         }
1514
1515         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1516                 werr = NetLocalGroupGetInfo_l(ctx, &r);
1517         } else {
1518                 werr = NetLocalGroupGetInfo_r(ctx, &r);
1519         }
1520
1521         r.out.result = W_ERROR_V(werr);
1522
1523         if (DEBUGLEVEL >= 10) {
1524                 NDR_PRINT_OUT_DEBUG(NetLocalGroupGetInfo, &r);
1525         }
1526
1527         return r.out.result;
1528 }
1529
1530 /****************************************************************
1531  NetLocalGroupSetInfo
1532 ****************************************************************/
1533
1534 NET_API_STATUS NetLocalGroupSetInfo(const char * server_name /* [in] */,
1535                                     const char * group_name /* [in] */,
1536                                     uint32_t level /* [in] */,
1537                                     uint8_t *buffer /* [in] [ref] */,
1538                                     uint32_t *parm_err /* [out] [ref] */)
1539 {
1540         struct NetLocalGroupSetInfo r;
1541         struct libnetapi_ctx *ctx = NULL;
1542         NET_API_STATUS status;
1543         WERROR werr;
1544
1545         status = libnetapi_getctx(&ctx);
1546         if (status != 0) {
1547                 return status;
1548         }
1549
1550         /* In parameters */
1551         r.in.server_name = server_name;
1552         r.in.group_name = group_name;
1553         r.in.level = level;
1554         r.in.buffer = buffer;
1555
1556         /* Out parameters */
1557         r.out.parm_err = parm_err;
1558
1559         if (DEBUGLEVEL >= 10) {
1560                 NDR_PRINT_IN_DEBUG(NetLocalGroupSetInfo, &r);
1561         }
1562
1563         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1564                 werr = NetLocalGroupSetInfo_l(ctx, &r);
1565         } else {
1566                 werr = NetLocalGroupSetInfo_r(ctx, &r);
1567         }
1568
1569         r.out.result = W_ERROR_V(werr);
1570
1571         if (DEBUGLEVEL >= 10) {
1572                 NDR_PRINT_OUT_DEBUG(NetLocalGroupSetInfo, &r);
1573         }
1574
1575         return r.out.result;
1576 }
1577
1578 /****************************************************************
1579  NetLocalGroupEnum
1580 ****************************************************************/
1581
1582 NET_API_STATUS NetLocalGroupEnum(const char * server_name /* [in] */,
1583                                  uint32_t level /* [in] */,
1584                                  uint8_t **buffer /* [out] [ref] */,
1585                                  uint32_t prefmaxlen /* [in] */,
1586                                  uint32_t *entries_read /* [out] [ref] */,
1587                                  uint32_t *total_entries /* [out] [ref] */,
1588                                  uint32_t *resume_handle /* [in,out] [ref] */)
1589 {
1590         struct NetLocalGroupEnum r;
1591         struct libnetapi_ctx *ctx = NULL;
1592         NET_API_STATUS status;
1593         WERROR werr;
1594
1595         status = libnetapi_getctx(&ctx);
1596         if (status != 0) {
1597                 return status;
1598         }
1599
1600         /* In parameters */
1601         r.in.server_name = server_name;
1602         r.in.level = level;
1603         r.in.prefmaxlen = prefmaxlen;
1604         r.in.resume_handle = resume_handle;
1605
1606         /* Out parameters */
1607         r.out.buffer = buffer;
1608         r.out.entries_read = entries_read;
1609         r.out.total_entries = total_entries;
1610         r.out.resume_handle = resume_handle;
1611
1612         if (DEBUGLEVEL >= 10) {
1613                 NDR_PRINT_IN_DEBUG(NetLocalGroupEnum, &r);
1614         }
1615
1616         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1617                 werr = NetLocalGroupEnum_l(ctx, &r);
1618         } else {
1619                 werr = NetLocalGroupEnum_r(ctx, &r);
1620         }
1621
1622         r.out.result = W_ERROR_V(werr);
1623
1624         if (DEBUGLEVEL >= 10) {
1625                 NDR_PRINT_OUT_DEBUG(NetLocalGroupEnum, &r);
1626         }
1627
1628         return r.out.result;
1629 }
1630
1631 /****************************************************************
1632  NetLocalGroupAddMembers
1633 ****************************************************************/
1634
1635 NET_API_STATUS NetLocalGroupAddMembers(const char * server_name /* [in] */,
1636                                        const char * group_name /* [in] */,
1637                                        uint32_t level /* [in] */,
1638                                        uint8_t *buffer /* [in] [ref] */,
1639                                        uint32_t total_entries /* [in] */)
1640 {
1641         struct NetLocalGroupAddMembers r;
1642         struct libnetapi_ctx *ctx = NULL;
1643         NET_API_STATUS status;
1644         WERROR werr;
1645
1646         status = libnetapi_getctx(&ctx);
1647         if (status != 0) {
1648                 return status;
1649         }
1650
1651         /* In parameters */
1652         r.in.server_name = server_name;
1653         r.in.group_name = group_name;
1654         r.in.level = level;
1655         r.in.buffer = buffer;
1656         r.in.total_entries = total_entries;
1657
1658         /* Out parameters */
1659
1660         if (DEBUGLEVEL >= 10) {
1661                 NDR_PRINT_IN_DEBUG(NetLocalGroupAddMembers, &r);
1662         }
1663
1664         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1665                 werr = NetLocalGroupAddMembers_l(ctx, &r);
1666         } else {
1667                 werr = NetLocalGroupAddMembers_r(ctx, &r);
1668         }
1669
1670         r.out.result = W_ERROR_V(werr);
1671
1672         if (DEBUGLEVEL >= 10) {
1673                 NDR_PRINT_OUT_DEBUG(NetLocalGroupAddMembers, &r);
1674         }
1675
1676         return r.out.result;
1677 }
1678
1679 /****************************************************************
1680  NetLocalGroupDelMembers
1681 ****************************************************************/
1682
1683 NET_API_STATUS NetLocalGroupDelMembers(const char * server_name /* [in] */,
1684                                        const char * group_name /* [in] */,
1685                                        uint32_t level /* [in] */,
1686                                        uint8_t *buffer /* [in] [ref] */,
1687                                        uint32_t total_entries /* [in] */)
1688 {
1689         struct NetLocalGroupDelMembers r;
1690         struct libnetapi_ctx *ctx = NULL;
1691         NET_API_STATUS status;
1692         WERROR werr;
1693
1694         status = libnetapi_getctx(&ctx);
1695         if (status != 0) {
1696                 return status;
1697         }
1698
1699         /* In parameters */
1700         r.in.server_name = server_name;
1701         r.in.group_name = group_name;
1702         r.in.level = level;
1703         r.in.buffer = buffer;
1704         r.in.total_entries = total_entries;
1705
1706         /* Out parameters */
1707
1708         if (DEBUGLEVEL >= 10) {
1709                 NDR_PRINT_IN_DEBUG(NetLocalGroupDelMembers, &r);
1710         }
1711
1712         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1713                 werr = NetLocalGroupDelMembers_l(ctx, &r);
1714         } else {
1715                 werr = NetLocalGroupDelMembers_r(ctx, &r);
1716         }
1717
1718         r.out.result = W_ERROR_V(werr);
1719
1720         if (DEBUGLEVEL >= 10) {
1721                 NDR_PRINT_OUT_DEBUG(NetLocalGroupDelMembers, &r);
1722         }
1723
1724         return r.out.result;
1725 }
1726
1727 /****************************************************************
1728  NetLocalGroupGetMembers
1729 ****************************************************************/
1730
1731 NET_API_STATUS NetLocalGroupGetMembers(const char * server_name /* [in] */,
1732                                        const char * local_group_name /* [in] */,
1733                                        uint32_t level /* [in] */,
1734                                        uint8_t **buffer /* [out] [ref] */,
1735                                        uint32_t prefmaxlen /* [in] */,
1736                                        uint32_t *entries_read /* [out] [ref] */,
1737                                        uint32_t *total_entries /* [out] [ref] */,
1738                                        uint32_t *resume_handle /* [in,out] [ref] */)
1739 {
1740         struct NetLocalGroupGetMembers r;
1741         struct libnetapi_ctx *ctx = NULL;
1742         NET_API_STATUS status;
1743         WERROR werr;
1744
1745         status = libnetapi_getctx(&ctx);
1746         if (status != 0) {
1747                 return status;
1748         }
1749
1750         /* In parameters */
1751         r.in.server_name = server_name;
1752         r.in.local_group_name = local_group_name;
1753         r.in.level = level;
1754         r.in.prefmaxlen = prefmaxlen;
1755         r.in.resume_handle = resume_handle;
1756
1757         /* Out parameters */
1758         r.out.buffer = buffer;
1759         r.out.entries_read = entries_read;
1760         r.out.total_entries = total_entries;
1761         r.out.resume_handle = resume_handle;
1762
1763         if (DEBUGLEVEL >= 10) {
1764                 NDR_PRINT_IN_DEBUG(NetLocalGroupGetMembers, &r);
1765         }
1766
1767         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1768                 werr = NetLocalGroupGetMembers_l(ctx, &r);
1769         } else {
1770                 werr = NetLocalGroupGetMembers_r(ctx, &r);
1771         }
1772
1773         r.out.result = W_ERROR_V(werr);
1774
1775         if (DEBUGLEVEL >= 10) {
1776                 NDR_PRINT_OUT_DEBUG(NetLocalGroupGetMembers, &r);
1777         }
1778
1779         return r.out.result;
1780 }
1781
1782 /****************************************************************
1783  NetLocalGroupSetMembers
1784 ****************************************************************/
1785
1786 NET_API_STATUS NetLocalGroupSetMembers(const char * server_name /* [in] */,
1787                                        const char * group_name /* [in] */,
1788                                        uint32_t level /* [in] */,
1789                                        uint8_t *buffer /* [in] [ref] */,
1790                                        uint32_t total_entries /* [in] */)
1791 {
1792         struct NetLocalGroupSetMembers r;
1793         struct libnetapi_ctx *ctx = NULL;
1794         NET_API_STATUS status;
1795         WERROR werr;
1796
1797         status = libnetapi_getctx(&ctx);
1798         if (status != 0) {
1799                 return status;
1800         }
1801
1802         /* In parameters */
1803         r.in.server_name = server_name;
1804         r.in.group_name = group_name;
1805         r.in.level = level;
1806         r.in.buffer = buffer;
1807         r.in.total_entries = total_entries;
1808
1809         /* Out parameters */
1810
1811         if (DEBUGLEVEL >= 10) {
1812                 NDR_PRINT_IN_DEBUG(NetLocalGroupSetMembers, &r);
1813         }
1814
1815         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1816                 werr = NetLocalGroupSetMembers_l(ctx, &r);
1817         } else {
1818                 werr = NetLocalGroupSetMembers_r(ctx, &r);
1819         }
1820
1821         r.out.result = W_ERROR_V(werr);
1822
1823         if (DEBUGLEVEL >= 10) {
1824                 NDR_PRINT_OUT_DEBUG(NetLocalGroupSetMembers, &r);
1825         }
1826
1827         return r.out.result;
1828 }
1829
1830 /****************************************************************
1831  NetRemoteTOD
1832 ****************************************************************/
1833
1834 NET_API_STATUS NetRemoteTOD(const char * server_name /* [in] */,
1835                             uint8_t **buffer /* [out] [ref] */)
1836 {
1837         struct NetRemoteTOD r;
1838         struct libnetapi_ctx *ctx = NULL;
1839         NET_API_STATUS status;
1840         WERROR werr;
1841
1842         status = libnetapi_getctx(&ctx);
1843         if (status != 0) {
1844                 return status;
1845         }
1846
1847         /* In parameters */
1848         r.in.server_name = server_name;
1849
1850         /* Out parameters */
1851         r.out.buffer = buffer;
1852
1853         if (DEBUGLEVEL >= 10) {
1854                 NDR_PRINT_IN_DEBUG(NetRemoteTOD, &r);
1855         }
1856
1857         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1858                 werr = NetRemoteTOD_l(ctx, &r);
1859         } else {
1860                 werr = NetRemoteTOD_r(ctx, &r);
1861         }
1862
1863         r.out.result = W_ERROR_V(werr);
1864
1865         if (DEBUGLEVEL >= 10) {
1866                 NDR_PRINT_OUT_DEBUG(NetRemoteTOD, &r);
1867         }
1868
1869         return r.out.result;
1870 }
1871
1872 /****************************************************************
1873  NetShareAdd
1874 ****************************************************************/
1875
1876 NET_API_STATUS NetShareAdd(const char * server_name /* [in] */,
1877                            uint32_t level /* [in] */,
1878                            uint8_t *buffer /* [in] [ref] */,
1879                            uint32_t *parm_err /* [out] [ref] */)
1880 {
1881         struct NetShareAdd r;
1882         struct libnetapi_ctx *ctx = NULL;
1883         NET_API_STATUS status;
1884         WERROR werr;
1885
1886         status = libnetapi_getctx(&ctx);
1887         if (status != 0) {
1888                 return status;
1889         }
1890
1891         /* In parameters */
1892         r.in.server_name = server_name;
1893         r.in.level = level;
1894         r.in.buffer = buffer;
1895
1896         /* Out parameters */
1897         r.out.parm_err = parm_err;
1898
1899         if (DEBUGLEVEL >= 10) {
1900                 NDR_PRINT_IN_DEBUG(NetShareAdd, &r);
1901         }
1902
1903         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1904                 werr = NetShareAdd_l(ctx, &r);
1905         } else {
1906                 werr = NetShareAdd_r(ctx, &r);
1907         }
1908
1909         r.out.result = W_ERROR_V(werr);
1910
1911         if (DEBUGLEVEL >= 10) {
1912                 NDR_PRINT_OUT_DEBUG(NetShareAdd, &r);
1913         }
1914
1915         return r.out.result;
1916 }
1917
1918 /****************************************************************
1919  NetShareDel
1920 ****************************************************************/
1921
1922 NET_API_STATUS NetShareDel(const char * server_name /* [in] */,
1923                            const char * net_name /* [in] */,
1924                            uint32_t reserved /* [in] */)
1925 {
1926         struct NetShareDel r;
1927         struct libnetapi_ctx *ctx = NULL;
1928         NET_API_STATUS status;
1929         WERROR werr;
1930
1931         status = libnetapi_getctx(&ctx);
1932         if (status != 0) {
1933                 return status;
1934         }
1935
1936         /* In parameters */
1937         r.in.server_name = server_name;
1938         r.in.net_name = net_name;
1939         r.in.reserved = reserved;
1940
1941         /* Out parameters */
1942
1943         if (DEBUGLEVEL >= 10) {
1944                 NDR_PRINT_IN_DEBUG(NetShareDel, &r);
1945         }
1946
1947         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
1948                 werr = NetShareDel_l(ctx, &r);
1949         } else {
1950                 werr = NetShareDel_r(ctx, &r);
1951         }
1952
1953         r.out.result = W_ERROR_V(werr);
1954
1955         if (DEBUGLEVEL >= 10) {
1956                 NDR_PRINT_OUT_DEBUG(NetShareDel, &r);
1957         }
1958
1959         return r.out.result;
1960 }
1961
1962 /****************************************************************
1963  NetShareEnum
1964 ****************************************************************/
1965
1966 NET_API_STATUS NetShareEnum(const char * server_name /* [in] */,
1967                             uint32_t level /* [in] */,
1968                             uint8_t **buffer /* [out] [ref] */,
1969                             uint32_t prefmaxlen /* [in] */,
1970                             uint32_t *entries_read /* [out] [ref] */,
1971                             uint32_t *total_entries /* [out] [ref] */,
1972                             uint32_t *resume_handle /* [in,out] [ref] */)
1973 {
1974         struct NetShareEnum r;
1975         struct libnetapi_ctx *ctx = NULL;
1976         NET_API_STATUS status;
1977         WERROR werr;
1978
1979         status = libnetapi_getctx(&ctx);
1980         if (status != 0) {
1981                 return status;
1982         }
1983
1984         /* In parameters */
1985         r.in.server_name = server_name;
1986         r.in.level = level;
1987         r.in.prefmaxlen = prefmaxlen;
1988         r.in.resume_handle = resume_handle;
1989
1990         /* Out parameters */
1991         r.out.buffer = buffer;
1992         r.out.entries_read = entries_read;
1993         r.out.total_entries = total_entries;
1994         r.out.resume_handle = resume_handle;
1995
1996         if (DEBUGLEVEL >= 10) {
1997                 NDR_PRINT_IN_DEBUG(NetShareEnum, &r);
1998         }
1999
2000         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
2001                 werr = NetShareEnum_l(ctx, &r);
2002         } else {
2003                 werr = NetShareEnum_r(ctx, &r);
2004         }
2005
2006         r.out.result = W_ERROR_V(werr);
2007
2008         if (DEBUGLEVEL >= 10) {
2009                 NDR_PRINT_OUT_DEBUG(NetShareEnum, &r);
2010         }
2011
2012         return r.out.result;
2013 }
2014
2015 /****************************************************************
2016  NetShareGetInfo
2017 ****************************************************************/
2018
2019 NET_API_STATUS NetShareGetInfo(const char * server_name /* [in] */,
2020                                const char * net_name /* [in] */,
2021                                uint32_t level /* [in] */,
2022                                uint8_t **buffer /* [out] [ref] */)
2023 {
2024         struct NetShareGetInfo r;
2025         struct libnetapi_ctx *ctx = NULL;
2026         NET_API_STATUS status;
2027         WERROR werr;
2028
2029         status = libnetapi_getctx(&ctx);
2030         if (status != 0) {
2031                 return status;
2032         }
2033
2034         /* In parameters */
2035         r.in.server_name = server_name;
2036         r.in.net_name = net_name;
2037         r.in.level = level;
2038
2039         /* Out parameters */
2040         r.out.buffer = buffer;
2041
2042         if (DEBUGLEVEL >= 10) {
2043                 NDR_PRINT_IN_DEBUG(NetShareGetInfo, &r);
2044         }
2045
2046         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
2047                 werr = NetShareGetInfo_l(ctx, &r);
2048         } else {
2049                 werr = NetShareGetInfo_r(ctx, &r);
2050         }
2051
2052         r.out.result = W_ERROR_V(werr);
2053
2054         if (DEBUGLEVEL >= 10) {
2055                 NDR_PRINT_OUT_DEBUG(NetShareGetInfo, &r);
2056         }
2057
2058         return r.out.result;
2059 }
2060
2061 /****************************************************************
2062  NetShareSetInfo
2063 ****************************************************************/
2064
2065 NET_API_STATUS NetShareSetInfo(const char * server_name /* [in] */,
2066                                const char * net_name /* [in] */,
2067                                uint32_t level /* [in] */,
2068                                uint8_t *buffer /* [in] [ref] */,
2069                                uint32_t *parm_err /* [out] [ref] */)
2070 {
2071         struct NetShareSetInfo r;
2072         struct libnetapi_ctx *ctx = NULL;
2073         NET_API_STATUS status;
2074         WERROR werr;
2075
2076         status = libnetapi_getctx(&ctx);
2077         if (status != 0) {
2078                 return status;
2079         }
2080
2081         /* In parameters */
2082         r.in.server_name = server_name;
2083         r.in.net_name = net_name;
2084         r.in.level = level;
2085         r.in.buffer = buffer;
2086
2087         /* Out parameters */
2088         r.out.parm_err = parm_err;
2089
2090         if (DEBUGLEVEL >= 10) {
2091                 NDR_PRINT_IN_DEBUG(NetShareSetInfo, &r);
2092         }
2093
2094         if (LIBNETAPI_LOCAL_SERVER(server_name)) {
2095                 werr = NetShareSetInfo_l(ctx, &r);
2096         } else {
2097                 werr = NetShareSetInfo_r(ctx, &r);
2098         }
2099
2100         r.out.result = W_ERROR_V(werr);
2101
2102         if (DEBUGLEVEL >= 10) {
2103                 NDR_PRINT_OUT_DEBUG(NetShareSetInfo, &r);
2104         }
2105
2106         return r.out.result;
2107 }
2108