s4-samr: merge samr_EnumDomainGroups from s3 idl. (fixme: python)
authorGünther Deschner <gd@samba.org>
Fri, 7 Nov 2008 13:51:21 +0000 (14:51 +0100)
committerGünther Deschner <gd@samba.org>
Mon, 10 Nov 2008 20:46:30 +0000 (21:46 +0100)
Guenther

librpc/idl/samr.idl
source4/libnet/libnet_group.c
source4/rpc_server/samr/dcesrv_samr.c
source4/torture/rpc/samr.c

index 55c95a9bdce7b4eb7745524ba219136178b3408f..ba813b730f6cd69179d9f0d4d71f6f3130c6b82e 100644 (file)
@@ -441,11 +441,11 @@ import "misc.idl", "lsa.idl", "security.idl";
        /************************/
        /* Function    0x0b     */
        NTSTATUS samr_EnumDomainGroups(
-               [in,ref]      policy_handle *domain_handle,
+               [in]          policy_handle *domain_handle,
                [in,out,ref]  uint32 *resume_handle,
+               [out,ref]     samr_SamArray **sam,
                [in]          uint32 max_size,
-               [out,unique]  samr_SamArray *sam,
-               [out]         uint32 num_entries
+               [out,ref]     uint32 *num_entries
                );
 
        /************************/
index eded3785110aae555144d76e8180ad0393909a46..af5fe4d5d375ed18d9f16ad2746e73766f002f7b 100644 (file)
@@ -518,6 +518,10 @@ static void continue_domain_queried(struct rpc_request *req)
        s->group_list.in.max_size       = s->page_size;
        s->group_list.in.resume_handle  = &s->resume_index;
        s->group_list.out.resume_handle = &s->resume_index;
+       s->group_list.out.num_entries   = talloc(s, uint32_t);
+       if (composite_nomem(s->group_list.out.num_entries, c)) return;
+       s->group_list.out.sam           = talloc(s, struct samr_SamArray *);
+       if (composite_nomem(s->group_list.out.sam, c)) return;
 
        /* send the request */
        enum_req = dcerpc_samr_EnumDomainGroups_send(s->ctx->samr.pipe, c, &s->group_list);
@@ -549,6 +553,10 @@ static void continue_samr_domain_opened(struct composite_context *ctx)
        s->group_list.in.max_size       = s->page_size;
        s->group_list.in.resume_handle  = &s->resume_index;
        s->group_list.out.resume_handle = &s->resume_index;
+       s->group_list.out.num_entries   = talloc(s, uint32_t);
+       if (composite_nomem(s->group_list.out.num_entries, c)) return;
+       s->group_list.out.sam           = talloc(s, struct samr_SamArray *);
+       if (composite_nomem(s->group_list.out.sam, c)) return;
 
        /* send the request */
        enum_req = dcerpc_samr_EnumDomainGroups_send(s->ctx->samr.pipe, c, &s->group_list);
@@ -587,15 +595,15 @@ static void continue_groups_enumerated(struct rpc_request *req)
                /* get enumerated accounts counter and resume handle (the latter allows
                   making subsequent call to continue enumeration) */
                s->resume_index = *s->group_list.out.resume_handle;
-               s->count        = s->group_list.out.num_entries;
+               s->count        = *s->group_list.out.num_entries;
 
                /* prepare returned group accounts array */
-               s->groups       = talloc_array(c, struct grouplist, s->group_list.out.sam->count);
+               s->groups       = talloc_array(c, struct grouplist, (*s->group_list.out.sam)->count);
                if (composite_nomem(s->groups, c)) return;
 
-               for (i = 0; i < s->group_list.out.sam->count; i++) {
+               for (i = 0; i < (*s->group_list.out.sam)->count; i++) {
                        struct dom_sid *group_sid;
-                       struct samr_SamEntry *entry = &s->group_list.out.sam->entries[i];
+                       struct samr_SamEntry *entry = &(*s->group_list.out.sam)->entries[i];
                        struct dom_sid *domain_sid = (*s->query_domain.out.info)->domain.sid;
                        
                        /* construct group sid from returned rid and queried domain sid */
index f6691a5a6d919a4f3630447f70c59c09be9092a9..2a3666b09b291637b6540e78a416298ea6fcca52 100644 (file)
@@ -1150,10 +1150,11 @@ static NTSTATUS dcesrv_samr_EnumDomainGroups(struct dcesrv_call_state *dce_call,
        int ldb_cnt, count, i, first;
        struct samr_SamEntry *entries;
        const char * const attrs[3] = { "objectSid", "sAMAccountName", NULL };
+       struct samr_SamArray *sam;
 
        *r->out.resume_handle = 0;
-       r->out.sam = NULL;
-       r->out.num_entries = 0;
+       *r->out.sam = NULL;
+       *r->out.num_entries = 0;
 
        DCESRV_PULL_HANDLE(h, r->in.domain_handle, SAMR_HANDLE_DOMAIN);
 
@@ -1204,20 +1205,22 @@ static NTSTATUS dcesrv_samr_EnumDomainGroups(struct dcesrv_call_state *dce_call,
 
        /* return the rest, limit by max_size. Note that we 
           use the w2k3 element size value of 54 */
-       r->out.num_entries = count - first;
-       r->out.num_entries = MIN(r->out.num_entries, 
+       *r->out.num_entries = count - first;
+       *r->out.num_entries = MIN(*r->out.num_entries,
                                 1+(r->in.max_size/SAMR_ENUM_USERS_MULTIPLIER));
 
-       r->out.sam = talloc(mem_ctx, struct samr_SamArray);
-       if (!r->out.sam) {
+       sam = talloc(mem_ctx, struct samr_SamArray);
+       if (!sam) {
                return NT_STATUS_NO_MEMORY;
        }
 
-       r->out.sam->entries = entries+first;
-       r->out.sam->count = r->out.num_entries;
+       sam->entries = entries+first;
+       sam->count = *r->out.num_entries;
+
+       *r->out.sam = sam;
 
-       if (r->out.num_entries < count - first) {
-               *r->out.resume_handle = entries[first+r->out.num_entries-1].idx;
+       if (*r->out.num_entries < count - first) {
+               *r->out.resume_handle = entries[first+*r->out.num_entries-1].idx;
                return STATUS_MORE_ENTRIES;
        }
 
index 4eb5b39ce035c14ef5c0eb88f010d1d29b26141c..24d16ceeb32bfc6b750bc082903ddf57aafe5c5e 100644 (file)
@@ -3434,6 +3434,8 @@ static bool test_EnumDomainGroups(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        NTSTATUS status;
        struct samr_EnumDomainGroups r;
        uint32_t resume_handle=0;
+       struct samr_SamArray *sam = NULL;
+       uint32_t num_entries = 0;
        int i;
        bool ret = true;
 
@@ -3443,6 +3445,8 @@ static bool test_EnumDomainGroups(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        r.in.resume_handle = &resume_handle;
        r.in.max_size = (uint32_t)-1;
        r.out.resume_handle = &resume_handle;
+       r.out.num_entries = &num_entries;
+       r.out.sam = &sam;
 
        status = dcerpc_samr_EnumDomainGroups(p, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
@@ -3450,12 +3454,12 @@ static bool test_EnumDomainGroups(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                return false;
        }
        
-       if (!r.out.sam) {
+       if (!sam) {
                return false;
        }
 
-       for (i=0;i<r.out.sam->count;i++) {
-               if (!test_OpenGroup(p, mem_ctx, handle, r.out.sam->entries[i].idx)) {
+       for (i=0;i<sam->count;i++) {
+               if (!test_OpenGroup(p, mem_ctx, handle, sam->entries[i].idx)) {
                        ret = false;
                }
        }
@@ -4092,6 +4096,8 @@ static bool test_GroupList(struct dcerpc_pipe *p, struct torture_context *tctx,
        struct samr_QueryDisplayInfo q2;
        NTSTATUS status;
        uint32_t resume_handle=0;
+       struct samr_SamArray *sam = NULL;
+       uint32_t num_entries = 0;
        int i;
        bool ret = true;
        uint32_t total_size;
@@ -4107,6 +4113,8 @@ static bool test_GroupList(struct dcerpc_pipe *p, struct torture_context *tctx,
        q1.in.resume_handle = &resume_handle;
        q1.in.max_size = 5;
        q1.out.resume_handle = &resume_handle;
+       q1.out.num_entries = &num_entries;
+       q1.out.sam = &sam;
 
        status = STATUS_MORE_ENTRIES;
        while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
@@ -4116,16 +4124,16 @@ static bool test_GroupList(struct dcerpc_pipe *p, struct torture_context *tctx,
                    !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES))
                        break;
 
-               for (i=0; i<q1.out.num_entries; i++) {
+               for (i=0; i<*q1.out.num_entries; i++) {
                        add_string_to_array(tctx,
-                                           q1.out.sam->entries[i].name.string,
+                                           sam->entries[i].name.string,
                                            &names, &num_names);
                }
        }
 
        torture_assert_ntstatus_ok(tctx, status, "EnumDomainGroups");
        
-       torture_assert(tctx, q1.out.sam, "EnumDomainGroups failed to return q1.out.sam");
+       torture_assert(tctx, sam, "EnumDomainGroups failed to return sam");
 
        q2.in.domain_handle = handle;
        q2.in.level = 5;