s3-spoolss: fix rpcclient after setprinter IDL fixes.
[ira/wip.git] / source3 / rpcclient / cmd_srvsvc.c
index 2e84f0498f46b980205ef08ffd821991173fd33a..866b68111d81380a454debb4c3cf504b06ebfad4 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "includes.h"
 #include "rpcclient.h"
+#include "../librpc/gen_ndr/cli_srvsvc.h"
 
 /* Display server query info */
 
@@ -172,7 +173,6 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
        union srvsvc_NetSrvInfo info;
        WERROR result;
        NTSTATUS status;
-       const char *server_name;
 
        if (argc > 2) {
                printf("Usage: %s [infolevel]\n", argv[0]);
@@ -182,12 +182,8 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
        if (argc == 2)
                info_level = atoi(argv[1]);
 
-       server_name = talloc_asprintf_strupper_m(mem_ctx, "\\\\%s",
-                                                cli->cli->desthost);
-       W_ERROR_HAVE_NO_MEMORY(server_name);
-
        status = rpccli_srvsvc_NetSrvGetInfo(cli, mem_ctx,
-                                            server_name,
+                                            cli->srv_name_slash,
                                             info_level,
                                             &info,
                                             &result);
@@ -217,96 +213,163 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
        return result;
 }
 
-static void display_share_info_1(SRV_SHARE_INFO_1 *info1)
+static void display_share_info_1(struct srvsvc_NetShareInfo1 *r)
 {
-       fstring netname = "", remark = "";
-
-       rpcstr_pull_unistr2_fstring(netname, &info1->info_1_str.uni_netname);
-       rpcstr_pull_unistr2_fstring(remark, &info1->info_1_str.uni_remark);
-
-       printf("netname: %s\n", netname);
-       printf("\tremark:\t%s\n", remark);
+       printf("netname: %s\n", r->name);
+       printf("\tremark:\t%s\n", r->comment);
 }
 
-static void display_share_info_2(SRV_SHARE_INFO_2 *info2)
+static void display_share_info_2(struct srvsvc_NetShareInfo2 *r)
 {
-       fstring netname = "", remark = "", path = "", passwd = "";
-
-       rpcstr_pull_unistr2_fstring(netname, &info2->info_2_str.uni_netname);
-       rpcstr_pull_unistr2_fstring(remark, &info2->info_2_str.uni_remark);
-       rpcstr_pull_unistr2_fstring(path, &info2->info_2_str.uni_path);
-       rpcstr_pull_unistr2_fstring(passwd, &info2->info_2_str.uni_passwd);
-
-       printf("netname: %s\n", netname);
-       printf("\tremark:\t%s\n", remark);
-       printf("\tpath:\t%s\n", path);
-       printf("\tpassword:\t%s\n", passwd);
+       printf("netname: %s\n", r->name);
+       printf("\tremark:\t%s\n", r->comment);
+       printf("\tpath:\t%s\n", r->path);
+       printf("\tpassword:\t%s\n", r->password);
 }
 
-static void display_share_info_502(SRV_SHARE_INFO_502 *info502)
+static void display_share_info_502(struct srvsvc_NetShareInfo502 *r)
 {
-       fstring netname = "", remark = "", path = "", passwd = "";
-
-       rpcstr_pull_unistr2_fstring(netname, &info502->info_502_str.uni_netname);
-       rpcstr_pull_unistr2_fstring(remark, &info502->info_502_str.uni_remark);
-       rpcstr_pull_unistr2_fstring(path, &info502->info_502_str.uni_path);
-       rpcstr_pull_unistr2_fstring(passwd, &info502->info_502_str.uni_passwd);
-
-       printf("netname: %s\n", netname);
-       printf("\tremark:\t%s\n", remark);
-       printf("\tpath:\t%s\n", path);
-       printf("\tpassword:\t%s\n", passwd);
-
-       printf("\ttype:\t0x%x\n", info502->info_502.type);
-       printf("\tperms:\t%d\n", info502->info_502.perms);
-       printf("\tmax_uses:\t%d\n", info502->info_502.max_uses);
-       printf("\tnum_uses:\t%d\n", info502->info_502.num_uses);
-       
-       if (info502->info_502_str.sd)
-               display_sec_desc(info502->info_502_str.sd);
+       printf("netname: %s\n", r->name);
+       printf("\tremark:\t%s\n", r->comment);
+       printf("\tpath:\t%s\n", r->path);
+       printf("\tpassword:\t%s\n", r->password);
+
+       printf("\ttype:\t0x%x\n", r->type);
+       printf("\tperms:\t%d\n", r->permissions);
+       printf("\tmax_uses:\t%d\n", r->max_users);
+       printf("\tnum_uses:\t%d\n", r->current_users);
+
+       if (r->sd_buf.sd)
+               display_sec_desc(r->sd_buf.sd);
 
 }
 
-static WERROR cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli, 
-                                          TALLOC_CTX *mem_ctx,
-                                          int argc, const char **argv)
+static WERROR cmd_srvsvc_net_share_enum_int(struct rpc_pipe_client *cli,
+                                           TALLOC_CTX *mem_ctx,
+                                           int argc, const char **argv,
+                                           uint32_t opcode)
 {
        uint32 info_level = 2;
-       SRV_SHARE_INFO_CTR ctr;
+       struct srvsvc_NetShareInfoCtr info_ctr;
+       struct srvsvc_NetShareCtr0 ctr0;
+       struct srvsvc_NetShareCtr1 ctr1;
+       struct srvsvc_NetShareCtr2 ctr2;
+       struct srvsvc_NetShareCtr501 ctr501;
+       struct srvsvc_NetShareCtr502 ctr502;
+       struct srvsvc_NetShareCtr1004 ctr1004;
+       struct srvsvc_NetShareCtr1005 ctr1005;
+       struct srvsvc_NetShareCtr1006 ctr1006;
+       struct srvsvc_NetShareCtr1007 ctr1007;
+       struct srvsvc_NetShareCtr1501 ctr1501;
        WERROR result;
-       ENUM_HND hnd;
+       NTSTATUS status;
+       uint32_t totalentries = 0;
+       uint32_t resume_handle = 0;
+       uint32_t *resume_handle_p = NULL;
        uint32 preferred_len = 0xffffffff, i;
 
-       if (argc > 2) {
-               printf("Usage: %s [infolevel]\n", argv[0]);
+       if (argc > 3) {
+               printf("Usage: %s [infolevel] [resume_handle]\n", argv[0]);
                return WERR_OK;
        }
 
-       if (argc == 2)
+       if (argc >= 2) {
                info_level = atoi(argv[1]);
+       }
+
+       if (argc == 3) {
+               resume_handle = atoi(argv[2]);
+               resume_handle_p = &resume_handle;
+       }
 
-       init_enum_hnd(&hnd, 0);
+       ZERO_STRUCT(info_ctr);
 
-       result = rpccli_srvsvc_net_share_enum(
-               cli, mem_ctx, info_level, &ctr, preferred_len, &hnd);
+       info_ctr.level = info_level;
 
-       if (!W_ERROR_IS_OK(result) || !ctr.num_entries)
+       switch (info_level) {
+       case 0:
+               ZERO_STRUCT(ctr0);
+               info_ctr.ctr.ctr0 = &ctr0;
+               break;
+       case 1:
+               ZERO_STRUCT(ctr1);
+               info_ctr.ctr.ctr1 = &ctr1;
+               break;
+       case 2:
+               ZERO_STRUCT(ctr2);
+               info_ctr.ctr.ctr2 = &ctr2;
+               break;
+       case 501:
+               ZERO_STRUCT(ctr501);
+               info_ctr.ctr.ctr501 = &ctr501;
+               break;
+       case 502:
+               ZERO_STRUCT(ctr502);
+               info_ctr.ctr.ctr502 = &ctr502;
+               break;
+       case 1004:
+               ZERO_STRUCT(ctr1004);
+               info_ctr.ctr.ctr1004 = &ctr1004;
+               break;
+       case 1005:
+               ZERO_STRUCT(ctr1005);
+               info_ctr.ctr.ctr1005 = &ctr1005;
+               break;
+       case 1006:
+               ZERO_STRUCT(ctr1006);
+               info_ctr.ctr.ctr1006 = &ctr1006;
+               break;
+       case 1007:
+               ZERO_STRUCT(ctr1007);
+               info_ctr.ctr.ctr1007 = &ctr1007;
+               break;
+       case 1501:
+               ZERO_STRUCT(ctr1501);
+               info_ctr.ctr.ctr1501 = &ctr1501;
+               break;
+       }
+
+       switch (opcode) {
+               case NDR_SRVSVC_NETSHAREENUM:
+                       status = rpccli_srvsvc_NetShareEnum(cli, mem_ctx,
+                                                           cli->desthost,
+                                                           &info_ctr,
+                                                           preferred_len,
+                                                           &totalentries,
+                                                           resume_handle_p,
+                                                           &result);
+                       break;
+               case NDR_SRVSVC_NETSHAREENUMALL:
+                       status = rpccli_srvsvc_NetShareEnumAll(cli, mem_ctx,
+                                                              cli->desthost,
+                                                              &info_ctr,
+                                                              preferred_len,
+                                                              &totalentries,
+                                                              resume_handle_p,
+                                                              &result);
+                       break;
+               default:
+                       return WERR_INVALID_PARAM;
+       }
+
+       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
                goto done;
+       }
 
        /* Display results */
 
        switch (info_level) {
        case 1:
-               for (i = 0; i < ctr.num_entries; i++)
-                       display_share_info_1(&ctr.share.info1[i]);
+               for (i = 0; i < totalentries; i++)
+                       display_share_info_1(&info_ctr.ctr.ctr1->array[i]);
                break;
        case 2:
-               for (i = 0; i < ctr.num_entries; i++)
-                       display_share_info_2(&ctr.share.info2[i]);
+               for (i = 0; i < totalentries; i++)
+                       display_share_info_2(&info_ctr.ctr.ctr2->array[i]);
                break;
        case 502:
-               for (i = 0; i < ctr.num_entries; i++)
-                       display_share_info_502(&ctr.share.info502[i]);
+               for (i = 0; i < totalentries; i++)
+                       display_share_info_502(&info_ctr.ctr.ctr502->array[i]);
                break;
        default:
                printf("unsupported info level %d\n", info_level);
@@ -317,15 +380,34 @@ static WERROR cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli,
        return result;
 }
 
+static WERROR cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli,
+                                       TALLOC_CTX *mem_ctx,
+                                       int argc, const char **argv)
+{
+       return cmd_srvsvc_net_share_enum_int(cli, mem_ctx,
+                                            argc, argv,
+                                            NDR_SRVSVC_NETSHAREENUM);
+}
+
+static WERROR cmd_srvsvc_net_share_enum_all(struct rpc_pipe_client *cli,
+                                           TALLOC_CTX *mem_ctx,
+                                           int argc, const char **argv)
+{
+       return cmd_srvsvc_net_share_enum_int(cli, mem_ctx,
+                                            argc, argv,
+                                            NDR_SRVSVC_NETSHAREENUMALL);
+}
+
 static WERROR cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli, 
                                            TALLOC_CTX *mem_ctx,
                                            int argc, const char **argv)
 {
        uint32 info_level = 502;
-       SRV_SHARE_INFO info;
+       union srvsvc_NetShareInfo info;
        WERROR result;
+       NTSTATUS status;
 
-       if (argc > 3) {
+       if (argc < 2 || argc > 3) {
                printf("Usage: %s [sharename] [infolevel]\n", argv[0]);
                return WERR_OK;
        }
@@ -333,22 +415,28 @@ static WERROR cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
        if (argc == 3)
                info_level = atoi(argv[2]);
 
-       result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info);
+       status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
+                                              cli->desthost,
+                                              argv[1],
+                                              info_level,
+                                              &info,
+                                              &result);
 
-       if (!W_ERROR_IS_OK(result))
+       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
                goto done;
+       }
 
        /* Display results */
 
        switch (info_level) {
        case 1:
-               display_share_info_1(&info.share.info1);
+               display_share_info_1(info.info1);
                break;
        case 2:
-               display_share_info_2(&info.share.info2);
+               display_share_info_2(info.info2);
                break;
        case 502:
-               display_share_info_502(&info.share.info502);
+               display_share_info_502(info.info502);
                break;
        default:
                printf("unsupported info level %d\n", info_level);
@@ -364,8 +452,10 @@ static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
                                            int argc, const char **argv)
 {
        uint32 info_level = 502;
-       SRV_SHARE_INFO info_get;
+       union srvsvc_NetShareInfo info_get;
        WERROR result;
+       NTSTATUS status;
+       uint32_t parm_err = 0;
 
        if (argc > 3) {
                printf("Usage: %s [sharename] [comment]\n", argv[0]);
@@ -373,27 +463,46 @@ static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
        }
 
        /* retrieve share info */
-       result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info_get);
-       if (!W_ERROR_IS_OK(result))
+       status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
+                                              cli->desthost,
+                                              argv[1],
+                                              info_level,
+                                              &info_get,
+                                              &result);
+
+       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
                goto done;
+       }
 
-       info_get.switch_value = info_level;
-       info_get.ptr_share_ctr = 1;
-       init_unistr2(&(info_get.share.info502.info_502_str.uni_remark), argv[2], UNI_STR_TERMINATE);
-       
-       /* set share info */
-       result = rpccli_srvsvc_net_share_set_info(cli, mem_ctx, argv[1], info_level, &info_get);
+       info_get.info502->comment = argv[2];
 
-       if (!W_ERROR_IS_OK(result))
+       /* set share info */
+       status = rpccli_srvsvc_NetShareSetInfo(cli, mem_ctx,
+                                              cli->desthost,
+                                              argv[1],
+                                              info_level,
+                                              &info_get,
+                                              &parm_err,
+                                              &result);
+
+       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
                goto done;
+       }
 
        /* re-retrieve share info and display */
-       result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info_get);
-       if (!W_ERROR_IS_OK(result))
+       status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
+                                              cli->desthost,
+                                              argv[1],
+                                              info_level,
+                                              &info_get,
+                                              &result);
+
+       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
                goto done;
+       }
+
+       display_share_info_502(info_get.info502);
 
-       display_share_info_502(&info_get.share.info502);
-       
  done:
        return result;
 }
@@ -403,7 +512,6 @@ static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli,
                                           int argc, const char **argv)
 {
        struct srvsvc_NetRemoteTODInfo *tod = NULL;
-       fstring srv_name_slash;
        WERROR result;
        NTSTATUS status;
 
@@ -412,9 +520,8 @@ static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli,
                return WERR_OK;
        }
 
-       fstr_sprintf(srv_name_slash, "\\\\%s", cli->cli->desthost);
        status = rpccli_srvsvc_NetRemoteTOD(cli, mem_ctx,
-                                           srv_name_slash,
+                                           cli->srv_name_slash,
                                            &tod,
                                            &result);
        if (!NT_STATUS_IS_OK(status)) {
@@ -434,10 +541,13 @@ static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli,
                                         int argc, const char **argv)
 {
        uint32 info_level = 3;
-       SRV_FILE_INFO_CTR ctr;
+       struct srvsvc_NetFileInfoCtr info_ctr;
+       struct srvsvc_NetFileCtr3 ctr3;
        WERROR result;
-       ENUM_HND hnd;
+       NTSTATUS status;
        uint32 preferred_len = 0xffff;
+       uint32_t total_entries = 0;
+       uint32_t resume_handle = 0;
 
        if (argc > 2) {
                printf("Usage: %s [infolevel]\n", argv[0]);
@@ -447,12 +557,53 @@ static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli,
        if (argc == 2)
                info_level = atoi(argv[1]);
 
-       init_enum_hnd(&hnd, 0);
+       ZERO_STRUCT(info_ctr);
+       ZERO_STRUCT(ctr3);
+
+       info_ctr.level = info_level;
+       info_ctr.ctr.ctr3 = &ctr3;
+
+       status = rpccli_srvsvc_NetFileEnum(cli, mem_ctx,
+                                          cli->desthost,
+                                          NULL,
+                                          NULL,
+                                          &info_ctr,
+                                          preferred_len,
+                                          &total_entries,
+                                          &resume_handle,
+                                          &result);
 
-       ZERO_STRUCT(ctr);
+       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result))
+               goto done;
 
-       result = rpccli_srvsvc_net_file_enum(
-               cli, mem_ctx, info_level, NULL, &ctr, preferred_len, &hnd);
+ done:
+       return result;
+}
+
+static WERROR cmd_srvsvc_net_name_validate(struct rpc_pipe_client *cli,
+                                          TALLOC_CTX *mem_ctx,
+                                          int argc, const char **argv)
+{
+       WERROR result;
+       NTSTATUS status;
+       uint32_t name_type = 9;
+       uint32_t flags = 0;
+
+       if (argc < 2 || argc > 3) {
+               printf("Usage: %s [sharename] [type]\n", argv[0]);
+               return WERR_OK;
+       }
+
+       if (argc == 3) {
+               name_type = atoi(argv[2]);
+       }
+
+       status = rpccli_srvsvc_NetNameValidate(cli, mem_ctx,
+                                              cli->desthost,
+                                              argv[1],
+                                              name_type,
+                                              flags,
+                                              &result);
 
        if (!W_ERROR_IS_OK(result))
                goto done;
@@ -461,18 +612,281 @@ static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli,
        return result;
 }
 
+static WERROR cmd_srvsvc_net_file_get_sec(struct rpc_pipe_client *cli,
+                                         TALLOC_CTX *mem_ctx,
+                                         int argc, const char **argv)
+{
+       WERROR result;
+       NTSTATUS status;
+       struct sec_desc_buf *sd_buf = NULL;
+
+       if (argc < 2 || argc > 4) {
+               printf("Usage: %s [sharename] [file]\n", argv[0]);
+               return WERR_OK;
+       }
+
+       status = rpccli_srvsvc_NetGetFileSecurity(cli, mem_ctx,
+                                                 cli->desthost,
+                                                 argv[1],
+                                                 argv[2],
+                                                 SECINFO_DACL,
+                                                 &sd_buf,
+                                                 &result);
+
+       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
+               goto done;
+       }
+
+       display_sec_desc(sd_buf->sd);
+
+ done:
+       return result;
+}
+
+static WERROR cmd_srvsvc_net_sess_del(struct rpc_pipe_client *cli,
+                                     TALLOC_CTX *mem_ctx,
+                                     int argc, const char **argv)
+{
+       WERROR result;
+       NTSTATUS status;
+
+       if (argc < 2 || argc > 4) {
+               printf("Usage: %s [client] [user]\n", argv[0]);
+               return WERR_OK;
+       }
+
+       status = rpccli_srvsvc_NetSessDel(cli, mem_ctx,
+                                         cli->desthost,
+                                         argv[1],
+                                         argv[2],
+                                         &result);
+
+       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
+               goto done;
+       }
+
+ done:
+       return result;
+}
+
+static WERROR cmd_srvsvc_net_sess_enum(struct rpc_pipe_client *cli,
+                                      TALLOC_CTX *mem_ctx,
+                                      int argc, const char **argv)
+{
+       WERROR result;
+       NTSTATUS status;
+       struct srvsvc_NetSessInfoCtr info_ctr;
+       struct srvsvc_NetSessCtr0 ctr0;
+       struct srvsvc_NetSessCtr1 ctr1;
+       struct srvsvc_NetSessCtr2 ctr2;
+       struct srvsvc_NetSessCtr10 ctr10;
+       struct srvsvc_NetSessCtr502 ctr502;
+       uint32_t total_entries = 0;
+       uint32_t resume_handle = 0;
+       uint32_t *resume_handle_p = NULL;
+       uint32_t level = 1;
+       const char *client = NULL;
+       const char *user = NULL;
+
+       if (argc > 6) {
+               printf("Usage: %s [client] [user] [level] [resume_handle]\n", argv[0]);
+               return WERR_OK;
+       }
+
+       if (argc >= 2) {
+               client = argv[1];
+       }
+
+       if (argc >= 3) {
+               user = argv[2];
+       }
+
+       if (argc >= 4) {
+               level = atoi(argv[3]);
+       }
+
+       if (argc >= 5) {
+               resume_handle = atoi(argv[4]);
+               resume_handle_p = &resume_handle;
+       }
+
+       ZERO_STRUCT(info_ctr);
+
+       info_ctr.level = level;
+
+       d_printf("trying level: %d\n", level);
+
+       switch (level) {
+       case 0:
+               ZERO_STRUCT(ctr0);
+               info_ctr.ctr.ctr0 = &ctr0;
+               break;
+       case 1:
+               ZERO_STRUCT(ctr1);
+               info_ctr.ctr.ctr1 = &ctr1;
+               break;
+       case 2:
+               ZERO_STRUCT(ctr2);
+               info_ctr.ctr.ctr2 = &ctr2;
+               break;
+       case 10:
+               ZERO_STRUCT(ctr10);
+               info_ctr.ctr.ctr10 = &ctr10;
+               break;
+       case 502:
+               ZERO_STRUCT(ctr502);
+               info_ctr.ctr.ctr502 = &ctr502;
+               break;
+       }
+
+       status = rpccli_srvsvc_NetSessEnum(cli, mem_ctx,
+                                         cli->desthost,
+                                         client,
+                                         user,
+                                         &info_ctr,
+                                         0xffffffff,
+                                         &total_entries,
+                                         resume_handle_p,
+                                         &result);
+
+       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
+               goto done;
+       }
+
+ done:
+       return result;
+}
+
+static WERROR cmd_srvsvc_net_disk_enum(struct rpc_pipe_client *cli,
+                                      TALLOC_CTX *mem_ctx,
+                                      int argc, const char **argv)
+{
+       struct srvsvc_NetDiskInfo info;
+       WERROR result;
+       NTSTATUS status;
+       uint32_t total_entries = 0;
+       uint32_t resume_handle = 0;
+       uint32_t level = 0;
+
+       if (argc > 4) {
+               printf("Usage: %s [level] [resume_handle]\n", argv[0]);
+               return WERR_OK;
+       }
+
+       if (argc >= 2) {
+               level = atoi(argv[1]);
+       }
+
+       if (argc >= 3) {
+               resume_handle = atoi(argv[2]);
+       }
+
+       ZERO_STRUCT(info);
+
+       status = rpccli_srvsvc_NetDiskEnum(cli, mem_ctx,
+                                          cli->desthost,
+                                          level,
+                                          &info,
+                                          0xffffffff,
+                                          &total_entries,
+                                          &resume_handle,
+                                          &result);
+
+       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
+               goto done;
+       }
+
+ done:
+       return result;
+}
+
+static WERROR cmd_srvsvc_net_conn_enum(struct rpc_pipe_client *cli,
+                                      TALLOC_CTX *mem_ctx,
+                                      int argc, const char **argv)
+{
+       struct srvsvc_NetConnInfoCtr info_ctr;
+       struct srvsvc_NetConnCtr0 ctr0;
+       struct srvsvc_NetConnCtr1 ctr1;
+       WERROR result;
+       NTSTATUS status;
+       uint32_t total_entries = 0;
+       uint32_t resume_handle = 0;
+       uint32_t *resume_handle_p = NULL;
+       uint32_t level = 1;
+       const char *path = "IPC$";
+
+       if (argc > 4) {
+               printf("Usage: %s [level] [path] [resume_handle]\n", argv[0]);
+               return WERR_OK;
+       }
+
+       if (argc >= 2) {
+               level = atoi(argv[1]);
+       }
+
+       if (argc >= 3) {
+               path = argv[2];
+       }
+
+       if (argc >= 4) {
+               resume_handle = atoi(argv[3]);
+               resume_handle_p = &resume_handle;
+       }
+
+       ZERO_STRUCT(info_ctr);
+
+       info_ctr.level = level;
+
+       switch (level) {
+               case 0:
+                       ZERO_STRUCT(ctr0);
+                       info_ctr.ctr.ctr0 = &ctr0;
+                       break;
+               case 1:
+                       ZERO_STRUCT(ctr1);
+                       info_ctr.ctr.ctr1 = &ctr1;
+                       break;
+               default:
+                       return WERR_INVALID_PARAM;
+       }
+
+       status = rpccli_srvsvc_NetConnEnum(cli, mem_ctx,
+                                          cli->desthost,
+                                          path,
+                                          &info_ctr,
+                                          0xffffffff,
+                                          &total_entries,
+                                          resume_handle_p,
+                                          &result);
+
+       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
+               goto done;
+       }
+
+ done:
+       return result;
+}
+
+
 /* List of commands exported by this module */
 
 struct cmd_set srvsvc_commands[] = {
 
        { "SRVSVC" },
 
-       { "srvinfo",     RPC_RTYPE_WERROR, NULL, cmd_srvsvc_srv_query_info, PI_SRVSVC, NULL, "Server query info", "" },
-       { "netshareenum",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_enum, PI_SRVSVC, NULL, "Enumerate shares", "" },
-       { "netsharegetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_get_info, PI_SRVSVC, NULL, "Get Share Info", "" },
-       { "netsharesetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_set_info, PI_SRVSVC, NULL, "Set Share Info", "" },
-       { "netfileenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_enum,  PI_SRVSVC, NULL, "Enumerate open files", "" },
-       { "netremotetod",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_remote_tod, PI_SRVSVC, NULL, "Fetch remote time of day", "" },
+       { "srvinfo",     RPC_RTYPE_WERROR, NULL, cmd_srvsvc_srv_query_info, &ndr_table_srvsvc.syntax_id, NULL, "Server query info", "" },
+       { "netshareenum",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate shares", "" },
+       { "netshareenumall",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_enum_all, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate all shares", "" },
+       { "netsharegetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_get_info, &ndr_table_srvsvc.syntax_id, NULL, "Get Share Info", "" },
+       { "netsharesetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_set_info, &ndr_table_srvsvc.syntax_id, NULL, "Set Share Info", "" },
+       { "netfileenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_enum,  &ndr_table_srvsvc.syntax_id, NULL, "Enumerate open files", "" },
+       { "netremotetod",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_remote_tod, &ndr_table_srvsvc.syntax_id, NULL, "Fetch remote time of day", "" },
+       { "netnamevalidate", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_name_validate, &ndr_table_srvsvc.syntax_id, NULL, "Validate sharename", "" },
+       { "netfilegetsec", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_get_sec, &ndr_table_srvsvc.syntax_id, NULL, "Get File security", "" },
+       { "netsessdel", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_sess_del, &ndr_table_srvsvc.syntax_id, NULL, "Delete Session", "" },
+       { "netsessenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_sess_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate Sessions", "" },
+       { "netdiskenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_disk_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate Disks", "" },
+       { "netconnenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_conn_enum, &ndr_table_srvsvc.syntax_id, NULL, "Enumerate Connections", "" },
 
        { NULL }
 };