Use rpccli_samr_GetGroupsForUser() all over the place.
authorGünther Deschner <gd@samba.org>
Wed, 6 Feb 2008 15:19:20 +0000 (16:19 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 7 Feb 2008 13:25:18 +0000 (14:25 +0100)
Guenther
(This used to be commit d1c669920e88e7fecd13101c4ddfe45354c5ecdb)

source3/rpcclient/cmd_samr.c
source3/utils/net_rpc.c
source3/winbindd/winbindd_rpc.c

index 43f53cb263a2a5726f1a9c0313361a4ac0555c22..c77d13d88e89b5a914ec5eaff90eca8284620aad 100644 (file)
@@ -605,13 +605,12 @@ static NTSTATUS cmd_samr_query_usergroups(struct rpc_pipe_client *cli,
                                domain_pol, 
                                user_pol;
        NTSTATUS                result = NT_STATUS_UNSUCCESSFUL;
-       uint32                  num_groups, 
-                               user_rid;
+       uint32                  user_rid;
        uint32                  access_mask = MAXIMUM_ALLOWED_ACCESS;
-       DOM_GID                 *user_gids;
        int                     i;
        fstring                 server;
-       
+       struct samr_RidWithAttributeArray *rid_array = NULL;
+
        if ((argc < 2) || (argc > 3)) {
                printf("Usage: %s rid [access mask]\n", argv[0]);
                return NT_STATUS_OK;
@@ -648,15 +647,17 @@ static NTSTATUS cmd_samr_query_usergroups(struct rpc_pipe_client *cli,
        if (!NT_STATUS_IS_OK(result))
                goto done;
 
-       result = rpccli_samr_query_usergroups(cli, mem_ctx, &user_pol,
-                                          &num_groups, &user_gids);
+       result = rpccli_samr_GetGroupsForUser(cli, mem_ctx,
+                                             &user_pol,
+                                             &rid_array);
 
        if (!NT_STATUS_IS_OK(result))
                goto done;
 
-       for (i = 0; i < num_groups; i++) {
-               printf("\tgroup rid:[0x%x] attr:[0x%x]\n", 
-                      user_gids[i].g_rid, user_gids[i].attr);
+       for (i = 0; i < rid_array->count; i++) {
+               printf("\tgroup rid:[0x%x] attr:[0x%x]\n",
+                      rid_array->rids[i].rid,
+                      rid_array->rids[i].attributes);
        }
 
        rpccli_samr_Close(cli, mem_ctx, &user_pol);
index 8530767d38aa0b55c5eb322987c7bef956049915..612ae1cb2e001ddfea83e9e2c602386a934c4aaa 100644 (file)
@@ -1164,7 +1164,7 @@ static NTSTATUS rpc_user_info_internals(const DOM_SID *domain_sid,
        uint32 flags = 0x000003e8; /* Unknown */
        int i;
        char **names;
-       DOM_GID *user_gids;
+       struct samr_RidWithAttributeArray *rid_array = NULL;
 
        if (argc < 1) {
                d_printf("User must be specified\n");
@@ -1203,11 +1203,14 @@ static NTSTATUS rpc_user_info_internals(const DOM_SID *domain_sid,
                                      &user_pol);
        if (!NT_STATUS_IS_OK(result)) goto done;
 
-       result = rpccli_samr_query_usergroups(pipe_hnd, mem_ctx, &user_pol,
-                                          &num_rids, &user_gids);
+       result = rpccli_samr_GetGroupsForUser(pipe_hnd, mem_ctx,
+                                             &user_pol,
+                                             &rid_array);
 
        if (!NT_STATUS_IS_OK(result)) goto done;
 
+       num_rids = rid_array->count;
+
        /* Look up rids */
 
        if (num_rids) {
@@ -1217,7 +1220,7 @@ static NTSTATUS rpc_user_info_internals(const DOM_SID *domain_sid,
                }
 
                for (i = 0; i < num_rids; i++)
-                       rids[i] = user_gids[i].g_rid;
+                       rids[i] = rid_array->rids[i].rid;
 
                result = rpccli_samr_lookup_rids(pipe_hnd, mem_ctx, &domain_pol,
                                              num_rids, rids,
index 98e4077a4df8497b63772f1394c76c52e8259d67..8e196e50ec0a9455d9eb0bcecc73d780131b956b 100644 (file)
@@ -510,7 +510,7 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
        POLICY_HND dom_pol, user_pol;
        uint32 des_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
-       DOM_GID *user_groups;
+       struct samr_RidWithAttributeArray *rid_array = NULL;
        unsigned int i;
        uint32 user_rid;
        struct rpc_pipe_client *cli;
@@ -557,8 +557,10 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
                return result;
 
        /* Query user rids */
-       result = rpccli_samr_query_usergroups(cli, mem_ctx, &user_pol, 
-                                          num_groups, &user_groups);
+       result = rpccli_samr_GetGroupsForUser(cli, mem_ctx,
+                                             &user_pol,
+                                             &rid_array);
+       *num_groups = rid_array->count;
 
        rpccli_samr_Close(cli, mem_ctx, &user_pol);
 
@@ -572,9 +574,9 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
        for (i=0;i<(*num_groups);i++) {
                sid_copy(&((*user_grpsids)[i]), &domain->sid);
                sid_append_rid(&((*user_grpsids)[i]),
-                               user_groups[i].g_rid);
+                               rid_array->rids[i].rid);
        }
-       
+
        return NT_STATUS_OK;
 }