ctdb-vacuum: update comment for ctdb_process_delete_queue
[Samba.git] / source3 / rpcclient / cmd_srvsvc.c
blobe5fa0656737bd731d6e807e47c04af4a734530d9
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"
25 #include "../librpc/gen_ndr/ndr_srvsvc.h"
26 #include "../librpc/gen_ndr/ndr_srvsvc_c.h"
27 #include "../libcli/security/display_sec.h"
29 /* Display server query info */
31 static char *get_server_type_str(uint32 type)
33 static fstring typestr;
34 int i;
36 if (type == SV_TYPE_ALL) {
37 fstrcpy(typestr, "All");
38 return typestr;
41 typestr[0] = 0;
43 for (i = 0; i < 32; i++) {
44 if (type & (1 << i)) {
45 switch (1 << i) {
46 case SV_TYPE_WORKSTATION:
47 fstrcat(typestr, "Wk ");
48 break;
49 case SV_TYPE_SERVER:
50 fstrcat(typestr, "Sv ");
51 break;
52 case SV_TYPE_SQLSERVER:
53 fstrcat(typestr, "Sql ");
54 break;
55 case SV_TYPE_DOMAIN_CTRL:
56 fstrcat(typestr, "PDC ");
57 break;
58 case SV_TYPE_DOMAIN_BAKCTRL:
59 fstrcat(typestr, "BDC ");
60 break;
61 case SV_TYPE_TIME_SOURCE:
62 fstrcat(typestr, "Tim ");
63 break;
64 case SV_TYPE_AFP:
65 fstrcat(typestr, "AFP ");
66 break;
67 case SV_TYPE_NOVELL:
68 fstrcat(typestr, "Nov ");
69 break;
70 case SV_TYPE_DOMAIN_MEMBER:
71 fstrcat(typestr, "Dom ");
72 break;
73 case SV_TYPE_PRINTQ_SERVER:
74 fstrcat(typestr, "PrQ ");
75 break;
76 case SV_TYPE_DIALIN_SERVER:
77 fstrcat(typestr, "Din ");
78 break;
79 case SV_TYPE_SERVER_UNIX:
80 fstrcat(typestr, "Unx ");
81 break;
82 case SV_TYPE_NT:
83 fstrcat(typestr, "NT ");
84 break;
85 case SV_TYPE_WFW:
86 fstrcat(typestr, "Wfw ");
87 break;
88 case SV_TYPE_SERVER_MFPN:
89 fstrcat(typestr, "Mfp ");
90 break;
91 case SV_TYPE_SERVER_NT:
92 fstrcat(typestr, "SNT ");
93 break;
94 case SV_TYPE_POTENTIAL_BROWSER:
95 fstrcat(typestr, "PtB ");
96 break;
97 case SV_TYPE_BACKUP_BROWSER:
98 fstrcat(typestr, "BMB ");
99 break;
100 case SV_TYPE_MASTER_BROWSER:
101 fstrcat(typestr, "LMB ");
102 break;
103 case SV_TYPE_DOMAIN_MASTER:
104 fstrcat(typestr, "DMB ");
105 break;
106 case SV_TYPE_SERVER_OSF:
107 fstrcat(typestr, "OSF ");
108 break;
109 case SV_TYPE_SERVER_VMS:
110 fstrcat(typestr, "VMS ");
111 break;
112 case SV_TYPE_WIN95_PLUS:
113 fstrcat(typestr, "W95 ");
114 break;
115 case SV_TYPE_ALTERNATE_XPORT:
116 fstrcat(typestr, "Xpt ");
117 break;
118 case SV_TYPE_LOCAL_LIST_ONLY:
119 fstrcat(typestr, "Dom ");
120 break;
121 case SV_TYPE_DOMAIN_ENUM:
122 fstrcat(typestr, "Loc ");
123 break;
128 i = strlen(typestr) - 1;
130 if (typestr[i] == ' ')
131 typestr[i] = 0;
133 return typestr;
136 static void display_server(const char *sname, uint32 type, const char *comment)
138 printf("\t%-15.15s%-20s %s\n", sname, get_server_type_str(type),
139 comment);
142 static void display_srv_info_101(struct srvsvc_NetSrvInfo101 *r)
144 display_server(r->server_name, r->server_type, r->comment);
146 printf("\tplatform_id :\t%d\n", r->platform_id);
147 printf("\tos version :\t%d.%d\n",
148 r->version_major, r->version_minor);
149 printf("\tserver type :\t0x%x\n", r->server_type);
152 static void display_srv_info_102(struct srvsvc_NetSrvInfo102 *r)
154 display_server(r->server_name, r->server_type, r->comment);
156 printf("\tplatform_id :\t%d\n", r->platform_id);
157 printf("\tos version :\t%d.%d\n",
158 r->version_major, r->version_minor);
159 printf("\tserver type :\t0x%x\n", r->server_type);
161 printf("\tusers :\t%x\n", r->users);
162 printf("\tdisc, hidden :\t%x, %x\n", r->disc, r->hidden);
163 printf("\tannounce, delta :\t%d, %d\n", r->announce,
164 r->anndelta);
165 printf("\tlicenses :\t%d\n", r->licenses);
166 printf("\tuser path :\t%s\n", r->userpath);
169 /* Server query info */
170 static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
171 TALLOC_CTX *mem_ctx,
172 int argc, const char **argv)
174 uint32 info_level = 101;
175 union srvsvc_NetSrvInfo info;
176 WERROR result;
177 NTSTATUS status;
178 const char *server_unc = cli->srv_name_slash;
179 struct dcerpc_binding_handle *b = cli->binding_handle;
181 if (argc > 3) {
182 printf("Usage: %s [infolevel] [server_unc]\n", argv[0]);
183 return WERR_OK;
186 if (argc >= 2) {
187 info_level = atoi(argv[1]);
190 if (argc >= 3) {
191 server_unc = argv[2];
194 status = dcerpc_srvsvc_NetSrvGetInfo(b, mem_ctx,
195 server_unc,
196 info_level,
197 &info,
198 &result);
199 if (!NT_STATUS_IS_OK(status)) {
200 return ntstatus_to_werror(status);
203 if (!W_ERROR_IS_OK(result)) {
204 goto done;
207 /* Display results */
209 switch (info_level) {
210 case 101:
211 display_srv_info_101(info.info101);
212 break;
213 case 102:
214 display_srv_info_102(info.info102);
215 break;
216 default:
217 printf("unsupported info level %d\n", info_level);
218 break;
221 done:
222 return result;
225 static void display_share_info_1(struct srvsvc_NetShareInfo1 *r)
227 printf("netname: %s\n", r->name);
228 printf("\tremark:\t%s\n", r->comment);
231 static void display_share_info_2(struct srvsvc_NetShareInfo2 *r)
233 printf("netname: %s\n", r->name);
234 printf("\tremark:\t%s\n", r->comment);
235 printf("\tpath:\t%s\n", r->path);
236 printf("\tpassword:\t%s\n", r->password);
239 static void display_share_info_502(struct srvsvc_NetShareInfo502 *r)
241 printf("netname: %s\n", r->name);
242 printf("\tremark:\t%s\n", r->comment);
243 printf("\tpath:\t%s\n", r->path);
244 printf("\tpassword:\t%s\n", r->password);
246 printf("\ttype:\t0x%x\n", r->type);
247 printf("\tperms:\t%d\n", r->permissions);
248 printf("\tmax_uses:\t%d\n", r->max_users);
249 printf("\tnum_uses:\t%d\n", r->current_users);
251 if (r->sd_buf.sd)
252 display_sec_desc(r->sd_buf.sd);
256 static WERROR cmd_srvsvc_net_share_enum_int(struct rpc_pipe_client *cli,
257 TALLOC_CTX *mem_ctx,
258 int argc, const char **argv,
259 uint32_t opcode)
261 uint32 info_level = 2;
262 struct srvsvc_NetShareInfoCtr info_ctr;
263 struct srvsvc_NetShareCtr0 ctr0;
264 struct srvsvc_NetShareCtr1 ctr1;
265 struct srvsvc_NetShareCtr2 ctr2;
266 struct srvsvc_NetShareCtr501 ctr501;
267 struct srvsvc_NetShareCtr502 ctr502;
268 struct srvsvc_NetShareCtr1004 ctr1004;
269 struct srvsvc_NetShareCtr1005 ctr1005;
270 struct srvsvc_NetShareCtr1006 ctr1006;
271 struct srvsvc_NetShareCtr1007 ctr1007;
272 struct srvsvc_NetShareCtr1501 ctr1501;
273 WERROR result;
274 NTSTATUS status;
275 uint32_t totalentries = 0;
276 uint32_t count = 0;
277 uint32_t resume_handle = 0;
278 uint32_t *resume_handle_p = NULL;
279 uint32 preferred_len = 0xffffffff, i;
280 struct dcerpc_binding_handle *b = cli->binding_handle;
282 if (argc > 3) {
283 printf("Usage: %s [infolevel] [resume_handle]\n", argv[0]);
284 return WERR_OK;
287 if (argc >= 2) {
288 info_level = atoi(argv[1]);
291 if (argc == 3) {
292 resume_handle = atoi(argv[2]);
293 resume_handle_p = &resume_handle;
296 ZERO_STRUCT(info_ctr);
298 info_ctr.level = info_level;
300 switch (info_level) {
301 case 0:
302 ZERO_STRUCT(ctr0);
303 info_ctr.ctr.ctr0 = &ctr0;
304 break;
305 case 1:
306 ZERO_STRUCT(ctr1);
307 info_ctr.ctr.ctr1 = &ctr1;
308 break;
309 case 2:
310 ZERO_STRUCT(ctr2);
311 info_ctr.ctr.ctr2 = &ctr2;
312 break;
313 case 501:
314 ZERO_STRUCT(ctr501);
315 info_ctr.ctr.ctr501 = &ctr501;
316 break;
317 case 502:
318 ZERO_STRUCT(ctr502);
319 info_ctr.ctr.ctr502 = &ctr502;
320 break;
321 case 1004:
322 ZERO_STRUCT(ctr1004);
323 info_ctr.ctr.ctr1004 = &ctr1004;
324 break;
325 case 1005:
326 ZERO_STRUCT(ctr1005);
327 info_ctr.ctr.ctr1005 = &ctr1005;
328 break;
329 case 1006:
330 ZERO_STRUCT(ctr1006);
331 info_ctr.ctr.ctr1006 = &ctr1006;
332 break;
333 case 1007:
334 ZERO_STRUCT(ctr1007);
335 info_ctr.ctr.ctr1007 = &ctr1007;
336 break;
337 case 1501:
338 ZERO_STRUCT(ctr1501);
339 info_ctr.ctr.ctr1501 = &ctr1501;
340 break;
343 switch (opcode) {
344 case NDR_SRVSVC_NETSHAREENUM:
345 status = dcerpc_srvsvc_NetShareEnum(b, mem_ctx,
346 cli->desthost,
347 &info_ctr,
348 preferred_len,
349 &totalentries,
350 resume_handle_p,
351 &result);
352 break;
353 case NDR_SRVSVC_NETSHAREENUMALL:
354 status = dcerpc_srvsvc_NetShareEnumAll(b, mem_ctx,
355 cli->desthost,
356 &info_ctr,
357 preferred_len,
358 &totalentries,
359 resume_handle_p,
360 &result);
361 break;
362 default:
363 return WERR_INVALID_PARAM;
366 if (!NT_STATUS_IS_OK(status)) {
367 result = ntstatus_to_werror(status);
368 goto done;
370 if (!W_ERROR_IS_OK(result)) {
371 goto done;
374 /* Display results */
376 switch (info_level) {
377 case 1:
378 count = info_ctr.ctr.ctr1->count;
379 for (i = 0; i < count; i++)
380 display_share_info_1(&info_ctr.ctr.ctr1->array[i]);
381 break;
382 case 2:
383 count = info_ctr.ctr.ctr2->count;
384 for (i = 0; i < count; i++)
385 display_share_info_2(&info_ctr.ctr.ctr2->array[i]);
386 break;
387 case 502:
388 count = info_ctr.ctr.ctr502->count;
389 for (i = 0; i < count; i++)
390 display_share_info_502(&info_ctr.ctr.ctr502->array[i]);
391 break;
392 default:
393 printf("unsupported info level %d\n", info_level);
394 break;
397 done:
398 return result;
401 static WERROR cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli,
402 TALLOC_CTX *mem_ctx,
403 int argc, const char **argv)
405 return cmd_srvsvc_net_share_enum_int(cli, mem_ctx,
406 argc, argv,
407 NDR_SRVSVC_NETSHAREENUM);
410 static WERROR cmd_srvsvc_net_share_enum_all(struct rpc_pipe_client *cli,
411 TALLOC_CTX *mem_ctx,
412 int argc, const char **argv)
414 return cmd_srvsvc_net_share_enum_int(cli, mem_ctx,
415 argc, argv,
416 NDR_SRVSVC_NETSHAREENUMALL);
419 static WERROR cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
420 TALLOC_CTX *mem_ctx,
421 int argc, const char **argv)
423 uint32 info_level = 502;
424 union srvsvc_NetShareInfo info;
425 WERROR result;
426 NTSTATUS status;
427 struct dcerpc_binding_handle *b = cli->binding_handle;
429 if (argc < 2 || argc > 3) {
430 printf("Usage: %s [sharename] [infolevel]\n", argv[0]);
431 return WERR_OK;
434 if (argc == 3)
435 info_level = atoi(argv[2]);
437 status = dcerpc_srvsvc_NetShareGetInfo(b, mem_ctx,
438 cli->desthost,
439 argv[1],
440 info_level,
441 &info,
442 &result);
444 if (!NT_STATUS_IS_OK(status)) {
445 result = ntstatus_to_werror(status);
446 goto done;
448 if (!W_ERROR_IS_OK(result)) {
449 goto done;
452 /* Display results */
454 switch (info_level) {
455 case 1:
456 display_share_info_1(info.info1);
457 break;
458 case 2:
459 display_share_info_2(info.info2);
460 break;
461 case 502:
462 display_share_info_502(info.info502);
463 break;
464 default:
465 printf("unsupported info level %d\n", info_level);
466 break;
469 done:
470 return result;
473 static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
474 TALLOC_CTX *mem_ctx,
475 int argc, const char **argv)
477 uint32 info_level = 502;
478 union srvsvc_NetShareInfo info_get;
479 WERROR result;
480 NTSTATUS status;
481 uint32_t parm_err = 0;
482 struct dcerpc_binding_handle *b = cli->binding_handle;
484 if (argc > 3) {
485 printf("Usage: %s [sharename] [comment]\n", argv[0]);
486 return WERR_OK;
489 /* retrieve share info */
490 status = dcerpc_srvsvc_NetShareGetInfo(b, mem_ctx,
491 cli->desthost,
492 argv[1],
493 info_level,
494 &info_get,
495 &result);
497 if (!NT_STATUS_IS_OK(status)) {
498 result = ntstatus_to_werror(status);
499 goto done;
501 if (!W_ERROR_IS_OK(result)) {
502 goto done;
505 info_get.info502->comment = argv[2];
507 /* set share info */
508 status = dcerpc_srvsvc_NetShareSetInfo(b, mem_ctx,
509 cli->desthost,
510 argv[1],
511 info_level,
512 &info_get,
513 &parm_err,
514 &result);
516 if (!NT_STATUS_IS_OK(status)) {
517 result = ntstatus_to_werror(status);
518 goto done;
520 if (!W_ERROR_IS_OK(result)) {
521 goto done;
524 /* re-retrieve share info and display */
525 status = dcerpc_srvsvc_NetShareGetInfo(b, mem_ctx,
526 cli->desthost,
527 argv[1],
528 info_level,
529 &info_get,
530 &result);
531 if (!NT_STATUS_IS_OK(status)) {
532 result = ntstatus_to_werror(status);
533 goto done;
535 if (!W_ERROR_IS_OK(result)) {
536 goto done;
539 display_share_info_502(info_get.info502);
541 done:
542 return result;
545 static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli,
546 TALLOC_CTX *mem_ctx,
547 int argc, const char **argv)
549 struct srvsvc_NetRemoteTODInfo *tod = NULL;
550 WERROR result;
551 NTSTATUS status;
552 struct dcerpc_binding_handle *b = cli->binding_handle;
554 if (argc > 1) {
555 printf("Usage: %s\n", argv[0]);
556 return WERR_OK;
559 status = dcerpc_srvsvc_NetRemoteTOD(b, mem_ctx,
560 cli->srv_name_slash,
561 &tod,
562 &result);
563 if (!NT_STATUS_IS_OK(status)) {
564 result = ntstatus_to_werror(status);
565 goto done;
568 if (!W_ERROR_IS_OK(result))
569 goto done;
571 done:
572 return result;
575 static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli,
576 TALLOC_CTX *mem_ctx,
577 int argc, const char **argv)
579 uint32 info_level = 3;
580 struct srvsvc_NetFileInfoCtr info_ctr;
581 struct srvsvc_NetFileCtr3 ctr3;
582 WERROR result;
583 NTSTATUS status;
584 uint32 preferred_len = 0xffff;
585 uint32_t total_entries = 0;
586 uint32_t resume_handle = 0;
587 struct dcerpc_binding_handle *b = cli->binding_handle;
589 if (argc > 2) {
590 printf("Usage: %s [infolevel]\n", argv[0]);
591 return WERR_OK;
594 if (argc == 2)
595 info_level = atoi(argv[1]);
597 ZERO_STRUCT(info_ctr);
598 ZERO_STRUCT(ctr3);
600 info_ctr.level = info_level;
601 info_ctr.ctr.ctr3 = &ctr3;
603 status = dcerpc_srvsvc_NetFileEnum(b, mem_ctx,
604 cli->desthost,
605 NULL,
606 NULL,
607 &info_ctr,
608 preferred_len,
609 &total_entries,
610 &resume_handle,
611 &result);
612 if (!NT_STATUS_IS_OK(status)) {
613 result = ntstatus_to_werror(status);
614 goto done;
617 if (!W_ERROR_IS_OK(result)) {
618 goto done;
621 done:
622 return result;
625 static WERROR cmd_srvsvc_net_name_validate(struct rpc_pipe_client *cli,
626 TALLOC_CTX *mem_ctx,
627 int argc, const char **argv)
629 WERROR result;
630 NTSTATUS status;
631 uint32_t name_type = 9;
632 uint32_t flags = 0;
633 struct dcerpc_binding_handle *b = cli->binding_handle;
635 if (argc < 2 || argc > 3) {
636 printf("Usage: %s [sharename] [type]\n", argv[0]);
637 return WERR_OK;
640 if (argc == 3) {
641 name_type = atoi(argv[2]);
644 status = dcerpc_srvsvc_NetNameValidate(b, mem_ctx,
645 cli->desthost,
646 argv[1],
647 name_type,
648 flags,
649 &result);
650 if (!NT_STATUS_IS_OK(status)) {
651 result = ntstatus_to_werror(status);
652 goto done;
655 if (!W_ERROR_IS_OK(result))
656 goto done;
658 done:
659 return result;
662 static WERROR cmd_srvsvc_net_file_get_sec(struct rpc_pipe_client *cli,
663 TALLOC_CTX *mem_ctx,
664 int argc, const char **argv)
666 WERROR result;
667 NTSTATUS status;
668 struct sec_desc_buf *sd_buf = NULL;
669 struct dcerpc_binding_handle *b = cli->binding_handle;
671 if (argc < 2 || argc > 4) {
672 printf("Usage: %s [sharename] [file]\n", argv[0]);
673 return WERR_OK;
676 status = dcerpc_srvsvc_NetGetFileSecurity(b, mem_ctx,
677 cli->desthost,
678 argv[1],
679 argv[2],
680 SECINFO_DACL,
681 &sd_buf,
682 &result);
683 if (!NT_STATUS_IS_OK(status)) {
684 result = ntstatus_to_werror(status);
685 goto done;
688 if (!W_ERROR_IS_OK(result)) {
689 goto done;
692 display_sec_desc(sd_buf->sd);
694 done:
695 return result;
698 static WERROR cmd_srvsvc_net_sess_del(struct rpc_pipe_client *cli,
699 TALLOC_CTX *mem_ctx,
700 int argc, const char **argv)
702 WERROR result;
703 NTSTATUS status;
704 struct dcerpc_binding_handle *b = cli->binding_handle;
706 if (argc < 2 || argc > 4) {
707 printf("Usage: %s [client] [user]\n", argv[0]);
708 return WERR_OK;
711 status = dcerpc_srvsvc_NetSessDel(b, mem_ctx,
712 cli->desthost,
713 argv[1],
714 argv[2],
715 &result);
716 if (!NT_STATUS_IS_OK(status)) {
717 result = ntstatus_to_werror(status);
718 goto done;
721 if (!W_ERROR_IS_OK(result)) {
722 goto done;
725 done:
726 return result;
729 static WERROR cmd_srvsvc_net_sess_enum(struct rpc_pipe_client *cli,
730 TALLOC_CTX *mem_ctx,
731 int argc, const char **argv)
733 WERROR result;
734 NTSTATUS status;
735 struct srvsvc_NetSessInfoCtr info_ctr;
736 struct srvsvc_NetSessCtr0 ctr0;
737 struct srvsvc_NetSessCtr1 ctr1;
738 struct srvsvc_NetSessCtr2 ctr2;
739 struct srvsvc_NetSessCtr10 ctr10;
740 struct srvsvc_NetSessCtr502 ctr502;
741 uint32_t total_entries = 0;
742 uint32_t resume_handle = 0;
743 uint32_t *resume_handle_p = NULL;
744 uint32_t level = 1;
745 const char *client = NULL;
746 const char *user = NULL;
747 struct dcerpc_binding_handle *b = cli->binding_handle;
749 if (argc > 6) {
750 printf("Usage: %s [client] [user] [level] [resume_handle]\n", argv[0]);
751 return WERR_OK;
754 if (argc >= 2) {
755 client = argv[1];
758 if (argc >= 3) {
759 user = argv[2];
762 if (argc >= 4) {
763 level = atoi(argv[3]);
766 if (argc >= 5) {
767 resume_handle = atoi(argv[4]);
768 resume_handle_p = &resume_handle;
771 ZERO_STRUCT(info_ctr);
773 info_ctr.level = level;
775 d_printf("trying level: %d\n", level);
777 switch (level) {
778 case 0:
779 ZERO_STRUCT(ctr0);
780 info_ctr.ctr.ctr0 = &ctr0;
781 break;
782 case 1:
783 ZERO_STRUCT(ctr1);
784 info_ctr.ctr.ctr1 = &ctr1;
785 break;
786 case 2:
787 ZERO_STRUCT(ctr2);
788 info_ctr.ctr.ctr2 = &ctr2;
789 break;
790 case 10:
791 ZERO_STRUCT(ctr10);
792 info_ctr.ctr.ctr10 = &ctr10;
793 break;
794 case 502:
795 ZERO_STRUCT(ctr502);
796 info_ctr.ctr.ctr502 = &ctr502;
797 break;
800 status = dcerpc_srvsvc_NetSessEnum(b, mem_ctx,
801 cli->desthost,
802 client,
803 user,
804 &info_ctr,
805 0xffffffff,
806 &total_entries,
807 resume_handle_p,
808 &result);
810 if (!NT_STATUS_IS_OK(status)) {
811 result = ntstatus_to_werror(status);
812 goto done;
815 if (!W_ERROR_IS_OK(result)) {
816 goto done;
819 done:
820 return result;
823 static WERROR cmd_srvsvc_net_disk_enum(struct rpc_pipe_client *cli,
824 TALLOC_CTX *mem_ctx,
825 int argc, const char **argv)
827 struct srvsvc_NetDiskInfo info;
828 WERROR result;
829 NTSTATUS status;
830 uint32_t total_entries = 0;
831 uint32_t resume_handle = 0;
832 uint32_t level = 0;
833 struct dcerpc_binding_handle *b = cli->binding_handle;
835 if (argc > 4) {
836 printf("Usage: %s [level] [resume_handle]\n", argv[0]);
837 return WERR_OK;
840 if (argc >= 2) {
841 level = atoi(argv[1]);
844 if (argc >= 3) {
845 resume_handle = atoi(argv[2]);
848 ZERO_STRUCT(info);
850 status = dcerpc_srvsvc_NetDiskEnum(b, mem_ctx,
851 cli->desthost,
852 level,
853 &info,
854 0xffffffff,
855 &total_entries,
856 &resume_handle,
857 &result);
858 if (!NT_STATUS_IS_OK(status)) {
859 result = ntstatus_to_werror(status);
860 goto done;
863 if (!W_ERROR_IS_OK(result)) {
864 goto done;
867 done:
868 return result;
871 static WERROR cmd_srvsvc_net_conn_enum(struct rpc_pipe_client *cli,
872 TALLOC_CTX *mem_ctx,
873 int argc, const char **argv)
875 struct srvsvc_NetConnInfoCtr info_ctr;
876 struct srvsvc_NetConnCtr0 ctr0;
877 struct srvsvc_NetConnCtr1 ctr1;
878 WERROR result;
879 NTSTATUS status;
880 uint32_t total_entries = 0;
881 uint32_t resume_handle = 0;
882 uint32_t *resume_handle_p = NULL;
883 uint32_t level = 1;
884 const char *path = "IPC$";
885 struct dcerpc_binding_handle *b = cli->binding_handle;
887 if (argc > 4) {
888 printf("Usage: %s [level] [path] [resume_handle]\n", argv[0]);
889 return WERR_OK;
892 if (argc >= 2) {
893 level = atoi(argv[1]);
896 if (argc >= 3) {
897 path = argv[2];
900 if (argc >= 4) {
901 resume_handle = atoi(argv[3]);
902 resume_handle_p = &resume_handle;
905 ZERO_STRUCT(info_ctr);
907 info_ctr.level = level;
909 switch (level) {
910 case 0:
911 ZERO_STRUCT(ctr0);
912 info_ctr.ctr.ctr0 = &ctr0;
913 break;
914 case 1:
915 ZERO_STRUCT(ctr1);
916 info_ctr.ctr.ctr1 = &ctr1;
917 break;
918 default:
919 return WERR_INVALID_PARAM;
922 status = dcerpc_srvsvc_NetConnEnum(b, mem_ctx,
923 cli->desthost,
924 path,
925 &info_ctr,
926 0xffffffff,
927 &total_entries,
928 resume_handle_p,
929 &result);
931 if (!NT_STATUS_IS_OK(status)) {
932 result = ntstatus_to_werror(status);
933 goto done;
936 if (!W_ERROR_IS_OK(result)) {
937 goto done;
940 done:
941 return result;
945 /* List of commands exported by this module */
947 struct cmd_set srvsvc_commands[] = {
949 { "SRVSVC" },
951 { "srvinfo", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_srv_query_info, &ndr_table_srvsvc, NULL, "Server query info", "" },
952 { "netshareenum",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_enum, &ndr_table_srvsvc, NULL, "Enumerate shares", "" },
953 { "netshareenumall",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_enum_all, &ndr_table_srvsvc, NULL, "Enumerate all shares", "" },
954 { "netsharegetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_get_info, &ndr_table_srvsvc, NULL, "Get Share Info", "" },
955 { "netsharesetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_set_info, &ndr_table_srvsvc, NULL, "Set Share Info", "" },
956 { "netfileenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_enum, &ndr_table_srvsvc, NULL, "Enumerate open files", "" },
957 { "netremotetod",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_remote_tod, &ndr_table_srvsvc, NULL, "Fetch remote time of day", "" },
958 { "netnamevalidate", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_name_validate, &ndr_table_srvsvc, NULL, "Validate sharename", "" },
959 { "netfilegetsec", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_get_sec, &ndr_table_srvsvc, NULL, "Get File security", "" },
960 { "netsessdel", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_sess_del, &ndr_table_srvsvc, NULL, "Delete Session", "" },
961 { "netsessenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_sess_enum, &ndr_table_srvsvc, NULL, "Enumerate Sessions", "" },
962 { "netdiskenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_disk_enum, &ndr_table_srvsvc, NULL, "Enumerate Disks", "" },
963 { "netconnenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_conn_enum, &ndr_table_srvsvc, NULL, "Enumerate Connections", "" },
965 { NULL }