r4440: - add a start of srvsvc_NetShareCheck() server code
[samba.git] / source4 / rpc_server / srvsvc / dcesrv_srvsvc.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    endpoint server for the srvsvc pipe
5
6    Copyright (C) Stefan (metze) Metzmacher 2004
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "rpc_server/dcerpc_server.h"
25 #include "librpc/gen_ndr/ndr_srvsvc.h"
26 #include "rpc_server/common/common.h"
27 #include "system/time.h"
28
29 /* 
30   srvsvc_NetCharDevEnum 
31 */
32 static WERROR srvsvc_NetCharDevEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
33                                       struct srvsvc_NetCharDevEnum *r)
34 {
35         r->out.level = r->in.level;
36         r->out.totalentries = 0;
37         r->out.resume_handle = NULL;
38
39         switch (r->in.level) {
40         case 0:
41                 r->out.ctr.ctr0 = talloc_p(mem_ctx, struct srvsvc_NetCharDevCtr0);
42                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr0);
43
44                 r->out.ctr.ctr0->count = 0;
45                 r->out.ctr.ctr0->array = NULL;
46
47                 return WERR_NOT_SUPPORTED;
48
49         case 1:
50                 r->out.ctr.ctr1 = talloc_p(mem_ctx, struct srvsvc_NetCharDevCtr1);
51                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr1);
52
53                 r->out.ctr.ctr1->count = 0;
54                 r->out.ctr.ctr1->array = NULL;
55
56                 return WERR_NOT_SUPPORTED;
57
58         default:
59                 return WERR_UNKNOWN_LEVEL;
60         }
61
62         return WERR_OK;
63 }
64
65
66 /* 
67   srvsvc_NetCharDevGetInfo 
68 */
69 static WERROR srvsvc_NetCharDevGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
70                        struct srvsvc_NetCharDevGetInfo *r)
71 {
72         ZERO_STRUCT(r->out);
73
74         switch (r->in.level) {
75         case 0:
76         {
77                 return WERR_NOT_SUPPORTED;
78         }
79         case 1:
80         {
81                 return WERR_NOT_SUPPORTED;
82         }
83         default:
84                 return WERR_UNKNOWN_LEVEL;
85         }
86
87         return WERR_UNKNOWN_LEVEL;
88 }
89
90
91 /* 
92   srvsvc_NetCharDevControl 
93 */
94 static WERROR srvsvc_NetCharDevControl(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
95                        struct srvsvc_NetCharDevControl *r)
96 {
97         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
98 }
99
100
101 /* 
102   srvsvc_NetCharDevQEnum 
103 */
104 static WERROR srvsvc_NetCharDevQEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
105                                      struct srvsvc_NetCharDevQEnum *r)
106 {
107         r->out.level = r->in.level;
108         r->out.totalentries = 0;
109         r->out.resume_handle = NULL;
110
111         switch (r->in.level) {
112         case 0:
113         {
114                 r->out.ctr.ctr0 = talloc_p(mem_ctx, struct srvsvc_NetCharDevQCtr0);
115                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr0);
116
117                 r->out.ctr.ctr0->count = 0;
118                 r->out.ctr.ctr0->array = NULL;
119
120                 return WERR_NOT_SUPPORTED;
121         }
122         case 1:
123         {
124                 r->out.ctr.ctr1 = talloc_p(mem_ctx, struct srvsvc_NetCharDevQCtr1);
125                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr1);
126
127                 r->out.ctr.ctr1->count = 0;
128                 r->out.ctr.ctr1->array = NULL;
129
130                 return WERR_NOT_SUPPORTED;
131         }
132         default:
133                 return WERR_UNKNOWN_LEVEL;
134         }
135
136         return WERR_UNKNOWN_LEVEL;
137 }
138
139
140 /* 
141   srvsvc_NetCharDevQGetInfo 
142 */
143 static WERROR srvsvc_NetCharDevQGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
144                                         struct srvsvc_NetCharDevQGetInfo *r)
145 {
146         ZERO_STRUCT(r->out);
147
148         switch (r->in.level) {
149         case 0:
150         {
151                 return WERR_NOT_SUPPORTED;
152         }
153         case 1:
154         {
155                 return WERR_NOT_SUPPORTED;
156         }
157         default:
158                 return WERR_UNKNOWN_LEVEL;
159         }
160
161         return WERR_UNKNOWN_LEVEL;
162 }
163
164
165 /* 
166   srvsvc_NetCharDevQSetInfo 
167 */
168 static WERROR srvsvc_NetCharDevQSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
169                        struct srvsvc_NetCharDevQSetInfo *r)
170 {
171         switch (r->in.level) {
172         case 0:
173         {
174                 if (r->in.parm_error) {
175                         r->out.parm_error = r->in.parm_error;
176                 }
177                 return WERR_NOT_SUPPORTED;
178         }
179         case 1:
180         {
181                 if (r->in.parm_error) {
182                         r->out.parm_error = r->in.parm_error;
183                 }
184                 return WERR_NOT_SUPPORTED;
185         }
186         default:
187                 return WERR_UNKNOWN_LEVEL;
188         }
189
190         return WERR_UNKNOWN_LEVEL;
191 }
192
193
194 /* 
195   srvsvc_NetCharDevQPurge 
196 */
197 static WERROR srvsvc_NetCharDevQPurge(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
198                        struct srvsvc_NetCharDevQPurge *r)
199 {
200         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
201 }
202
203
204 /* 
205   srvsvc_NetCharDevQPurgeSelf 
206 */
207 static WERROR srvsvc_NetCharDevQPurgeSelf(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
208                                           struct srvsvc_NetCharDevQPurgeSelf *r)
209 {
210         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);        
211 }
212
213
214 /* 
215   srvsvc_NetConnEnum 
216 */
217 static WERROR srvsvc_NetConnEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
218                        struct srvsvc_NetConnEnum *r)
219 {
220         r->out.level = r->in.level;
221         r->out.totalentries = 0;
222         r->out.resume_handle = NULL;
223
224         switch (r->in.level) {
225         case 0:
226         {
227                 r->out.ctr.ctr0 = talloc_p(mem_ctx, struct srvsvc_NetConnCtr0);
228                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr0);
229
230                 r->out.ctr.ctr0->count = 0;
231                 r->out.ctr.ctr0->array = NULL;
232
233                 return WERR_NOT_SUPPORTED;
234         }
235         case 1:
236         {
237                 r->out.ctr.ctr1 = talloc_p(mem_ctx, struct srvsvc_NetConnCtr1);
238                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr1);
239
240                 r->out.ctr.ctr1->count = 0;
241                 r->out.ctr.ctr1->array = NULL;
242
243                 return WERR_NOT_SUPPORTED;
244         }
245         default:
246                 return WERR_UNKNOWN_LEVEL;
247         }
248
249         return WERR_UNKNOWN_LEVEL;
250 }
251
252
253 /* 
254   srvsvc_NetFileEnum 
255 */
256 static WERROR srvsvc_NetFileEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
257                                  struct srvsvc_NetFileEnum *r)
258 {
259         r->out.level = r->in.level;
260         r->out.totalentries = 0;
261         r->out.resume_handle = NULL;
262
263         switch (r->in.level) {
264         case 2:
265         {
266                 r->out.ctr.ctr2 = talloc_p(mem_ctx, struct srvsvc_NetFileCtr2);
267                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr2);
268
269                 r->out.ctr.ctr2->count = 0;
270                 r->out.ctr.ctr2->array = NULL;
271
272                 return WERR_NOT_SUPPORTED;
273         }
274         case 3:
275         {
276                 r->out.ctr.ctr3 = talloc_p(mem_ctx, struct srvsvc_NetFileCtr3);
277                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr3);
278
279                 r->out.ctr.ctr3->count = 0;
280                 r->out.ctr.ctr3->array = NULL;
281
282                 return WERR_NOT_SUPPORTED;
283         }
284         default:
285                 return WERR_UNKNOWN_LEVEL;
286         }
287
288         return WERR_UNKNOWN_LEVEL;
289 }
290
291
292 /* 
293   srvsvc_NetFileGetInfo 
294 */
295 static WERROR srvsvc_NetFileGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
296                                     struct srvsvc_NetFileGetInfo *r)
297 {
298         ZERO_STRUCT(r->out);
299
300         switch (r->in.level) {
301         case 2:
302         {
303                 return WERR_NOT_SUPPORTED;
304         }
305         case 3:
306         {
307                 return WERR_NOT_SUPPORTED;
308         }
309         default:
310                 return WERR_UNKNOWN_LEVEL;
311         }
312
313         return WERR_UNKNOWN_LEVEL;
314 }
315
316
317 /* 
318   srvsvc_NetFileClose 
319 */
320 static WERROR srvsvc_NetFileClose(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
321                        struct srvsvc_NetFileClose *r)
322 {
323         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
324 }
325
326
327 /* 
328   srvsvc_NetSessEnum 
329 */
330 static WERROR srvsvc_NetSessEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
331                        struct srvsvc_NetSessEnum *r)
332 {
333         r->out.level = r->in.level;
334         r->out.totalentries = 0;
335         r->out.resume_handle = NULL;
336
337         switch (r->in.level) {
338         case 0:
339         {
340                 r->out.ctr.ctr0 = talloc_p(mem_ctx, struct srvsvc_NetSessCtr0);
341                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr0);
342
343                 r->out.ctr.ctr0->count = 0;
344                 r->out.ctr.ctr0->array = NULL;
345
346                 return WERR_NOT_SUPPORTED;
347         }
348         case 1:
349         {
350                 r->out.ctr.ctr1 = talloc_p(mem_ctx, struct srvsvc_NetSessCtr1);
351                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr1);
352
353                 r->out.ctr.ctr1->count = 0;
354                 r->out.ctr.ctr1->array = NULL;
355
356                 return WERR_NOT_SUPPORTED;
357         }
358         case 2:
359         {
360                 r->out.ctr.ctr2 = talloc_p(mem_ctx, struct srvsvc_NetSessCtr2);
361                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr2);
362
363                 r->out.ctr.ctr2->count = 0;
364                 r->out.ctr.ctr2->array = NULL;
365
366                 return WERR_NOT_SUPPORTED;
367         }
368         case 10:
369         {
370                 r->out.ctr.ctr10 = talloc_p(mem_ctx, struct srvsvc_NetSessCtr10);
371                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr10);
372
373                 r->out.ctr.ctr2->count = 0;
374                 r->out.ctr.ctr2->array = NULL;
375
376                 return WERR_NOT_SUPPORTED;
377         }
378         case 502:
379         {
380                 r->out.ctr.ctr502 = talloc_p(mem_ctx, struct srvsvc_NetSessCtr502);
381                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr502);
382
383                 r->out.ctr.ctr2->count = 0;
384                 r->out.ctr.ctr2->array = NULL;
385
386                 return WERR_NOT_SUPPORTED;
387         }
388         default:
389                 return WERR_UNKNOWN_LEVEL;
390         }
391
392         return WERR_UNKNOWN_LEVEL;
393 }
394
395
396 /* 
397   srvsvc_NetSessDel 
398 */
399 static WERROR srvsvc_NetSessDel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
400                        struct srvsvc_NetSessDel *r)
401 {
402         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
403 }
404
405
406 /* 
407   srvsvc_NetShareAdd 
408 */
409 static WERROR srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
410                        struct srvsvc_NetShareAdd *r)
411 {
412         switch (r->in.level) {
413         case 0:
414         {
415                 if (r->in.parm_error) {
416                         r->out.parm_error = r->in.parm_error;
417                 }
418                 return WERR_NOT_SUPPORTED;
419         }
420         case 1:
421         {
422                 if (r->in.parm_error) {
423                         r->out.parm_error = r->in.parm_error;
424                 }
425                 return WERR_NOT_SUPPORTED;
426         }
427         case 2:
428         {
429                 if (r->in.parm_error) {
430                         r->out.parm_error = r->in.parm_error;
431                 }
432                 return WERR_NOT_SUPPORTED;
433         }
434         case 501:
435         {       
436                 if (r->in.parm_error) {
437                         r->out.parm_error = r->in.parm_error;
438                 }
439                 return WERR_NOT_SUPPORTED;
440         }
441         case 502:
442         {
443                 if (r->in.parm_error) {
444                         r->out.parm_error = r->in.parm_error;
445                 }
446                 return WERR_NOT_SUPPORTED;
447         }
448         default:
449                 return WERR_UNKNOWN_LEVEL;
450         }
451
452         return WERR_UNKNOWN_LEVEL;
453 }
454
455 static WERROR srvsvc_fiel_ShareInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
456                                    int snum, uint32_t level, union srvsvc_NetShareInfo *info)
457 {
458         struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
459
460         switch (level) {
461         case 0:
462         {
463                 info->info0->name       = dcesrv_common_get_share_name(mem_ctx, dce_ctx, snum);
464                 W_ERROR_HAVE_NO_MEMORY(info->info0->name);
465
466                 return WERR_OK;
467         }
468         case 1:
469         {
470                 info->info1->name       = dcesrv_common_get_share_name(mem_ctx, dce_ctx, snum);
471                 W_ERROR_HAVE_NO_MEMORY(info->info1->name);
472                 info->info1->type       = dcesrv_common_get_share_type(mem_ctx, dce_ctx, snum);
473                 info->info1->comment    = dcesrv_common_get_share_comment(mem_ctx, dce_ctx, snum);
474                 W_ERROR_HAVE_NO_MEMORY(info->info1->comment);
475
476                 return WERR_OK;
477         }
478         case 2:
479         {
480                 info->info2->name               = dcesrv_common_get_share_name(mem_ctx, dce_ctx, snum);
481                 W_ERROR_HAVE_NO_MEMORY(info->info2->name);
482                 info->info2->type               = dcesrv_common_get_share_type(mem_ctx, dce_ctx, snum);
483                 info->info2->comment            = dcesrv_common_get_share_comment(mem_ctx, dce_ctx, snum);
484                 W_ERROR_HAVE_NO_MEMORY(info->info2->comment);
485                 info->info2->permissions        = dcesrv_common_get_share_permissions(mem_ctx, dce_ctx, snum);
486                 info->info2->max_users  = dcesrv_common_get_share_max_users(mem_ctx, dce_ctx, snum);
487                 info->info2->current_users      = dcesrv_common_get_share_current_users(mem_ctx, dce_ctx, snum);
488                 info->info2->path               = dcesrv_common_get_share_path(mem_ctx, dce_ctx, snum);
489                 W_ERROR_HAVE_NO_MEMORY(info->info2->path);
490                 info->info2->password           = dcesrv_common_get_share_password(mem_ctx, dce_ctx, snum);
491
492                 return WERR_OK;
493         }
494         case 501:
495         {
496                 info->info501->name             = dcesrv_common_get_share_name(mem_ctx, dce_ctx, snum);
497                 W_ERROR_HAVE_NO_MEMORY(info->info501->name);
498                 info->info501->type             = dcesrv_common_get_share_type(mem_ctx, dce_ctx, snum);
499                 info->info501->comment          = dcesrv_common_get_share_comment(mem_ctx, dce_ctx, snum);
500                 W_ERROR_HAVE_NO_MEMORY(info->info501->comment);
501                 info->info501->csc_policy       = dcesrv_common_get_share_csc_policy(mem_ctx, dce_ctx, snum);
502
503                 return WERR_OK;
504         }
505         case 502:
506         {
507                 info->info502->name             = dcesrv_common_get_share_name(mem_ctx, dce_ctx, snum);
508                 W_ERROR_HAVE_NO_MEMORY(info->info502->name);
509                 info->info502->type             = dcesrv_common_get_share_type(mem_ctx, dce_ctx, snum);
510                 info->info502->comment          = dcesrv_common_get_share_comment(mem_ctx, dce_ctx, snum);
511                 W_ERROR_HAVE_NO_MEMORY(info->info502->comment);
512                 info->info502->permissions      = dcesrv_common_get_share_permissions(mem_ctx, dce_ctx, snum);
513                 info->info502->max_users        = dcesrv_common_get_share_max_users(mem_ctx, dce_ctx, snum);
514                 info->info502->current_users    = dcesrv_common_get_share_current_users(mem_ctx, dce_ctx, snum);
515                 info->info502->path             = dcesrv_common_get_share_path(mem_ctx, dce_ctx, snum);
516                 W_ERROR_HAVE_NO_MEMORY(info->info502->path);
517                 info->info502->password         = dcesrv_common_get_share_password(mem_ctx, dce_ctx, snum);
518                 info->info502->unknown          = dcesrv_common_get_share_unknown(mem_ctx, dce_ctx, snum);
519                 info->info502->sd               = dcesrv_common_get_security_descriptor(mem_ctx, dce_ctx, snum);
520
521                 return WERR_OK;
522         }
523         case 1005:
524         {
525                 info->info1005->dfs_flags       = dcesrv_common_get_share_dfs_flags(mem_ctx, dce_ctx, snum);
526
527                 return WERR_OK;
528         }
529         default:
530                 return WERR_UNKNOWN_LEVEL;
531         }
532
533         return WERR_UNKNOWN_LEVEL;
534 }
535
536 /* 
537   srvsvc_NetShareEnumAll
538 */
539 static WERROR srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
540                                      struct srvsvc_NetShareEnumAll *r)
541 {
542         struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
543
544         r->out.level = r->in.level;
545         ZERO_STRUCT(r->out.ctr);
546         r->out.totalentries = 0;
547         r->out.resume_handle = NULL;
548
549         /* TODO: - paging of results 
550          *       - access check
551          */
552
553         switch (r->in.level) {
554         case 0:
555         {
556                 int i;
557                 struct srvsvc_NetShareCtr0 *ctr0;
558
559                 ctr0 = talloc_p(mem_ctx, struct srvsvc_NetShareCtr0);
560                 W_ERROR_HAVE_NO_MEMORY(ctr0);
561
562                 ctr0->count = dcesrv_common_get_count_of_shares(mem_ctx, dce_ctx);
563                 ctr0->array = NULL;
564
565                 if (ctr0->count == 0) {
566                         r->out.ctr.ctr0 = ctr0;
567                         return WERR_OK;
568                 }
569
570                 ctr0->array = talloc_array_p(mem_ctx, struct srvsvc_NetShareInfo0, ctr0->count);
571                 W_ERROR_HAVE_NO_MEMORY(ctr0->array);
572
573                 for (i=0; i < ctr0->count; i++) {
574                         WERROR status;
575                         union srvsvc_NetShareInfo info;
576
577                         info.info0 = &ctr0->array[i];
578                         status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, i, r->in.level, &info);
579                         if (!W_ERROR_IS_OK(status)) {
580                                 return status;
581                         }
582                 }
583
584                 r->out.ctr.ctr0         = ctr0;
585                 r->out.totalentries     = r->out.ctr.ctr0->count;
586                 return WERR_OK;
587         }
588         case 1:
589         {
590                 int i;
591                 struct srvsvc_NetShareCtr1 *ctr1;
592
593                 ctr1 = talloc_p(mem_ctx, struct srvsvc_NetShareCtr1);
594                 W_ERROR_HAVE_NO_MEMORY(ctr1);
595
596                 ctr1->count = dcesrv_common_get_count_of_shares(mem_ctx, dce_ctx);
597                 ctr1->array = NULL;
598
599                 if (ctr1->count == 0) {
600                         r->out.ctr.ctr1 = ctr1;
601                         return WERR_OK;
602                 }
603
604                 ctr1->array = talloc_array_p(mem_ctx, struct srvsvc_NetShareInfo1, ctr1->count);
605                 W_ERROR_HAVE_NO_MEMORY(ctr1->array);
606
607                 for (i=0; i < ctr1->count; i++) {
608                         WERROR status;
609                         union srvsvc_NetShareInfo info;
610
611                         info.info1 = &ctr1->array[i];
612                         status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, i, r->in.level, &info);
613                         if (!W_ERROR_IS_OK(status)) {
614                                 return status;
615                         }
616                 }
617
618                 r->out.ctr.ctr1         = ctr1;
619                 r->out.totalentries     = r->out.ctr.ctr1->count;
620                 return WERR_OK;
621         }
622         case 2:
623         {
624                 int i;
625                 struct srvsvc_NetShareCtr2 *ctr2;
626
627                 ctr2 = talloc_p(mem_ctx, struct srvsvc_NetShareCtr2);
628                 W_ERROR_HAVE_NO_MEMORY(ctr2);
629
630                 ctr2->count = dcesrv_common_get_count_of_shares(mem_ctx, dce_ctx);
631                 ctr2->array = NULL;
632
633                 if (ctr2->count == 0) {
634                         r->out.ctr.ctr2 = ctr2;
635                         return WERR_OK;
636                 }
637
638                 ctr2->array = talloc_array_p(mem_ctx, struct srvsvc_NetShareInfo2, ctr2->count);
639                 W_ERROR_HAVE_NO_MEMORY(ctr2->array);
640
641                 for (i=0; i < ctr2->count; i++) {
642                         WERROR status;
643                         union srvsvc_NetShareInfo info;
644
645                         info.info2 = &ctr2->array[i];
646                         status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, i, r->in.level, &info);
647                         if (!W_ERROR_IS_OK(status)) {
648                                 return status;
649                         }
650                 }
651
652                 r->out.ctr.ctr2         = ctr2;
653                 r->out.totalentries     = r->out.ctr.ctr2->count;
654                 return WERR_OK;
655         }
656         case 501:
657         {
658                 int i;
659                 struct srvsvc_NetShareCtr501 *ctr501;
660
661                 ctr501 = talloc_p(mem_ctx, struct srvsvc_NetShareCtr501);
662                 W_ERROR_HAVE_NO_MEMORY(ctr501);
663
664                 ctr501->count = dcesrv_common_get_count_of_shares(mem_ctx, dce_ctx);
665                 ctr501->array = NULL;
666
667                 if (ctr501->count == 0) {
668                         r->out.ctr.ctr501 = ctr501;
669                         return WERR_OK;
670                 }
671
672                 ctr501->array = talloc_array_p(mem_ctx, struct srvsvc_NetShareInfo501, ctr501->count);
673                 W_ERROR_HAVE_NO_MEMORY(ctr501->array);
674
675                 for (i=0; i < ctr501->count; i++) {
676                         WERROR status;
677                         union srvsvc_NetShareInfo info;
678
679                         info.info501 = &ctr501->array[i];
680                         status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, i, r->in.level, &info);
681                         if (!W_ERROR_IS_OK(status)) {
682                                 return status;
683                         }
684                 }
685
686                 r->out.ctr.ctr501       = ctr501;
687                 r->out.totalentries     = r->out.ctr.ctr501->count;
688                 return WERR_OK;
689         }
690         case 502:
691         {
692                 int i;
693                 struct srvsvc_NetShareCtr502 *ctr502;
694
695                 ctr502 = talloc_p(mem_ctx, struct srvsvc_NetShareCtr502);
696                 W_ERROR_HAVE_NO_MEMORY(ctr502);
697
698                 ctr502->count = dcesrv_common_get_count_of_shares(mem_ctx, dce_ctx);
699                 ctr502->array = NULL;
700
701                 if (ctr502->count == 0) {
702                         r->out.ctr.ctr502 = ctr502;
703                         return WERR_OK;
704                 }
705
706                 ctr502->array = talloc_array_p(mem_ctx, struct srvsvc_NetShareInfo502, ctr502->count);
707                 W_ERROR_HAVE_NO_MEMORY(ctr502->array);
708
709                 for (i=0; i < ctr502->count; i++) {
710                         WERROR status;
711                         union srvsvc_NetShareInfo info;
712
713                         info.info502 = &ctr502->array[i];
714                         status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, i, r->in.level, &info);
715                         if (!W_ERROR_IS_OK(status)) {
716                                 return status;
717                         }
718                 }
719
720                 r->out.ctr.ctr502       = ctr502;
721                 r->out.totalentries     = r->out.ctr.ctr502->count;
722                 return WERR_OK;
723         }
724         default:
725                 return WERR_UNKNOWN_LEVEL;
726         }
727
728         return WERR_UNKNOWN_LEVEL;
729 }
730
731
732 /* 
733   srvsvc_NetShareGetInfo 
734 */
735 static WERROR srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
736                                      struct srvsvc_NetShareGetInfo *r)
737 {
738         int snum;
739
740         ZERO_STRUCT(r->out);
741
742         /* TODO: - access check
743          */
744
745         if (strcmp("", r->in.share_name) == 0) {
746                 return WERR_INVALID_PARAM;
747         }
748
749         snum = lp_servicenumber(r->in.share_name);
750         if (snum < 0) {
751                 return WERR_NET_NAME_NOT_FOUND;
752         }
753
754         switch (r->in.level) {
755         case 0:
756         {
757                 WERROR status;
758                 union srvsvc_NetShareInfo info;
759
760                 info.info0 = talloc_p(mem_ctx, struct srvsvc_NetShareInfo0);
761                 W_ERROR_HAVE_NO_MEMORY(info.info0);
762
763                 status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, snum, r->in.level, &info);
764                 if (!W_ERROR_IS_OK(status)) {
765                         return status;
766                 }
767
768                 r->out.info.info0 = info.info0;
769                 return WERR_OK;
770         }
771         case 1:
772         {
773                 WERROR status;
774                 union srvsvc_NetShareInfo info;
775
776                 info.info1 = talloc_p(mem_ctx, struct srvsvc_NetShareInfo1);
777                 W_ERROR_HAVE_NO_MEMORY(info.info1);
778
779                 status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, snum, r->in.level, &info);
780                 if (!W_ERROR_IS_OK(status)) {
781                         return status;
782                 }
783
784                 r->out.info.info1 = info.info1;
785                 return WERR_OK;
786         }
787         case 2:
788         {
789                 WERROR status;
790                 union srvsvc_NetShareInfo info;
791
792                 info.info2 = talloc_p(mem_ctx, struct srvsvc_NetShareInfo2);
793                 W_ERROR_HAVE_NO_MEMORY(info.info2);
794
795                 status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, snum, r->in.level, &info);
796                 if (!W_ERROR_IS_OK(status)) {
797                         return status;
798                 }
799
800                 r->out.info.info2 = info.info2;
801                 return WERR_OK;
802         }
803         case 501:
804         {
805                 WERROR status;
806                 union srvsvc_NetShareInfo info;
807
808                 info.info501 = talloc_p(mem_ctx, struct srvsvc_NetShareInfo501);
809                 W_ERROR_HAVE_NO_MEMORY(info.info501);
810
811                 status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, snum, r->in.level, &info);
812                 if (!W_ERROR_IS_OK(status)) {
813                         return status;
814                 }
815
816                 r->out.info.info501 = info.info501;
817                 return WERR_OK;
818         }
819         case 502:
820         {
821                 WERROR status;
822                 union srvsvc_NetShareInfo info;
823
824                 info.info502 = talloc_p(mem_ctx, struct srvsvc_NetShareInfo502);
825                 W_ERROR_HAVE_NO_MEMORY(info.info502);
826
827                 status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, snum, r->in.level, &info);
828                 if (!W_ERROR_IS_OK(status)) {
829                         return status;
830                 }
831
832                 r->out.info.info502 = info.info502;
833                 return WERR_OK;
834         }
835         case 1005:
836         {
837                 WERROR status;
838                 union srvsvc_NetShareInfo info;
839
840                 info.info1005 = talloc_p(mem_ctx, struct srvsvc_NetShareInfo1005);
841                 W_ERROR_HAVE_NO_MEMORY(info.info1005);
842
843                 status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, snum, r->in.level, &info);
844                 if (!W_ERROR_IS_OK(status)) {
845                         return status;
846                 }
847
848                 r->out.info.info1005 = info.info1005;
849                 return WERR_OK;
850         }
851         default:
852                 return WERR_UNKNOWN_LEVEL;
853         }
854
855         return WERR_UNKNOWN_LEVEL;
856 }
857
858
859 /* 
860   srvsvc_NetShareSetInfo 
861 */
862 static WERROR srvsvc_NetShareSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
863                        struct srvsvc_NetShareSetInfo *r)
864 {
865         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
866 }
867
868
869 /* 
870   srvsvc_NetShareDel 
871 */
872 static WERROR srvsvc_NetShareDel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
873                        struct srvsvc_NetShareDel *r)
874 {
875         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
876 }
877
878
879 /* 
880   srvsvc_NetShareDelSticky 
881 */
882 static WERROR srvsvc_NetShareDelSticky(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
883                        struct srvsvc_NetShareDelSticky *r)
884 {
885         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
886 }
887
888
889 /* 
890   srvsvc_NetShareCheck 
891 */
892 static WERROR srvsvc_NetShareCheck(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
893                        struct srvsvc_NetShareCheck *r)
894 {
895         ZERO_STRUCT(r->out);
896
897         /* TODO: - access check
898          */
899
900         if (strcmp("", r->in.device_name) == 0) {
901                 r->out.type = STYPE_IPC;
902                 return WERR_OK;
903         }
904
905         if (strcmp("C:\\", r->in.device_name) == 0) {
906                 r->out.type = STYPE_DISKTREE;
907                 return WERR_OK;
908         }
909
910         /* TODO: - lookup the share be devicename (path) */
911         return WERR_DEVICE_NOT_SHARED;
912 }
913
914
915 /* 
916   srvsvc_NetSrvGetInfo 
917 */
918 static WERROR srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
919                        struct srvsvc_NetSrvGetInfo *r)
920 {
921         struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
922
923         ZERO_STRUCT(r->out);
924
925         switch (r->in.level) {
926         case 100:
927         {
928                 struct srvsvc_NetSrvInfo100 *info100;
929
930                 info100 = talloc_p(mem_ctx, struct srvsvc_NetSrvInfo100);
931                 W_ERROR_HAVE_NO_MEMORY(info100);
932
933                 info100->platform_id    = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
934                 info100->server_name    = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
935                 W_ERROR_HAVE_NO_MEMORY(info100->server_name);
936
937                 r->out.info.info100 = info100;
938                 return WERR_OK;
939         }
940         case 101:
941         {
942                 struct srvsvc_NetSrvInfo101 *info101;
943
944                 info101 = talloc_p(mem_ctx, struct srvsvc_NetSrvInfo101);
945                 W_ERROR_HAVE_NO_MEMORY(info101);
946
947                 info101->platform_id    = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
948                 info101->server_name    = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
949                 W_ERROR_HAVE_NO_MEMORY(info101->server_name);
950
951                 info101->version_major  = dcesrv_common_get_version_major(mem_ctx, dce_ctx);
952                 info101->version_minor  = dcesrv_common_get_version_minor(mem_ctx, dce_ctx);
953                 info101->server_type    = dcesrv_common_get_server_type(mem_ctx, dce_ctx);
954                 info101->comment        = talloc_strdup(mem_ctx, lp_serverstring());
955                 W_ERROR_HAVE_NO_MEMORY(info101->comment);
956
957                 r->out.info.info101 = info101;
958                 return WERR_OK;
959         }
960         default:
961                 return WERR_UNKNOWN_LEVEL;
962         }
963
964         return WERR_UNKNOWN_LEVEL;
965 }
966
967
968 /* 
969   srvsvc_NetSrvSetInfo 
970 */
971 static WERROR srvsvc_NetSrvSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
972                        struct srvsvc_NetSrvSetInfo *r)
973 {
974         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
975 }
976
977
978 /* 
979   srvsvc_NetDiskEnum 
980 */
981 static WERROR srvsvc_NetDiskEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
982                        struct srvsvc_NetDiskEnum *r)
983 {
984         r->out.count = 0;
985         r->out.ctr0 = NULL;
986         r->out.totalentries = 0;
987         r->out.resume_handle = NULL;
988
989         switch (r->in.level) {
990         case 0:
991         {
992                 r->out.ctr0 = talloc_p(mem_ctx, struct srvsvc_NetDiskCtr0);
993                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr0);
994
995                 r->out.ctr0->unknown = 0x1;
996                 r->out.ctr0->count = 0;
997                 r->out.ctr0->array = NULL;
998
999                 return WERR_NOT_SUPPORTED;
1000         }
1001         default:
1002                 return WERR_UNKNOWN_LEVEL;
1003         }
1004
1005         return WERR_UNKNOWN_LEVEL;
1006 }
1007
1008
1009 /* 
1010   srvsvc_NETRSERVERSTATISTICSGET 
1011 */
1012 static WERROR srvsvc_NETRSERVERSTATISTICSGET(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1013                                              struct srvsvc_NETRSERVERSTATISTICSGET *r)
1014 {
1015         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1016 }
1017
1018
1019 /* 
1020   srvsvc_NETRSERVERTRANSPORTADD 
1021 */
1022 static WERROR srvsvc_NETRSERVERTRANSPORTADD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1023                        struct srvsvc_NETRSERVERTRANSPORTADD *r)
1024 {
1025         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1026 }
1027
1028
1029 /* 
1030   srvsvc_NetTransportEnum 
1031 */
1032 static WERROR srvsvc_NetTransportEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1033                        struct srvsvc_NetTransportEnum *r)
1034 {
1035         r->out.level = r->in.level;
1036         r->out.totalentries = 0;
1037         r->out.resume_handle = NULL;
1038
1039         switch (r->in.level) {
1040         case 0:
1041         {
1042                 r->out.ctr.ctr0 = talloc_p(mem_ctx, struct srvsvc_NetTransportCtr0);
1043                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr0);
1044
1045                 r->out.ctr.ctr0->count = 0;
1046                 r->out.ctr.ctr0->array = NULL;
1047
1048                 return WERR_NOT_SUPPORTED;
1049         }
1050         case 1:
1051         {
1052                 r->out.ctr.ctr1 = talloc_p(mem_ctx, struct srvsvc_NetTransportCtr1);
1053                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr1);
1054
1055                 r->out.ctr.ctr1->count = 0;
1056                 r->out.ctr.ctr1->array = NULL;
1057
1058                 return WERR_NOT_SUPPORTED;
1059         }
1060         case 2:
1061         {
1062                 r->out.ctr.ctr2 = talloc_p(mem_ctx, struct srvsvc_NetTransportCtr2);
1063                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr2);
1064
1065                 r->out.ctr.ctr2->count = 0;
1066                 r->out.ctr.ctr2->array = NULL;
1067
1068                 return WERR_NOT_SUPPORTED;
1069         }
1070         case 3:
1071         {
1072                 r->out.ctr.ctr3 = talloc_p(mem_ctx, struct srvsvc_NetTransportCtr3);
1073                 W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr3);
1074
1075                 r->out.ctr.ctr3->count = 0;
1076                 r->out.ctr.ctr3->array = NULL;
1077
1078                 return WERR_NOT_SUPPORTED;
1079         }
1080         default:
1081                 return WERR_UNKNOWN_LEVEL;
1082         }
1083
1084         return WERR_UNKNOWN_LEVEL;
1085 }
1086
1087
1088 /* 
1089   srvsvc_NETRSERVERTRANSPORTDEL 
1090 */
1091 static WERROR srvsvc_NETRSERVERTRANSPORTDEL(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1092                        struct srvsvc_NETRSERVERTRANSPORTDEL *r)
1093 {
1094         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1095 }
1096
1097
1098 /* 
1099   srvsvc_NetRemoteTOD 
1100 */
1101 static WERROR srvsvc_NetRemoteTOD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1102                        struct srvsvc_NetRemoteTOD *r)
1103 {
1104         struct timeval tval;
1105         time_t t;
1106         struct tm tm;
1107
1108         r->out.info = talloc_p(mem_ctx, struct srvsvc_NetRemoteTODInfo);
1109         W_ERROR_HAVE_NO_MEMORY(r->out.info);
1110
1111         GetTimeOfDay(&tval);
1112         t = tval.tv_sec;
1113
1114         gmtime_r(&t, &tm);
1115
1116         r->out.info->elapsed    = t;
1117         /* TODO: fake the uptime: just return the milliseconds till 0:00:00 today */
1118         r->out.info->msecs      = (tm.tm_hour*60*60*1000)
1119                                 + (tm.tm_min*60*1000)
1120                                 + (tm.tm_sec*1000)
1121                                 + (tval.tv_usec/1000);
1122         r->out.info->hours      = tm.tm_hour;
1123         r->out.info->mins       = tm.tm_min;
1124         r->out.info->secs       = tm.tm_sec;
1125         r->out.info->hunds      = tval.tv_usec/10000;
1126         r->out.info->timezone   = get_time_zone(t)/60;
1127         r->out.info->tinterval  = 310; /* just return the same as windows */
1128         r->out.info->day        = tm.tm_mday;
1129         r->out.info->month      = tm.tm_mon + 1;
1130         r->out.info->year       = tm.tm_year + 1900;
1131         r->out.info->weekday    = tm.tm_wday;
1132
1133         return WERR_OK;
1134 }
1135
1136
1137 /* 
1138   srvsvc_NETRSERVERSETSERVICEBITS 
1139 */
1140 static WERROR srvsvc_NETRSERVERSETSERVICEBITS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1141                        struct srvsvc_NETRSERVERSETSERVICEBITS *r)
1142 {
1143         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1144 }
1145
1146
1147 /* 
1148   srvsvc_NETRPRPATHTYPE 
1149 */
1150 static WERROR srvsvc_NETRPRPATHTYPE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1151                        struct srvsvc_NETRPRPATHTYPE *r)
1152 {
1153         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1154 }
1155
1156
1157 /* 
1158   srvsvc_NETRPRPATHCANONICALIZE 
1159 */
1160 static WERROR srvsvc_NETRPRPATHCANONICALIZE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1161                        struct srvsvc_NETRPRPATHCANONICALIZE *r)
1162 {
1163         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1164 }
1165
1166
1167 /* 
1168   srvsvc_NETRPRPATHCOMPARE 
1169 */
1170 static WERROR srvsvc_NETRPRPATHCOMPARE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1171                        struct srvsvc_NETRPRPATHCOMPARE *r)
1172 {
1173         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1174 }
1175
1176
1177 /* 
1178   srvsvc_NET_NAME_VALIDATE 
1179 */
1180 static WERROR srvsvc_NET_NAME_VALIDATE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1181                        struct srvsvc_NET_NAME_VALIDATE *r)
1182 {
1183         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1184 }
1185
1186
1187 /* 
1188   srvsvc_NETRPRNAMECANONICALIZE 
1189 */
1190 static WERROR srvsvc_NETRPRNAMECANONICALIZE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1191                        struct srvsvc_NETRPRNAMECANONICALIZE *r)
1192 {
1193         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1194 }
1195
1196
1197 /* 
1198   srvsvc_NETRPRNAMECOMPARE 
1199 */
1200 static WERROR srvsvc_NETRPRNAMECOMPARE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1201                        struct srvsvc_NETRPRNAMECOMPARE *r)
1202 {
1203         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1204 }
1205
1206
1207 /* 
1208   srvsvc_NetShareEnum 
1209 */
1210 static WERROR srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1211                                   struct srvsvc_NetShareEnum *r)
1212 {
1213         struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
1214
1215         r->out.level = r->in.level;
1216         ZERO_STRUCT(r->out.ctr);
1217         r->out.totalentries = 0;
1218         r->out.resume_handle = NULL;
1219
1220         /* TODO: - paging of results 
1221          *       - access check
1222          */
1223
1224         switch (r->in.level) {
1225         case 0:
1226         {
1227                 int i;
1228                 uint32_t count;
1229                 struct srvsvc_NetShareCtr0 *ctr0;
1230
1231                 ctr0 = talloc_p(mem_ctx, struct srvsvc_NetShareCtr0);
1232                 W_ERROR_HAVE_NO_MEMORY(ctr0);
1233
1234                 ctr0->count = dcesrv_common_get_count_of_shares(mem_ctx, dce_ctx);
1235                 ctr0->array = NULL;
1236
1237                 if (ctr0->count == 0) {
1238                         r->out.ctr.ctr0 = ctr0;
1239                         return WERR_OK;
1240                 }
1241
1242                 ctr0->array = talloc_array_p(mem_ctx, struct srvsvc_NetShareInfo0, ctr0->count);
1243                 W_ERROR_HAVE_NO_MEMORY(ctr0->array);
1244
1245                 count           = ctr0->count;
1246                 ctr0->count     = 0;
1247                 for (i=0; i < count; i++) {
1248                         WERROR status;
1249                         union srvsvc_NetShareInfo info;
1250
1251                         if (!lp_browseable(i)){
1252                                 continue;
1253                         }
1254
1255                         info.info0 = &ctr0->array[ctr0->count++];
1256                         status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, i, r->in.level, &info);
1257                         if (!W_ERROR_IS_OK(status)) {
1258                                 return status;
1259                         }
1260                 }
1261
1262                 r->out.ctr.ctr0         = ctr0;
1263                 r->out.totalentries     = r->out.ctr.ctr0->count;
1264                 return WERR_OK;
1265         }
1266         case 1:
1267         {
1268                 int i;
1269                 uint32_t count;
1270                 struct srvsvc_NetShareCtr1 *ctr1;
1271
1272                 ctr1 = talloc_p(mem_ctx, struct srvsvc_NetShareCtr1);
1273                 W_ERROR_HAVE_NO_MEMORY(ctr1);
1274
1275                 ctr1->count = dcesrv_common_get_count_of_shares(mem_ctx, dce_ctx);
1276                 ctr1->array = NULL;
1277
1278                 if (ctr1->count == 0) {
1279                         r->out.ctr.ctr1 = ctr1;
1280                         return WERR_OK;
1281                 }
1282
1283                 ctr1->array = talloc_array_p(mem_ctx, struct srvsvc_NetShareInfo1, ctr1->count);
1284                 W_ERROR_HAVE_NO_MEMORY(ctr1->array);
1285
1286                 count           = ctr1->count;
1287                 ctr1->count     = 0;
1288                 for (i=0; i < count; i++) {
1289                         WERROR status;
1290                         union srvsvc_NetShareInfo info;
1291
1292                         if (!lp_browseable(i)){
1293                                 continue;
1294                         }
1295
1296                         info.info1 = &ctr1->array[ctr1->count++];
1297                         status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, i, r->in.level, &info);
1298                         if (!W_ERROR_IS_OK(status)) {
1299                                 return status;
1300                         }
1301                 }
1302
1303                 r->out.ctr.ctr1         = ctr1;
1304                 r->out.totalentries     = r->out.ctr.ctr1->count;
1305                 return WERR_OK;
1306         }
1307         case 2:
1308         {
1309                 int i;
1310                 uint32_t count;
1311                 struct srvsvc_NetShareCtr2 *ctr2;
1312
1313                 ctr2 = talloc_p(mem_ctx, struct srvsvc_NetShareCtr2);
1314                 W_ERROR_HAVE_NO_MEMORY(ctr2);
1315
1316                 ctr2->count = dcesrv_common_get_count_of_shares(mem_ctx, dce_ctx);
1317                 ctr2->array = NULL;
1318
1319                 if (ctr2->count == 0) {
1320                         r->out.ctr.ctr2 = ctr2;
1321                         return WERR_OK;
1322                 }
1323
1324                 ctr2->array = talloc_array_p(mem_ctx, struct srvsvc_NetShareInfo2, ctr2->count);
1325                 W_ERROR_HAVE_NO_MEMORY(ctr2->array);
1326
1327                 count           = ctr2->count;
1328                 ctr2->count     = 0;
1329                 for (i=0; i < count; i++) {
1330                         WERROR status;
1331                         union srvsvc_NetShareInfo info;
1332
1333                         if (!lp_browseable(i)){
1334                                 continue;
1335                         }
1336
1337                         info.info2 = &ctr2->array[ctr2->count++];
1338                         status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, i, r->in.level, &info);
1339                         if (!W_ERROR_IS_OK(status)) {
1340                                 return status;
1341                         }
1342                 }
1343
1344                 r->out.ctr.ctr2         = ctr2;
1345                 r->out.totalentries     = r->out.ctr.ctr2->count;
1346                 return WERR_OK;
1347         }
1348         case 501:
1349         {
1350                 int i;
1351                 uint32_t count;
1352                 struct srvsvc_NetShareCtr501 *ctr501;
1353
1354                 ctr501 = talloc_p(mem_ctx, struct srvsvc_NetShareCtr501);
1355                 W_ERROR_HAVE_NO_MEMORY(ctr501);
1356
1357                 ctr501->count = dcesrv_common_get_count_of_shares(mem_ctx, dce_ctx);
1358                 ctr501->array = NULL;
1359
1360                 if (ctr501->count == 0) {
1361                         r->out.ctr.ctr501 = ctr501;
1362                         return WERR_OK;
1363                 }
1364
1365                 ctr501->array = talloc_array_p(mem_ctx, struct srvsvc_NetShareInfo501, ctr501->count);
1366                 W_ERROR_HAVE_NO_MEMORY(ctr501->array);
1367
1368                 count           = ctr501->count;
1369                 ctr501->count   = 0;
1370                 for (i=0; i < count; i++) {
1371                         WERROR status;
1372                         union srvsvc_NetShareInfo info;
1373
1374                         if (!lp_browseable(i)){
1375                                 continue;
1376                         }
1377
1378                         info.info501 = &ctr501->array[ctr501->count++];
1379                         status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, i, r->in.level, &info);
1380                         if (!W_ERROR_IS_OK(status)) {
1381                                 return status;
1382                         }
1383                 }
1384
1385                 r->out.ctr.ctr501       = ctr501;
1386                 r->out.totalentries     = r->out.ctr.ctr501->count;
1387                 return WERR_OK;
1388         }
1389         case 502:
1390         {
1391                 int i;
1392                 uint32_t count;
1393                 struct srvsvc_NetShareCtr502 *ctr502;
1394
1395                 ctr502 = talloc_p(mem_ctx, struct srvsvc_NetShareCtr502);
1396                 W_ERROR_HAVE_NO_MEMORY(ctr502);
1397
1398                 ctr502->count = dcesrv_common_get_count_of_shares(mem_ctx, dce_ctx);
1399                 ctr502->array = NULL;
1400
1401                 if (ctr502->count == 0) {
1402                         r->out.ctr.ctr502 = ctr502;
1403                         return WERR_OK;
1404                 }
1405
1406                 ctr502->array = talloc_array_p(mem_ctx, struct srvsvc_NetShareInfo502, ctr502->count);
1407                 W_ERROR_HAVE_NO_MEMORY(ctr502->array);
1408
1409                 count           = ctr502->count;
1410                 ctr502->count   = 0;
1411                 for (i=0; i < count; i++) {
1412                         WERROR status;
1413                         union srvsvc_NetShareInfo info;
1414
1415                         if (!lp_browseable(i)){
1416                                 continue;
1417                         }
1418
1419                         info.info502 = &ctr502->array[ctr502->count++];
1420                         status = srvsvc_fiel_ShareInfo(dce_call, mem_ctx, i, r->in.level, &info);
1421                         if (!W_ERROR_IS_OK(status)) {
1422                                 return status;
1423                         }
1424                 }
1425
1426                 r->out.ctr.ctr502       = ctr502;
1427                 r->out.totalentries     = r->out.ctr.ctr502->count;
1428                 return WERR_OK;
1429         }
1430         default:
1431                 return WERR_UNKNOWN_LEVEL;
1432         }
1433
1434         return WERR_UNKNOWN_LEVEL;
1435 }
1436
1437
1438 /* 
1439   srvsvc_NETRSHAREDELSTART 
1440 */
1441 static WERROR srvsvc_NETRSHAREDELSTART(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1442                        struct srvsvc_NETRSHAREDELSTART *r)
1443 {
1444         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1445 }
1446
1447
1448 /* 
1449   srvsvc_NETRSHAREDELCOMMIT 
1450 */
1451 static WERROR srvsvc_NETRSHAREDELCOMMIT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1452                        struct srvsvc_NETRSHAREDELCOMMIT *r)
1453 {
1454         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1455 }
1456
1457
1458 /* 
1459   srvsvc_NET_FILE_QUERY_SECDESC 
1460 */
1461 static WERROR srvsvc_NET_FILE_QUERY_SECDESC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1462                        struct srvsvc_NET_FILE_QUERY_SECDESC *r)
1463 {
1464         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1465 }
1466
1467
1468 /* 
1469   srvsvc_NET_FILE_SET_SECDESC 
1470 */
1471 static WERROR srvsvc_NET_FILE_SET_SECDESC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1472                        struct srvsvc_NET_FILE_SET_SECDESC *r)
1473 {
1474         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1475 }
1476
1477
1478 /* 
1479   srvsvc_NETRSERVERTRANSPORTADDEX 
1480 */
1481 static WERROR srvsvc_NETRSERVERTRANSPORTADDEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1482                        struct srvsvc_NETRSERVERTRANSPORTADDEX *r)
1483 {
1484         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1485 }
1486
1487
1488 /* 
1489   srvsvc_NETRSERVERSETSERVICEBITSEX 
1490 */
1491 static WERROR srvsvc_NETRSERVERSETSERVICEBITSEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1492                        struct srvsvc_NETRSERVERSETSERVICEBITSEX *r)
1493 {
1494         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1495 }
1496
1497
1498 /* 
1499   srvsvc_NETRDFSGETVERSION 
1500 */
1501 static WERROR srvsvc_NETRDFSGETVERSION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1502                        struct srvsvc_NETRDFSGETVERSION *r)
1503 {
1504         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1505 }
1506
1507
1508 /* 
1509   srvsvc_NETRDFSCREATELOCALPARTITION 
1510 */
1511 static WERROR srvsvc_NETRDFSCREATELOCALPARTITION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1512                        struct srvsvc_NETRDFSCREATELOCALPARTITION *r)
1513 {
1514         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1515 }
1516
1517
1518 /* 
1519   srvsvc_NETRDFSDELETELOCALPARTITION 
1520 */
1521 static WERROR srvsvc_NETRDFSDELETELOCALPARTITION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1522                        struct srvsvc_NETRDFSDELETELOCALPARTITION *r)
1523 {
1524         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1525 }
1526
1527
1528 /* 
1529   srvsvc_NETRDFSSETLOCALVOLUMESTATE 
1530 */
1531 static WERROR srvsvc_NETRDFSSETLOCALVOLUMESTATE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1532                        struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *r)
1533 {
1534         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1535 }
1536
1537
1538 /* 
1539   srvsvc_NETRDFSSETSERVERINFO 
1540 */
1541 static WERROR srvsvc_NETRDFSSETSERVERINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1542                        struct srvsvc_NETRDFSSETSERVERINFO *r)
1543 {
1544         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1545 }
1546
1547
1548 /* 
1549   srvsvc_NETRDFSCREATEEXITPOINT 
1550 */
1551 static WERROR srvsvc_NETRDFSCREATEEXITPOINT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1552                        struct srvsvc_NETRDFSCREATEEXITPOINT *r)
1553 {
1554         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1555 }
1556
1557
1558 /* 
1559   srvsvc_NETRDFSDELETEEXITPOINT 
1560 */
1561 static WERROR srvsvc_NETRDFSDELETEEXITPOINT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1562                        struct srvsvc_NETRDFSDELETEEXITPOINT *r)
1563 {
1564         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1565 }
1566
1567
1568 /* 
1569   srvsvc_NETRDFSMODIFYPREFIX 
1570 */
1571 static WERROR srvsvc_NETRDFSMODIFYPREFIX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1572                        struct srvsvc_NETRDFSMODIFYPREFIX *r)
1573 {
1574         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1575 }
1576
1577
1578 /* 
1579   srvsvc_NETRDFSFIXLOCALVOLUME 
1580 */
1581 static WERROR srvsvc_NETRDFSFIXLOCALVOLUME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1582                        struct srvsvc_NETRDFSFIXLOCALVOLUME *r)
1583 {
1584         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1585 }
1586
1587
1588 /* 
1589   srvsvc_NETRDFSMANAGERREPORTSITEINFO 
1590 */
1591 static WERROR srvsvc_NETRDFSMANAGERREPORTSITEINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1592                        struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r)
1593 {
1594         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1595 }
1596
1597
1598 /* 
1599   srvsvc_NETRSERVERTRANSPORTDELEX 
1600 */
1601 static WERROR srvsvc_NETRSERVERTRANSPORTDELEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1602                        struct srvsvc_NETRSERVERTRANSPORTDELEX *r)
1603 {
1604         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1605 }
1606
1607
1608 /* include the generated boilerplate */
1609 #include "librpc/gen_ndr/ndr_srvsvc_s.c"