Use rpccli_lsa_EnumAccounts() in net and rpcclient.
authorGünther Deschner <gd@samba.org>
Thu, 14 Feb 2008 00:32:56 +0000 (01:32 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 14 Feb 2008 00:32:56 +0000 (01:32 +0100)
Guenther
(This used to be commit bdbcfa4419a54b98ea577b0052894ddaa06890ce)

source3/rpcclient/cmd_lsarpc.c
source3/utils/net_rpc_rights.c

index c014dba676e15b78dc81fca439b4cddd35419c6f..6e12a9098262df1ea029ea4d151d2c8e1e101f3d 100644 (file)
@@ -550,8 +550,7 @@ static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli,
 
        uint32 enum_context=0;
        uint32 pref_max_length=0x1000;
-       DOM_SID *sids;
-       uint32 count=0;
+       struct lsa_SidArray sid_array;
        int i;
 
        if (argc > 3) {
@@ -572,19 +571,22 @@ static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli,
        if (!NT_STATUS_IS_OK(result))
                goto done;
 
-       result = rpccli_lsa_enum_sids(cli, mem_ctx, &pol, &enum_context, pref_max_length,
-                                       &count, &sids);
+       result = rpccli_lsa_EnumAccounts(cli, mem_ctx,
+                                        &pol,
+                                        &enum_context,
+                                        &sid_array,
+                                        pref_max_length);
 
        if (!NT_STATUS_IS_OK(result))
                goto done;
 
        /* Print results */
-       printf("found %d SIDs\n\n", count);
+       printf("found %d SIDs\n\n", sid_array.num_sids);
 
-       for (i = 0; i < count; i++) {
+       for (i = 0; i < sid_array.num_sids; i++) {
                fstring sid_str;
 
-               sid_to_fstring(sid_str, &sids[i]);
+               sid_to_fstring(sid_str, sid_array.sids[i].sid);
                printf("%s\n", sid_str);
        }
 
index de6e14ebadacf54993c27e129955ede96d3ec8af..d8c7462c0d563c4b7e3d7049ee4816cf07dbe689 100644 (file)
@@ -214,24 +214,27 @@ static NTSTATUS enum_accounts_for_privilege(struct rpc_pipe_client *pipe_hnd,
        NTSTATUS result;
        uint32 enum_context=0;
        uint32 pref_max_length=0x1000;
-       DOM_SID *sids = NULL;
-       uint32 count=0;
+       struct lsa_SidArray sid_array;
        int i;
        fstring name;
 
-       result = rpccli_lsa_enum_sids(pipe_hnd, ctx, pol, &enum_context, 
-               pref_max_length, &count, &sids);
+       result = rpccli_lsa_EnumAccounts(pipe_hnd, ctx,
+                                        pol,
+                                        &enum_context,
+                                        &sid_array,
+                                        pref_max_length);
 
        if (!NT_STATUS_IS_OK(result))
                return result;
                
        d_printf("%s:\n", privilege);
 
-       for ( i=0; i<count; i++ ) {
-       
-                  
-               result = check_privilege_for_user( pipe_hnd, ctx, pol, &sids[i], privilege);
-               
+       for ( i=0; i<sid_array.num_sids; i++ ) {
+
+               result = check_privilege_for_user(pipe_hnd, ctx, pol,
+                                                 sid_array.sids[i].sid,
+                                                 privilege);
+
                if ( ! NT_STATUS_IS_OK(result)) {
                        if ( ! NT_STATUS_EQUAL(result, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
                                return result;
@@ -241,9 +244,9 @@ static NTSTATUS enum_accounts_for_privilege(struct rpc_pipe_client *pipe_hnd,
 
                /* try to convert the SID to a name.  Fall back to 
                   printing the raw SID if necessary */
-               result = sid_to_name( pipe_hnd, ctx, &sids[i], name );
+               result = sid_to_name( pipe_hnd, ctx, sid_array.sids[i].sid, name );
                if ( !NT_STATUS_IS_OK (result) )
-                       sid_to_fstring(name, &sids[i]);
+                       sid_to_fstring(name, sid_array.sids[i].sid);
 
                d_printf("  %s\n", name);
        }
@@ -261,30 +264,32 @@ static NTSTATUS enum_privileges_for_accounts(struct rpc_pipe_client *pipe_hnd,
        NTSTATUS result;
        uint32 enum_context=0;
        uint32 pref_max_length=0x1000;
-       DOM_SID *sids;
-       uint32 count=0;
+       struct lsa_SidArray sid_array;
        int i;
        fstring name;
 
-       result = rpccli_lsa_enum_sids(pipe_hnd, ctx, pol, &enum_context, 
-               pref_max_length, &count, &sids);
+       result = rpccli_lsa_EnumAccounts(pipe_hnd, ctx,
+                                        pol,
+                                        &enum_context,
+                                        &sid_array,
+                                        pref_max_length);
 
        if (!NT_STATUS_IS_OK(result))
                return result;
-               
-       for ( i=0; i<count; i++ ) {
-       
+
+       for ( i=0; i<sid_array.num_sids; i++ ) {
+
                /* try to convert the SID to a name.  Fall back to 
                   printing the raw SID if necessary */
-                  
-               result = sid_to_name(pipe_hnd, ctx, &sids[i], name );
+
+               result = sid_to_name(pipe_hnd, ctx, sid_array.sids[i].sid, name);
                if ( !NT_STATUS_IS_OK (result) )
-                       sid_to_fstring(name, &sids[i]);
-                       
+                       sid_to_fstring(name, sid_array.sids[i].sid);
+
                d_printf("%s\n", name);
-               
-               result = enum_privileges_for_user(pipe_hnd, ctx, pol, &sids[i] );
-               
+
+               result = enum_privileges_for_user(pipe_hnd, ctx, pol,
+                                                 sid_array.sids[i].sid);
                if ( !NT_STATUS_IS_OK(result) )
                        return result;