Add some debug in s4's winbind server
[Samba/gebeck_regimport.git] / source3 / rpcclient / cmd_srvsvc.c
blob91e940416b31dc9cbf732e28e88b4f196caee8e6
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/cli_srvsvc.h"
28 /* Display server query info */
30 static char *get_server_type_str(uint32 type)
32 static fstring typestr;
33 int i;
35 if (type == SV_TYPE_ALL) {
36 fstrcpy(typestr, "All");
37 return typestr;
40 typestr[0] = 0;
42 for (i = 0; i < 32; i++) {
43 if (type & (1 << i)) {
44 switch (1 << i) {
45 case SV_TYPE_WORKSTATION:
46 fstrcat(typestr, "Wk ");
47 break;
48 case SV_TYPE_SERVER:
49 fstrcat(typestr, "Sv ");
50 break;
51 case SV_TYPE_SQLSERVER:
52 fstrcat(typestr, "Sql ");
53 break;
54 case SV_TYPE_DOMAIN_CTRL:
55 fstrcat(typestr, "PDC ");
56 break;
57 case SV_TYPE_DOMAIN_BAKCTRL:
58 fstrcat(typestr, "BDC ");
59 break;
60 case SV_TYPE_TIME_SOURCE:
61 fstrcat(typestr, "Tim ");
62 break;
63 case SV_TYPE_AFP:
64 fstrcat(typestr, "AFP ");
65 break;
66 case SV_TYPE_NOVELL:
67 fstrcat(typestr, "Nov ");
68 break;
69 case SV_TYPE_DOMAIN_MEMBER:
70 fstrcat(typestr, "Dom ");
71 break;
72 case SV_TYPE_PRINTQ_SERVER:
73 fstrcat(typestr, "PrQ ");
74 break;
75 case SV_TYPE_DIALIN_SERVER:
76 fstrcat(typestr, "Din ");
77 break;
78 case SV_TYPE_SERVER_UNIX:
79 fstrcat(typestr, "Unx ");
80 break;
81 case SV_TYPE_NT:
82 fstrcat(typestr, "NT ");
83 break;
84 case SV_TYPE_WFW:
85 fstrcat(typestr, "Wfw ");
86 break;
87 case SV_TYPE_SERVER_MFPN:
88 fstrcat(typestr, "Mfp ");
89 break;
90 case SV_TYPE_SERVER_NT:
91 fstrcat(typestr, "SNT ");
92 break;
93 case SV_TYPE_POTENTIAL_BROWSER:
94 fstrcat(typestr, "PtB ");
95 break;
96 case SV_TYPE_BACKUP_BROWSER:
97 fstrcat(typestr, "BMB ");
98 break;
99 case SV_TYPE_MASTER_BROWSER:
100 fstrcat(typestr, "LMB ");
101 break;
102 case SV_TYPE_DOMAIN_MASTER:
103 fstrcat(typestr, "DMB ");
104 break;
105 case SV_TYPE_SERVER_OSF:
106 fstrcat(typestr, "OSF ");
107 break;
108 case SV_TYPE_SERVER_VMS:
109 fstrcat(typestr, "VMS ");
110 break;
111 case SV_TYPE_WIN95_PLUS:
112 fstrcat(typestr, "W95 ");
113 break;
114 case SV_TYPE_ALTERNATE_XPORT:
115 fstrcat(typestr, "Xpt ");
116 break;
117 case SV_TYPE_LOCAL_LIST_ONLY:
118 fstrcat(typestr, "Dom ");
119 break;
120 case SV_TYPE_DOMAIN_ENUM:
121 fstrcat(typestr, "Loc ");
122 break;
127 i = strlen(typestr) - 1;
129 if (typestr[i] == ' ')
130 typestr[i] = 0;
132 return typestr;
135 static void display_server(const char *sname, uint32 type, const char *comment)
137 printf("\t%-15.15s%-20s %s\n", sname, get_server_type_str(type),
138 comment);
141 static void display_srv_info_101(struct srvsvc_NetSrvInfo101 *r)
143 display_server(r->server_name, r->server_type, r->comment);
145 printf("\tplatform_id :\t%d\n", r->platform_id);
146 printf("\tos version :\t%d.%d\n",
147 r->version_major, r->version_minor);
148 printf("\tserver type :\t0x%x\n", r->server_type);
151 static void display_srv_info_102(struct srvsvc_NetSrvInfo102 *r)
153 display_server(r->server_name, r->server_type, r->comment);
155 printf("\tplatform_id :\t%d\n", r->platform_id);
156 printf("\tos version :\t%d.%d\n",
157 r->version_major, r->version_minor);
158 printf("\tserver type :\t0x%x\n", r->server_type);
160 printf("\tusers :\t%x\n", r->users);
161 printf("\tdisc, hidden :\t%x, %x\n", r->disc, r->hidden);
162 printf("\tannounce, delta :\t%d, %d\n", r->announce,
163 r->anndelta);
164 printf("\tlicenses :\t%d\n", r->licenses);
165 printf("\tuser path :\t%s\n", r->userpath);
168 /* Server query info */
169 static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
170 TALLOC_CTX *mem_ctx,
171 int argc, const char **argv)
173 uint32 info_level = 101;
174 union srvsvc_NetSrvInfo info;
175 WERROR result;
176 NTSTATUS status;
177 const char *server_unc = cli->srv_name_slash;
179 if (argc > 3) {
180 printf("Usage: %s [infolevel] [server_unc]\n", argv[0]);
181 return WERR_OK;
184 if (argc >= 2) {
185 info_level = atoi(argv[1]);
188 if (argc >= 3) {
189 server_unc = argv[2];
192 status = rpccli_srvsvc_NetSrvGetInfo(cli, mem_ctx,
193 server_unc,
194 info_level,
195 &info,
196 &result);
197 if (!NT_STATUS_IS_OK(status)) {
198 return ntstatus_to_werror(status);
201 if (!W_ERROR_IS_OK(result)) {
202 goto done;
205 /* Display results */
207 switch (info_level) {
208 case 101:
209 display_srv_info_101(info.info101);
210 break;
211 case 102:
212 display_srv_info_102(info.info102);
213 break;
214 default:
215 printf("unsupported info level %d\n", info_level);
216 break;
219 done:
220 return result;
223 static void display_share_info_1(struct srvsvc_NetShareInfo1 *r)
225 printf("netname: %s\n", r->name);
226 printf("\tremark:\t%s\n", r->comment);
229 static void display_share_info_2(struct srvsvc_NetShareInfo2 *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);
237 static void display_share_info_502(struct srvsvc_NetShareInfo502 *r)
239 printf("netname: %s\n", r->name);
240 printf("\tremark:\t%s\n", r->comment);
241 printf("\tpath:\t%s\n", r->path);
242 printf("\tpassword:\t%s\n", r->password);
244 printf("\ttype:\t0x%x\n", r->type);
245 printf("\tperms:\t%d\n", r->permissions);
246 printf("\tmax_uses:\t%d\n", r->max_users);
247 printf("\tnum_uses:\t%d\n", r->current_users);
249 if (r->sd_buf.sd)
250 display_sec_desc(r->sd_buf.sd);
254 static WERROR cmd_srvsvc_net_share_enum_int(struct rpc_pipe_client *cli,
255 TALLOC_CTX *mem_ctx,
256 int argc, const char **argv,
257 uint32_t opcode)
259 uint32 info_level = 2;
260 struct srvsvc_NetShareInfoCtr info_ctr;
261 struct srvsvc_NetShareCtr0 ctr0;
262 struct srvsvc_NetShareCtr1 ctr1;
263 struct srvsvc_NetShareCtr2 ctr2;
264 struct srvsvc_NetShareCtr501 ctr501;
265 struct srvsvc_NetShareCtr502 ctr502;
266 struct srvsvc_NetShareCtr1004 ctr1004;
267 struct srvsvc_NetShareCtr1005 ctr1005;
268 struct srvsvc_NetShareCtr1006 ctr1006;
269 struct srvsvc_NetShareCtr1007 ctr1007;
270 struct srvsvc_NetShareCtr1501 ctr1501;
271 WERROR result;
272 NTSTATUS status;
273 uint32_t totalentries = 0;
274 uint32_t resume_handle = 0;
275 uint32_t *resume_handle_p = NULL;
276 uint32 preferred_len = 0xffffffff, i;
278 if (argc > 3) {
279 printf("Usage: %s [infolevel] [resume_handle]\n", argv[0]);
280 return WERR_OK;
283 if (argc >= 2) {
284 info_level = atoi(argv[1]);
287 if (argc == 3) {
288 resume_handle = atoi(argv[2]);
289 resume_handle_p = &resume_handle;
292 ZERO_STRUCT(info_ctr);
294 info_ctr.level = info_level;
296 switch (info_level) {
297 case 0:
298 ZERO_STRUCT(ctr0);
299 info_ctr.ctr.ctr0 = &ctr0;
300 break;
301 case 1:
302 ZERO_STRUCT(ctr1);
303 info_ctr.ctr.ctr1 = &ctr1;
304 break;
305 case 2:
306 ZERO_STRUCT(ctr2);
307 info_ctr.ctr.ctr2 = &ctr2;
308 break;
309 case 501:
310 ZERO_STRUCT(ctr501);
311 info_ctr.ctr.ctr501 = &ctr501;
312 break;
313 case 502:
314 ZERO_STRUCT(ctr502);
315 info_ctr.ctr.ctr502 = &ctr502;
316 break;
317 case 1004:
318 ZERO_STRUCT(ctr1004);
319 info_ctr.ctr.ctr1004 = &ctr1004;
320 break;
321 case 1005:
322 ZERO_STRUCT(ctr1005);
323 info_ctr.ctr.ctr1005 = &ctr1005;
324 break;
325 case 1006:
326 ZERO_STRUCT(ctr1006);
327 info_ctr.ctr.ctr1006 = &ctr1006;
328 break;
329 case 1007:
330 ZERO_STRUCT(ctr1007);
331 info_ctr.ctr.ctr1007 = &ctr1007;
332 break;
333 case 1501:
334 ZERO_STRUCT(ctr1501);
335 info_ctr.ctr.ctr1501 = &ctr1501;
336 break;
339 switch (opcode) {
340 case NDR_SRVSVC_NETSHAREENUM:
341 status = rpccli_srvsvc_NetShareEnum(cli, mem_ctx,
342 cli->desthost,
343 &info_ctr,
344 preferred_len,
345 &totalentries,
346 resume_handle_p,
347 &result);
348 break;
349 case NDR_SRVSVC_NETSHAREENUMALL:
350 status = rpccli_srvsvc_NetShareEnumAll(cli, mem_ctx,
351 cli->desthost,
352 &info_ctr,
353 preferred_len,
354 &totalentries,
355 resume_handle_p,
356 &result);
357 break;
358 default:
359 return WERR_INVALID_PARAM;
362 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
363 goto done;
366 /* Display results */
368 switch (info_level) {
369 case 1:
370 for (i = 0; i < totalentries; i++)
371 display_share_info_1(&info_ctr.ctr.ctr1->array[i]);
372 break;
373 case 2:
374 for (i = 0; i < totalentries; i++)
375 display_share_info_2(&info_ctr.ctr.ctr2->array[i]);
376 break;
377 case 502:
378 for (i = 0; i < totalentries; i++)
379 display_share_info_502(&info_ctr.ctr.ctr502->array[i]);
380 break;
381 default:
382 printf("unsupported info level %d\n", info_level);
383 break;
386 done:
387 return result;
390 static WERROR cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli,
391 TALLOC_CTX *mem_ctx,
392 int argc, const char **argv)
394 return cmd_srvsvc_net_share_enum_int(cli, mem_ctx,
395 argc, argv,
396 NDR_SRVSVC_NETSHAREENUM);
399 static WERROR cmd_srvsvc_net_share_enum_all(struct rpc_pipe_client *cli,
400 TALLOC_CTX *mem_ctx,
401 int argc, const char **argv)
403 return cmd_srvsvc_net_share_enum_int(cli, mem_ctx,
404 argc, argv,
405 NDR_SRVSVC_NETSHAREENUMALL);
408 static WERROR cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
409 TALLOC_CTX *mem_ctx,
410 int argc, const char **argv)
412 uint32 info_level = 502;
413 union srvsvc_NetShareInfo info;
414 WERROR result;
415 NTSTATUS status;
417 if (argc < 2 || argc > 3) {
418 printf("Usage: %s [sharename] [infolevel]\n", argv[0]);
419 return WERR_OK;
422 if (argc == 3)
423 info_level = atoi(argv[2]);
425 status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
426 cli->desthost,
427 argv[1],
428 info_level,
429 &info,
430 &result);
432 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
433 goto done;
436 /* Display results */
438 switch (info_level) {
439 case 1:
440 display_share_info_1(info.info1);
441 break;
442 case 2:
443 display_share_info_2(info.info2);
444 break;
445 case 502:
446 display_share_info_502(info.info502);
447 break;
448 default:
449 printf("unsupported info level %d\n", info_level);
450 break;
453 done:
454 return result;
457 static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
458 TALLOC_CTX *mem_ctx,
459 int argc, const char **argv)
461 uint32 info_level = 502;
462 union srvsvc_NetShareInfo info_get;
463 WERROR result;
464 NTSTATUS status;
465 uint32_t parm_err = 0;
467 if (argc > 3) {
468 printf("Usage: %s [sharename] [comment]\n", argv[0]);
469 return WERR_OK;
472 /* retrieve share info */
473 status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
474 cli->desthost,
475 argv[1],
476 info_level,
477 &info_get,
478 &result);
480 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
481 goto done;
484 info_get.info502->comment = argv[2];
486 /* set share info */
487 status = rpccli_srvsvc_NetShareSetInfo(cli, mem_ctx,
488 cli->desthost,
489 argv[1],
490 info_level,
491 &info_get,
492 &parm_err,
493 &result);
495 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
496 goto done;
499 /* re-retrieve share info and display */
500 status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
501 cli->desthost,
502 argv[1],
503 info_level,
504 &info_get,
505 &result);
507 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
508 goto done;
511 display_share_info_502(info_get.info502);
513 done:
514 return result;
517 static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli,
518 TALLOC_CTX *mem_ctx,
519 int argc, const char **argv)
521 struct srvsvc_NetRemoteTODInfo *tod = NULL;
522 WERROR result;
523 NTSTATUS status;
525 if (argc > 1) {
526 printf("Usage: %s\n", argv[0]);
527 return WERR_OK;
530 status = rpccli_srvsvc_NetRemoteTOD(cli, mem_ctx,
531 cli->srv_name_slash,
532 &tod,
533 &result);
534 if (!NT_STATUS_IS_OK(status)) {
535 result = ntstatus_to_werror(status);
536 goto done;
539 if (!W_ERROR_IS_OK(result))
540 goto done;
542 done:
543 return result;
546 static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli,
547 TALLOC_CTX *mem_ctx,
548 int argc, const char **argv)
550 uint32 info_level = 3;
551 struct srvsvc_NetFileInfoCtr info_ctr;
552 struct srvsvc_NetFileCtr3 ctr3;
553 WERROR result;
554 NTSTATUS status;
555 uint32 preferred_len = 0xffff;
556 uint32_t total_entries = 0;
557 uint32_t resume_handle = 0;
559 if (argc > 2) {
560 printf("Usage: %s [infolevel]\n", argv[0]);
561 return WERR_OK;
564 if (argc == 2)
565 info_level = atoi(argv[1]);
567 ZERO_STRUCT(info_ctr);
568 ZERO_STRUCT(ctr3);
570 info_ctr.level = info_level;
571 info_ctr.ctr.ctr3 = &ctr3;
573 status = rpccli_srvsvc_NetFileEnum(cli, mem_ctx,
574 cli->desthost,
575 NULL,
576 NULL,
577 &info_ctr,
578 preferred_len,
579 &total_entries,
580 &resume_handle,
581 &result);
583 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result))
584 goto done;
586 done:
587 return result;
590 static WERROR cmd_srvsvc_net_name_validate(struct rpc_pipe_client *cli,
591 TALLOC_CTX *mem_ctx,
592 int argc, const char **argv)
594 WERROR result;
595 NTSTATUS status;
596 uint32_t name_type = 9;
597 uint32_t flags = 0;
599 if (argc < 2 || argc > 3) {
600 printf("Usage: %s [sharename] [type]\n", argv[0]);
601 return WERR_OK;
604 if (argc == 3) {
605 name_type = atoi(argv[2]);
608 status = rpccli_srvsvc_NetNameValidate(cli, mem_ctx,
609 cli->desthost,
610 argv[1],
611 name_type,
612 flags,
613 &result);
615 if (!W_ERROR_IS_OK(result))
616 goto done;
618 done:
619 return result;
622 static WERROR cmd_srvsvc_net_file_get_sec(struct rpc_pipe_client *cli,
623 TALLOC_CTX *mem_ctx,
624 int argc, const char **argv)
626 WERROR result;
627 NTSTATUS status;
628 struct sec_desc_buf *sd_buf = NULL;
630 if (argc < 2 || argc > 4) {
631 printf("Usage: %s [sharename] [file]\n", argv[0]);
632 return WERR_OK;
635 status = rpccli_srvsvc_NetGetFileSecurity(cli, mem_ctx,
636 cli->desthost,
637 argv[1],
638 argv[2],
639 SECINFO_DACL,
640 &sd_buf,
641 &result);
643 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
644 goto done;
647 display_sec_desc(sd_buf->sd);
649 done:
650 return result;
653 static WERROR cmd_srvsvc_net_sess_del(struct rpc_pipe_client *cli,
654 TALLOC_CTX *mem_ctx,
655 int argc, const char **argv)
657 WERROR result;
658 NTSTATUS status;
660 if (argc < 2 || argc > 4) {
661 printf("Usage: %s [client] [user]\n", argv[0]);
662 return WERR_OK;
665 status = rpccli_srvsvc_NetSessDel(cli, mem_ctx,
666 cli->desthost,
667 argv[1],
668 argv[2],
669 &result);
671 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
672 goto done;
675 done:
676 return result;
679 static WERROR cmd_srvsvc_net_sess_enum(struct rpc_pipe_client *cli,
680 TALLOC_CTX *mem_ctx,
681 int argc, const char **argv)
683 WERROR result;
684 NTSTATUS status;
685 struct srvsvc_NetSessInfoCtr info_ctr;
686 struct srvsvc_NetSessCtr0 ctr0;
687 struct srvsvc_NetSessCtr1 ctr1;
688 struct srvsvc_NetSessCtr2 ctr2;
689 struct srvsvc_NetSessCtr10 ctr10;
690 struct srvsvc_NetSessCtr502 ctr502;
691 uint32_t total_entries = 0;
692 uint32_t resume_handle = 0;
693 uint32_t *resume_handle_p = NULL;
694 uint32_t level = 1;
695 const char *client = NULL;
696 const char *user = NULL;
698 if (argc > 6) {
699 printf("Usage: %s [client] [user] [level] [resume_handle]\n", argv[0]);
700 return WERR_OK;
703 if (argc >= 2) {
704 client = argv[1];
707 if (argc >= 3) {
708 user = argv[2];
711 if (argc >= 4) {
712 level = atoi(argv[3]);
715 if (argc >= 5) {
716 resume_handle = atoi(argv[4]);
717 resume_handle_p = &resume_handle;
720 ZERO_STRUCT(info_ctr);
722 info_ctr.level = level;
724 d_printf("trying level: %d\n", level);
726 switch (level) {
727 case 0:
728 ZERO_STRUCT(ctr0);
729 info_ctr.ctr.ctr0 = &ctr0;
730 break;
731 case 1:
732 ZERO_STRUCT(ctr1);
733 info_ctr.ctr.ctr1 = &ctr1;
734 break;
735 case 2:
736 ZERO_STRUCT(ctr2);
737 info_ctr.ctr.ctr2 = &ctr2;
738 break;
739 case 10:
740 ZERO_STRUCT(ctr10);
741 info_ctr.ctr.ctr10 = &ctr10;
742 break;
743 case 502:
744 ZERO_STRUCT(ctr502);
745 info_ctr.ctr.ctr502 = &ctr502;
746 break;
749 status = rpccli_srvsvc_NetSessEnum(cli, mem_ctx,
750 cli->desthost,
751 client,
752 user,
753 &info_ctr,
754 0xffffffff,
755 &total_entries,
756 resume_handle_p,
757 &result);
759 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
760 goto done;
763 done:
764 return result;
767 static WERROR cmd_srvsvc_net_disk_enum(struct rpc_pipe_client *cli,
768 TALLOC_CTX *mem_ctx,
769 int argc, const char **argv)
771 struct srvsvc_NetDiskInfo info;
772 WERROR result;
773 NTSTATUS status;
774 uint32_t total_entries = 0;
775 uint32_t resume_handle = 0;
776 uint32_t level = 0;
778 if (argc > 4) {
779 printf("Usage: %s [level] [resume_handle]\n", argv[0]);
780 return WERR_OK;
783 if (argc >= 2) {
784 level = atoi(argv[1]);
787 if (argc >= 3) {
788 resume_handle = atoi(argv[2]);
791 ZERO_STRUCT(info);
793 status = rpccli_srvsvc_NetDiskEnum(cli, mem_ctx,
794 cli->desthost,
795 level,
796 &info,
797 0xffffffff,
798 &total_entries,
799 &resume_handle,
800 &result);
802 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
803 goto done;
806 done:
807 return result;
810 static WERROR cmd_srvsvc_net_conn_enum(struct rpc_pipe_client *cli,
811 TALLOC_CTX *mem_ctx,
812 int argc, const char **argv)
814 struct srvsvc_NetConnInfoCtr info_ctr;
815 struct srvsvc_NetConnCtr0 ctr0;
816 struct srvsvc_NetConnCtr1 ctr1;
817 WERROR result;
818 NTSTATUS status;
819 uint32_t total_entries = 0;
820 uint32_t resume_handle = 0;
821 uint32_t *resume_handle_p = NULL;
822 uint32_t level = 1;
823 const char *path = "IPC$";
825 if (argc > 4) {
826 printf("Usage: %s [level] [path] [resume_handle]\n", argv[0]);
827 return WERR_OK;
830 if (argc >= 2) {
831 level = atoi(argv[1]);
834 if (argc >= 3) {
835 path = argv[2];
838 if (argc >= 4) {
839 resume_handle = atoi(argv[3]);
840 resume_handle_p = &resume_handle;
843 ZERO_STRUCT(info_ctr);
845 info_ctr.level = level;
847 switch (level) {
848 case 0:
849 ZERO_STRUCT(ctr0);
850 info_ctr.ctr.ctr0 = &ctr0;
851 break;
852 case 1:
853 ZERO_STRUCT(ctr1);
854 info_ctr.ctr.ctr1 = &ctr1;
855 break;
856 default:
857 return WERR_INVALID_PARAM;
860 status = rpccli_srvsvc_NetConnEnum(cli, mem_ctx,
861 cli->desthost,
862 path,
863 &info_ctr,
864 0xffffffff,
865 &total_entries,
866 resume_handle_p,
867 &result);
869 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
870 goto done;
873 done:
874 return result;
878 /* List of commands exported by this module */
880 struct cmd_set srvsvc_commands[] = {
882 { "SRVSVC" },
884 { "srvinfo", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_srv_query_info, &ndr_table_srvsvc.syntax_id, NULL, "Server query info", "" },
885 { "netshareenum",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate shares", "" },
886 { "netshareenumall",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_enum_all, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate all shares", "" },
887 { "netsharegetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_get_info, &ndr_table_srvsvc.syntax_id, NULL, "Get Share Info", "" },
888 { "netsharesetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_set_info, &ndr_table_srvsvc.syntax_id, NULL, "Set Share Info", "" },
889 { "netfileenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate open files", "" },
890 { "netremotetod",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_remote_tod, &ndr_table_srvsvc.syntax_id, NULL, "Fetch remote time of day", "" },
891 { "netnamevalidate", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_name_validate, &ndr_table_srvsvc.syntax_id, NULL, "Validate sharename", "" },
892 { "netfilegetsec", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_get_sec, &ndr_table_srvsvc.syntax_id, NULL, "Get File security", "" },
893 { "netsessdel", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_sess_del, &ndr_table_srvsvc.syntax_id, NULL, "Delete Session", "" },
894 { "netsessenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_sess_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate Sessions", "" },
895 { "netdiskenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_disk_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate Disks", "" },
896 { "netconnenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_conn_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate Connections", "" },
898 { NULL }