s3/docs: Fix typo.
[Samba/gebeck_regimport.git] / source3 / rpcclient / cmd_srvsvc.c
blob10017fa19b4878b63c459e00c1b8a28053fc38e3
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
5 Copyright (C) Andrew Tridgell 1992-1999
6 Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
7 Copyright (C) Tim Potter 2000,2002
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "includes.h"
24 #include "rpcclient.h"
26 /* Display server query info */
28 static char *get_server_type_str(uint32 type)
30 static fstring typestr;
31 int i;
33 if (type == SV_TYPE_ALL) {
34 fstrcpy(typestr, "All");
35 return typestr;
38 typestr[0] = 0;
40 for (i = 0; i < 32; i++) {
41 if (type & (1 << i)) {
42 switch (1 << i) {
43 case SV_TYPE_WORKSTATION:
44 fstrcat(typestr, "Wk ");
45 break;
46 case SV_TYPE_SERVER:
47 fstrcat(typestr, "Sv ");
48 break;
49 case SV_TYPE_SQLSERVER:
50 fstrcat(typestr, "Sql ");
51 break;
52 case SV_TYPE_DOMAIN_CTRL:
53 fstrcat(typestr, "PDC ");
54 break;
55 case SV_TYPE_DOMAIN_BAKCTRL:
56 fstrcat(typestr, "BDC ");
57 break;
58 case SV_TYPE_TIME_SOURCE:
59 fstrcat(typestr, "Tim ");
60 break;
61 case SV_TYPE_AFP:
62 fstrcat(typestr, "AFP ");
63 break;
64 case SV_TYPE_NOVELL:
65 fstrcat(typestr, "Nov ");
66 break;
67 case SV_TYPE_DOMAIN_MEMBER:
68 fstrcat(typestr, "Dom ");
69 break;
70 case SV_TYPE_PRINTQ_SERVER:
71 fstrcat(typestr, "PrQ ");
72 break;
73 case SV_TYPE_DIALIN_SERVER:
74 fstrcat(typestr, "Din ");
75 break;
76 case SV_TYPE_SERVER_UNIX:
77 fstrcat(typestr, "Unx ");
78 break;
79 case SV_TYPE_NT:
80 fstrcat(typestr, "NT ");
81 break;
82 case SV_TYPE_WFW:
83 fstrcat(typestr, "Wfw ");
84 break;
85 case SV_TYPE_SERVER_MFPN:
86 fstrcat(typestr, "Mfp ");
87 break;
88 case SV_TYPE_SERVER_NT:
89 fstrcat(typestr, "SNT ");
90 break;
91 case SV_TYPE_POTENTIAL_BROWSER:
92 fstrcat(typestr, "PtB ");
93 break;
94 case SV_TYPE_BACKUP_BROWSER:
95 fstrcat(typestr, "BMB ");
96 break;
97 case SV_TYPE_MASTER_BROWSER:
98 fstrcat(typestr, "LMB ");
99 break;
100 case SV_TYPE_DOMAIN_MASTER:
101 fstrcat(typestr, "DMB ");
102 break;
103 case SV_TYPE_SERVER_OSF:
104 fstrcat(typestr, "OSF ");
105 break;
106 case SV_TYPE_SERVER_VMS:
107 fstrcat(typestr, "VMS ");
108 break;
109 case SV_TYPE_WIN95_PLUS:
110 fstrcat(typestr, "W95 ");
111 break;
112 case SV_TYPE_ALTERNATE_XPORT:
113 fstrcat(typestr, "Xpt ");
114 break;
115 case SV_TYPE_LOCAL_LIST_ONLY:
116 fstrcat(typestr, "Dom ");
117 break;
118 case SV_TYPE_DOMAIN_ENUM:
119 fstrcat(typestr, "Loc ");
120 break;
125 i = strlen(typestr) - 1;
127 if (typestr[i] == ' ')
128 typestr[i] = 0;
130 return typestr;
133 static void display_server(const char *sname, uint32 type, const char *comment)
135 printf("\t%-15.15s%-20s %s\n", sname, get_server_type_str(type),
136 comment);
139 static void display_srv_info_101(struct srvsvc_NetSrvInfo101 *r)
141 display_server(r->server_name, r->server_type, r->comment);
143 printf("\tplatform_id :\t%d\n", r->platform_id);
144 printf("\tos version :\t%d.%d\n",
145 r->version_major, r->version_minor);
146 printf("\tserver type :\t0x%x\n", r->server_type);
149 static void display_srv_info_102(struct srvsvc_NetSrvInfo102 *r)
151 display_server(r->server_name, r->server_type, r->comment);
153 printf("\tplatform_id :\t%d\n", r->platform_id);
154 printf("\tos version :\t%d.%d\n",
155 r->version_major, r->version_minor);
156 printf("\tserver type :\t0x%x\n", r->server_type);
158 printf("\tusers :\t%x\n", r->users);
159 printf("\tdisc, hidden :\t%x, %x\n", r->disc, r->hidden);
160 printf("\tannounce, delta :\t%d, %d\n", r->announce,
161 r->anndelta);
162 printf("\tlicenses :\t%d\n", r->licenses);
163 printf("\tuser path :\t%s\n", r->userpath);
166 /* Server query info */
167 static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
168 TALLOC_CTX *mem_ctx,
169 int argc, const char **argv)
171 uint32 info_level = 101;
172 union srvsvc_NetSrvInfo info;
173 WERROR result;
174 NTSTATUS status;
176 if (argc > 2) {
177 printf("Usage: %s [infolevel]\n", argv[0]);
178 return WERR_OK;
181 if (argc == 2)
182 info_level = atoi(argv[1]);
184 status = rpccli_srvsvc_NetSrvGetInfo(cli, mem_ctx,
185 cli->srv_name_slash,
186 info_level,
187 &info,
188 &result);
189 if (!NT_STATUS_IS_OK(status)) {
190 return ntstatus_to_werror(status);
193 if (!W_ERROR_IS_OK(result)) {
194 goto done;
197 /* Display results */
199 switch (info_level) {
200 case 101:
201 display_srv_info_101(info.info101);
202 break;
203 case 102:
204 display_srv_info_102(info.info102);
205 break;
206 default:
207 printf("unsupported info level %d\n", info_level);
208 break;
211 done:
212 return result;
215 static void display_share_info_1(struct srvsvc_NetShareInfo1 *r)
217 printf("netname: %s\n", r->name);
218 printf("\tremark:\t%s\n", r->comment);
221 static void display_share_info_2(struct srvsvc_NetShareInfo2 *r)
223 printf("netname: %s\n", r->name);
224 printf("\tremark:\t%s\n", r->comment);
225 printf("\tpath:\t%s\n", r->path);
226 printf("\tpassword:\t%s\n", r->password);
229 static void display_share_info_502(struct srvsvc_NetShareInfo502 *r)
231 printf("netname: %s\n", r->name);
232 printf("\tremark:\t%s\n", r->comment);
233 printf("\tpath:\t%s\n", r->path);
234 printf("\tpassword:\t%s\n", r->password);
236 printf("\ttype:\t0x%x\n", r->type);
237 printf("\tperms:\t%d\n", r->permissions);
238 printf("\tmax_uses:\t%d\n", r->max_users);
239 printf("\tnum_uses:\t%d\n", r->current_users);
241 if (r->sd_buf.sd)
242 display_sec_desc(r->sd_buf.sd);
246 static WERROR cmd_srvsvc_net_share_enum_int(struct rpc_pipe_client *cli,
247 TALLOC_CTX *mem_ctx,
248 int argc, const char **argv,
249 uint32_t opcode)
251 uint32 info_level = 2;
252 struct srvsvc_NetShareInfoCtr info_ctr;
253 struct srvsvc_NetShareCtr0 ctr0;
254 struct srvsvc_NetShareCtr1 ctr1;
255 struct srvsvc_NetShareCtr2 ctr2;
256 struct srvsvc_NetShareCtr501 ctr501;
257 struct srvsvc_NetShareCtr502 ctr502;
258 struct srvsvc_NetShareCtr1004 ctr1004;
259 struct srvsvc_NetShareCtr1005 ctr1005;
260 struct srvsvc_NetShareCtr1006 ctr1006;
261 struct srvsvc_NetShareCtr1007 ctr1007;
262 struct srvsvc_NetShareCtr1501 ctr1501;
263 WERROR result;
264 NTSTATUS status;
265 uint32_t totalentries = 0;
266 uint32_t resume_handle = 0;
267 uint32_t *resume_handle_p = NULL;
268 uint32 preferred_len = 0xffffffff, i;
270 if (argc > 3) {
271 printf("Usage: %s [infolevel] [resume_handle]\n", argv[0]);
272 return WERR_OK;
275 if (argc >= 2) {
276 info_level = atoi(argv[1]);
279 if (argc == 3) {
280 resume_handle = atoi(argv[2]);
281 resume_handle_p = &resume_handle;
284 ZERO_STRUCT(info_ctr);
286 info_ctr.level = info_level;
288 switch (info_level) {
289 case 0:
290 ZERO_STRUCT(ctr0);
291 info_ctr.ctr.ctr0 = &ctr0;
292 break;
293 case 1:
294 ZERO_STRUCT(ctr1);
295 info_ctr.ctr.ctr1 = &ctr1;
296 break;
297 case 2:
298 ZERO_STRUCT(ctr2);
299 info_ctr.ctr.ctr2 = &ctr2;
300 break;
301 case 501:
302 ZERO_STRUCT(ctr501);
303 info_ctr.ctr.ctr501 = &ctr501;
304 break;
305 case 502:
306 ZERO_STRUCT(ctr502);
307 info_ctr.ctr.ctr502 = &ctr502;
308 break;
309 case 1004:
310 ZERO_STRUCT(ctr1004);
311 info_ctr.ctr.ctr1004 = &ctr1004;
312 break;
313 case 1005:
314 ZERO_STRUCT(ctr1005);
315 info_ctr.ctr.ctr1005 = &ctr1005;
316 break;
317 case 1006:
318 ZERO_STRUCT(ctr1006);
319 info_ctr.ctr.ctr1006 = &ctr1006;
320 break;
321 case 1007:
322 ZERO_STRUCT(ctr1007);
323 info_ctr.ctr.ctr1007 = &ctr1007;
324 break;
325 case 1501:
326 ZERO_STRUCT(ctr1501);
327 info_ctr.ctr.ctr1501 = &ctr1501;
328 break;
331 switch (opcode) {
332 case NDR_SRVSVC_NETSHAREENUM:
333 status = rpccli_srvsvc_NetShareEnum(cli, mem_ctx,
334 cli->desthost,
335 &info_ctr,
336 preferred_len,
337 &totalentries,
338 resume_handle_p,
339 &result);
340 break;
341 case NDR_SRVSVC_NETSHAREENUMALL:
342 status = rpccli_srvsvc_NetShareEnumAll(cli, mem_ctx,
343 cli->desthost,
344 &info_ctr,
345 preferred_len,
346 &totalentries,
347 resume_handle_p,
348 &result);
349 break;
350 default:
351 return WERR_INVALID_PARAM;
354 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
355 goto done;
358 /* Display results */
360 switch (info_level) {
361 case 1:
362 for (i = 0; i < totalentries; i++)
363 display_share_info_1(&info_ctr.ctr.ctr1->array[i]);
364 break;
365 case 2:
366 for (i = 0; i < totalentries; i++)
367 display_share_info_2(&info_ctr.ctr.ctr2->array[i]);
368 break;
369 case 502:
370 for (i = 0; i < totalentries; i++)
371 display_share_info_502(&info_ctr.ctr.ctr502->array[i]);
372 break;
373 default:
374 printf("unsupported info level %d\n", info_level);
375 break;
378 done:
379 return result;
382 static WERROR cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli,
383 TALLOC_CTX *mem_ctx,
384 int argc, const char **argv)
386 return cmd_srvsvc_net_share_enum_int(cli, mem_ctx,
387 argc, argv,
388 NDR_SRVSVC_NETSHAREENUM);
391 static WERROR cmd_srvsvc_net_share_enum_all(struct rpc_pipe_client *cli,
392 TALLOC_CTX *mem_ctx,
393 int argc, const char **argv)
395 return cmd_srvsvc_net_share_enum_int(cli, mem_ctx,
396 argc, argv,
397 NDR_SRVSVC_NETSHAREENUMALL);
400 static WERROR cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
401 TALLOC_CTX *mem_ctx,
402 int argc, const char **argv)
404 uint32 info_level = 502;
405 union srvsvc_NetShareInfo info;
406 WERROR result;
407 NTSTATUS status;
409 if (argc < 2 || argc > 3) {
410 printf("Usage: %s [sharename] [infolevel]\n", argv[0]);
411 return WERR_OK;
414 if (argc == 3)
415 info_level = atoi(argv[2]);
417 status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
418 cli->desthost,
419 argv[1],
420 info_level,
421 &info,
422 &result);
424 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
425 goto done;
428 /* Display results */
430 switch (info_level) {
431 case 1:
432 display_share_info_1(info.info1);
433 break;
434 case 2:
435 display_share_info_2(info.info2);
436 break;
437 case 502:
438 display_share_info_502(info.info502);
439 break;
440 default:
441 printf("unsupported info level %d\n", info_level);
442 break;
445 done:
446 return result;
449 static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
450 TALLOC_CTX *mem_ctx,
451 int argc, const char **argv)
453 uint32 info_level = 502;
454 union srvsvc_NetShareInfo info_get;
455 WERROR result;
456 NTSTATUS status;
457 uint32_t parm_err = 0;
459 if (argc > 3) {
460 printf("Usage: %s [sharename] [comment]\n", argv[0]);
461 return WERR_OK;
464 /* retrieve share info */
465 status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
466 cli->desthost,
467 argv[1],
468 info_level,
469 &info_get,
470 &result);
472 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
473 goto done;
476 info_get.info502->comment = argv[2];
478 /* set share info */
479 status = rpccli_srvsvc_NetShareSetInfo(cli, mem_ctx,
480 cli->desthost,
481 argv[1],
482 info_level,
483 &info_get,
484 &parm_err,
485 &result);
487 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
488 goto done;
491 /* re-retrieve share info and display */
492 status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
493 cli->desthost,
494 argv[1],
495 info_level,
496 &info_get,
497 &result);
499 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
500 goto done;
503 display_share_info_502(info_get.info502);
505 done:
506 return result;
509 static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli,
510 TALLOC_CTX *mem_ctx,
511 int argc, const char **argv)
513 struct srvsvc_NetRemoteTODInfo *tod = NULL;
514 WERROR result;
515 NTSTATUS status;
517 if (argc > 1) {
518 printf("Usage: %s\n", argv[0]);
519 return WERR_OK;
522 status = rpccli_srvsvc_NetRemoteTOD(cli, mem_ctx,
523 cli->srv_name_slash,
524 &tod,
525 &result);
526 if (!NT_STATUS_IS_OK(status)) {
527 result = ntstatus_to_werror(status);
528 goto done;
531 if (!W_ERROR_IS_OK(result))
532 goto done;
534 done:
535 return result;
538 static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli,
539 TALLOC_CTX *mem_ctx,
540 int argc, const char **argv)
542 uint32 info_level = 3;
543 struct srvsvc_NetFileInfoCtr info_ctr;
544 struct srvsvc_NetFileCtr3 ctr3;
545 WERROR result;
546 NTSTATUS status;
547 uint32 preferred_len = 0xffff;
548 uint32_t total_entries = 0;
549 uint32_t resume_handle = 0;
551 if (argc > 2) {
552 printf("Usage: %s [infolevel]\n", argv[0]);
553 return WERR_OK;
556 if (argc == 2)
557 info_level = atoi(argv[1]);
559 ZERO_STRUCT(info_ctr);
560 ZERO_STRUCT(ctr3);
562 info_ctr.level = info_level;
563 info_ctr.ctr.ctr3 = &ctr3;
565 status = rpccli_srvsvc_NetFileEnum(cli, mem_ctx,
566 cli->desthost,
567 NULL,
568 NULL,
569 &info_ctr,
570 preferred_len,
571 &total_entries,
572 &resume_handle,
573 &result);
575 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result))
576 goto done;
578 done:
579 return result;
582 static WERROR cmd_srvsvc_net_name_validate(struct rpc_pipe_client *cli,
583 TALLOC_CTX *mem_ctx,
584 int argc, const char **argv)
586 WERROR result;
587 NTSTATUS status;
588 uint32_t name_type = 9;
589 uint32_t flags = 0;
591 if (argc < 2 || argc > 3) {
592 printf("Usage: %s [sharename] [type]\n", argv[0]);
593 return WERR_OK;
596 if (argc == 3) {
597 name_type = atoi(argv[2]);
600 status = rpccli_srvsvc_NetNameValidate(cli, mem_ctx,
601 cli->desthost,
602 argv[1],
603 name_type,
604 flags,
605 &result);
607 if (!W_ERROR_IS_OK(result))
608 goto done;
610 done:
611 return result;
614 static WERROR cmd_srvsvc_net_file_get_sec(struct rpc_pipe_client *cli,
615 TALLOC_CTX *mem_ctx,
616 int argc, const char **argv)
618 WERROR result;
619 NTSTATUS status;
620 struct sec_desc_buf *sd_buf = NULL;
622 if (argc < 2 || argc > 4) {
623 printf("Usage: %s [sharename] [file]\n", argv[0]);
624 return WERR_OK;
627 status = rpccli_srvsvc_NetGetFileSecurity(cli, mem_ctx,
628 cli->desthost,
629 argv[1],
630 argv[2],
631 SECINFO_DACL,
632 &sd_buf,
633 &result);
635 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
636 goto done;
639 display_sec_desc(sd_buf->sd);
641 done:
642 return result;
645 static WERROR cmd_srvsvc_net_sess_del(struct rpc_pipe_client *cli,
646 TALLOC_CTX *mem_ctx,
647 int argc, const char **argv)
649 WERROR result;
650 NTSTATUS status;
652 if (argc < 2 || argc > 4) {
653 printf("Usage: %s [client] [user]\n", argv[0]);
654 return WERR_OK;
657 status = rpccli_srvsvc_NetSessDel(cli, mem_ctx,
658 cli->desthost,
659 argv[1],
660 argv[2],
661 &result);
663 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
664 goto done;
667 done:
668 return result;
671 static WERROR cmd_srvsvc_net_sess_enum(struct rpc_pipe_client *cli,
672 TALLOC_CTX *mem_ctx,
673 int argc, const char **argv)
675 WERROR result;
676 NTSTATUS status;
677 struct srvsvc_NetSessInfoCtr info_ctr;
678 struct srvsvc_NetSessCtr0 ctr0;
679 struct srvsvc_NetSessCtr1 ctr1;
680 struct srvsvc_NetSessCtr2 ctr2;
681 struct srvsvc_NetSessCtr10 ctr10;
682 struct srvsvc_NetSessCtr502 ctr502;
683 uint32_t total_entries = 0;
684 uint32_t resume_handle = 0;
685 uint32_t *resume_handle_p = NULL;
686 uint32_t level = 1;
687 const char *client = NULL;
688 const char *user = NULL;
690 if (argc > 6) {
691 printf("Usage: %s [client] [user] [level] [resume_handle]\n", argv[0]);
692 return WERR_OK;
695 if (argc >= 2) {
696 client = argv[1];
699 if (argc >= 3) {
700 user = argv[2];
703 if (argc >= 4) {
704 level = atoi(argv[3]);
707 if (argc >= 5) {
708 resume_handle = atoi(argv[4]);
709 resume_handle_p = &resume_handle;
712 ZERO_STRUCT(info_ctr);
714 info_ctr.level = level;
716 d_printf("trying level: %d\n", level);
718 switch (level) {
719 case 0:
720 ZERO_STRUCT(ctr0);
721 info_ctr.ctr.ctr0 = &ctr0;
722 break;
723 case 1:
724 ZERO_STRUCT(ctr1);
725 info_ctr.ctr.ctr1 = &ctr1;
726 break;
727 case 2:
728 ZERO_STRUCT(ctr2);
729 info_ctr.ctr.ctr2 = &ctr2;
730 break;
731 case 10:
732 ZERO_STRUCT(ctr10);
733 info_ctr.ctr.ctr10 = &ctr10;
734 break;
735 case 502:
736 ZERO_STRUCT(ctr502);
737 info_ctr.ctr.ctr502 = &ctr502;
738 break;
741 status = rpccli_srvsvc_NetSessEnum(cli, mem_ctx,
742 cli->desthost,
743 client,
744 user,
745 &info_ctr,
746 0xffffffff,
747 &total_entries,
748 resume_handle_p,
749 &result);
751 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
752 goto done;
755 done:
756 return result;
759 static WERROR cmd_srvsvc_net_disk_enum(struct rpc_pipe_client *cli,
760 TALLOC_CTX *mem_ctx,
761 int argc, const char **argv)
763 struct srvsvc_NetDiskInfo info;
764 WERROR result;
765 NTSTATUS status;
766 uint32_t total_entries = 0;
767 uint32_t resume_handle = 0;
768 uint32_t level = 0;
770 if (argc > 4) {
771 printf("Usage: %s [level] [resume_handle]\n", argv[0]);
772 return WERR_OK;
775 if (argc >= 2) {
776 level = atoi(argv[1]);
779 if (argc >= 3) {
780 resume_handle = atoi(argv[2]);
783 ZERO_STRUCT(info);
785 status = rpccli_srvsvc_NetDiskEnum(cli, mem_ctx,
786 cli->desthost,
787 level,
788 &info,
789 0xffffffff,
790 &total_entries,
791 &resume_handle,
792 &result);
794 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
795 goto done;
798 done:
799 return result;
802 static WERROR cmd_srvsvc_net_conn_enum(struct rpc_pipe_client *cli,
803 TALLOC_CTX *mem_ctx,
804 int argc, const char **argv)
806 struct srvsvc_NetConnInfoCtr info_ctr;
807 struct srvsvc_NetConnCtr0 ctr0;
808 struct srvsvc_NetConnCtr1 ctr1;
809 WERROR result;
810 NTSTATUS status;
811 uint32_t total_entries = 0;
812 uint32_t resume_handle = 0;
813 uint32_t *resume_handle_p = NULL;
814 uint32_t level = 1;
815 const char *path = "IPC$";
817 if (argc > 4) {
818 printf("Usage: %s [level] [path] [resume_handle]\n", argv[0]);
819 return WERR_OK;
822 if (argc >= 2) {
823 level = atoi(argv[1]);
826 if (argc >= 3) {
827 path = argv[2];
830 if (argc >= 4) {
831 resume_handle = atoi(argv[3]);
832 resume_handle_p = &resume_handle;
835 ZERO_STRUCT(info_ctr);
837 info_ctr.level = level;
839 switch (level) {
840 case 0:
841 ZERO_STRUCT(ctr0);
842 info_ctr.ctr.ctr0 = &ctr0;
843 break;
844 case 1:
845 ZERO_STRUCT(ctr1);
846 info_ctr.ctr.ctr1 = &ctr1;
847 break;
848 default:
849 return WERR_INVALID_PARAM;
852 status = rpccli_srvsvc_NetConnEnum(cli, mem_ctx,
853 cli->desthost,
854 path,
855 &info_ctr,
856 0xffffffff,
857 &total_entries,
858 resume_handle_p,
859 &result);
861 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
862 goto done;
865 done:
866 return result;
870 /* List of commands exported by this module */
872 struct cmd_set srvsvc_commands[] = {
874 { "SRVSVC" },
876 { "srvinfo", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_srv_query_info, &ndr_table_srvsvc.syntax_id, NULL, "Server query info", "" },
877 { "netshareenum",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate shares", "" },
878 { "netshareenumall",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_enum_all, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate all shares", "" },
879 { "netsharegetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_get_info, &ndr_table_srvsvc.syntax_id, NULL, "Get Share Info", "" },
880 { "netsharesetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_set_info, &ndr_table_srvsvc.syntax_id, NULL, "Set Share Info", "" },
881 { "netfileenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate open files", "" },
882 { "netremotetod",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_remote_tod, &ndr_table_srvsvc.syntax_id, NULL, "Fetch remote time of day", "" },
883 { "netnamevalidate", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_name_validate, &ndr_table_srvsvc.syntax_id, NULL, "Validate sharename", "" },
884 { "netfilegetsec", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_get_sec, &ndr_table_srvsvc.syntax_id, NULL, "Get File security", "" },
885 { "netsessdel", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_sess_del, &ndr_table_srvsvc.syntax_id, NULL, "Delete Session", "" },
886 { "netsessenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_sess_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate Sessions", "" },
887 { "netdiskenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_disk_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate Disks", "" },
888 { "netconnenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_conn_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate Connections", "" },
890 { NULL }