r23779: Change from v2 or later to v3 or later.
[ira/wip.git] / source3 / utils / smbtree.c
index d9cd446f6cb976233c8e7680df79e4ff4ac77056..5deb29a149b3a03b5b3f66feea464e9376d03695 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -134,10 +134,12 @@ static BOOL get_rpc_shares(struct cli_state *cli,
        NTSTATUS status;
        struct rpc_pipe_client *pipe_hnd;
        TALLOC_CTX *mem_ctx;
-       ENUM_HND enum_hnd;
-       WERROR werr;
-       SRV_SHARE_INFO_CTR ctr;
+       uint32 enum_hnd;
+       struct srvsvc_NetShareCtr1 ctr1;
+       union srvsvc_NetShareCtr ctr;
+       uint32 numentries;
        int i;
+       uint32 info_level = 1;
 
        mem_ctx = talloc_new(NULL);
        if (mem_ctx == NULL) {
@@ -145,8 +147,7 @@ static BOOL get_rpc_shares(struct cli_state *cli,
                return False;
        }
 
-       init_enum_hnd(&enum_hnd, 0);
-
+       enum_hnd = 0;
        pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
 
        if (pipe_hnd == NULL) {
@@ -156,23 +157,24 @@ static BOOL get_rpc_shares(struct cli_state *cli,
                return False;
        }
 
-       werr = rpccli_srvsvc_net_share_enum(pipe_hnd, mem_ctx, 1, &ctr,
-                                           0xffffffff, &enum_hnd);
+       ZERO_STRUCT(ctr1);
+       level = 1;
+       ctr.ctr1 = &ctr1;
+
+       status = rpccli_srvsvc_NetShareEnum(pipe_hnd, mem_ctx, NULL,
+                                           &info_level, &ctr,
+                                           0xffffffff, &numentries,
+                                           &enum_hnd);
 
-       if (!W_ERROR_IS_OK(werr)) {
+       if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(mem_ctx);
                cli_rpc_pipe_close(pipe_hnd);
                return False;
        }
 
-       for (i=0; i<ctr.num_entries; i++) {
-               SRV_SHARE_INFO_1 *info = &ctr.share.info1[i];
-               char *name, *comment;
-               name = rpcstr_pull_unistr2_talloc(
-                       mem_ctx, &info->info_1_str.uni_netname);
-               comment = rpcstr_pull_unistr2_talloc(
-                       mem_ctx, &info->info_1_str.uni_remark);
-               fn(name, info->info_1.type, comment, state);
+       for (i=0; i<numentries; i++) {
+               fn(ctr.ctr1->array[i].name, ctr.ctr1->array[i].type, 
+                  ctr.ctr1->array[i].comment, state);
        }
 
        TALLOC_FREE(mem_ctx);