netapi: fix NetUserSetGroups.
authorGünther Deschner <gd@samba.org>
Fri, 12 Sep 2008 09:28:03 +0000 (11:28 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 12 Sep 2008 12:12:24 +0000 (14:12 +0200)
Guenther
(This used to be commit e8b27b69f33fb33c670026b3a24ed95a2f0099fe)

source3/lib/netapi/user.c

index 62df2f9da5894a11d4a328e7073d50a0c8822b6f..986c32ad9300f52df45b7f5b48cb97501dd2a053 100644 (file)
@@ -2938,6 +2938,7 @@ WERROR NetUserSetGroups_r(struct libnetapi_ctx *ctx,
        struct samr_Ids user_rids, name_types;
        struct samr_Ids group_rids;
        struct samr_RidWithAttributeArray *rid_array = NULL;
+       struct lsa_String *lsa_names = NULL;
 
        uint32_t *add_rids = NULL;
        uint32_t *del_rids = NULL;
@@ -3021,39 +3022,40 @@ WERROR NetUserSetGroups_r(struct libnetapi_ctx *ctx,
                        break;
        }
 
+       lsa_names = talloc_array(ctx, struct lsa_String, r->in.num_entries);
+       if (!lsa_names) {
+               werr = WERR_NOMEM;
+               goto done;
+       }
+
        for (i=0; i < r->in.num_entries; i++) {
 
                switch (r->in.level) {
                        case 0:
-                               init_lsa_String(&lsa_account_name, i0->grui0_name);
+                               init_lsa_String(&lsa_names[i], i0->grui0_name);
                                i0++;
                                break;
                        case 1:
-                               init_lsa_String(&lsa_account_name, i1->grui1_name);
+                               init_lsa_String(&lsa_names[i], i1->grui1_name);
                                i1++;
                                break;
                }
+       }
 
-               status = rpccli_samr_LookupNames(pipe_cli, ctx,
-                                                &domain_handle,
-                                                1,
-                                                &lsa_account_name,
-                                                &group_rids,
-                                                &name_types);
-               if (!NT_STATUS_IS_OK(status)) {
-                       werr = ntstatus_to_werror(status);
-                       goto done;
-               }
-
-               if (!add_rid_to_array_unique(ctx,
-                                            group_rids.ids[0],
-                                            &member_rids,
-                                            &num_member_rids)) {
-                       werr = WERR_GENERAL_FAILURE;
-                       goto done;
-               }
+       status = rpccli_samr_LookupNames(pipe_cli, ctx,
+                                        &domain_handle,
+                                        r->in.num_entries,
+                                        lsa_names,
+                                        &group_rids,
+                                        &name_types);
+       if (!NT_STATUS_IS_OK(status)) {
+               werr = ntstatus_to_werror(status);
+               goto done;
        }
 
+       member_rids = group_rids.ids;
+       num_member_rids = group_rids.count;
+
        status = rpccli_samr_GetGroupsForUser(pipe_cli, ctx,
                                              &user_handle,
                                              &rid_array);