r4374: Follow metzes hint, change LookupRids a bit
authorVolker Lendecke <vlendec@samba.org>
Mon, 27 Dec 2004 09:48:49 +0000 (09:48 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:07:39 +0000 (13:07 -0500)
(This used to be commit b8fa5b9419c6397a4266bfdce3a31b1e016d7faa)

source4/rpc_server/samr/dcesrv_samr.c

index 9120bfe4686249fe2515564ad340a0cc4f5fe93c..6ab50fa4df3b7ea1ae0cbe0262c00e27a06db0fe 100644 (file)
@@ -1069,6 +1069,8 @@ static NTSTATUS samr_LookupRids(struct dcesrv_call_state *dce_call, TALLOC_CTX *
        struct samr_domain_state *d_state;
        int i;
        NTSTATUS status = NT_STATUS_OK;
+       struct samr_String *names;
+       uint32_t *ids;
 
        ZERO_STRUCT(r->out.names);
        ZERO_STRUCT(r->out.types);
@@ -1080,30 +1082,20 @@ static NTSTATUS samr_LookupRids(struct dcesrv_call_state *dce_call, TALLOC_CTX *
        if (r->in.num_rids == 0)
                return NT_STATUS_OK;
 
-       r->out.names.names = talloc_array_p(mem_ctx, struct samr_String,
-                                           r->in.num_rids);
-       if (r->out.names.names == NULL)
-               return NT_STATUS_NO_MEMORY;
+       names = talloc_array_p(mem_ctx, struct samr_String, r->in.num_rids);
+       ids = talloc_array_p(mem_ctx, uint32_t, r->in.num_rids);
 
-       r->out.types.ids = talloc_array_p(mem_ctx, uint32_t, r->in.num_rids);
-       if (r->out.types.ids == NULL)
+       if ((names == NULL) || (ids == NULL))
                return NT_STATUS_NO_MEMORY;
 
-       r->out.names.count = r->in.num_rids;
-       r->out.types.count = r->in.num_rids;
-
        for (i=0; i<r->in.num_rids; i++) {
                struct ldb_message **res;
                int count;
                const char * const attrs[] = {  "sAMAccountType",
                                                "sAMAccountName", NULL };
-               struct samr_String *str;
                uint32_t atype;
 
-               str = &r->out.names.names[i];
-
-               ZERO_STRUCTP(str);
-               r->out.types.ids[i] = 0;
+               ids[i] = SID_NAME_UNKNOWN;
 
                count = samdb_search(d_state->sam_ctx, mem_ctx,
                                     d_state->domain_dn, &res, attrs,
@@ -1114,8 +1106,8 @@ static NTSTATUS samr_LookupRids(struct dcesrv_call_state *dce_call, TALLOC_CTX *
                        continue;
                }
 
-               str->string = samdb_result_string(res[0], "sAMAccountName",
-                                                 NULL);
+               names[i].string = samdb_result_string(res[0], "sAMAccountName",
+                                                     NULL);
                
                atype = samdb_result_uint(res[0], "sAMAccountType", 0);
                if (atype == 0) {
@@ -1123,14 +1115,20 @@ static NTSTATUS samr_LookupRids(struct dcesrv_call_state *dce_call, TALLOC_CTX *
                        continue;
                }
 
-               r->out.types.ids[i] = samdb_atype_map(atype);
+               ids[i] = samdb_atype_map(atype);
                
-               if (r->out.types.ids[i] == SID_NAME_UNKNOWN) {
+               if (ids[i] == SID_NAME_UNKNOWN) {
                        status = STATUS_SOME_UNMAPPED;
                        continue;
                }
        }
-       
+
+       r->out.names.names = names;
+       r->out.names.count = r->in.num_rids;
+
+       r->out.types.ids = ids;
+       r->out.types.count = r->in.num_rids;
+
        return status;
 }