From: Stefan Metzmacher Date: Tue, 11 Mar 2008 15:38:05 +0000 (+0100) Subject: wb-ndr: use WINBIND_LOOKUP_LEVEL_SID2DOMGROUPS instead of WINBINDD_GETUSERDOMGROUPS; X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=337f45d218cb5f9adab49a5c267f391708e75fad;p=metze%2Fsamba%2Fwb-ndr.git wb-ndr: use WINBIND_LOOKUP_LEVEL_SID2DOMGROUPS instead of WINBINDD_GETUSERDOMGROUPS; metze --- diff --git a/source/winbindd/winbindd_async.c b/source/winbindd/winbindd_async.c index e559829f307..faaeccd9b7c 100644 --- a/source/winbindd/winbindd_async.c +++ b/source/winbindd/winbindd_async.c @@ -980,8 +980,10 @@ struct gettoken_state { }; static void gettoken_recvdomgroups(TALLOC_CTX *mem_ctx, bool success, - struct winbindd_response *response, - void *c, void *private_data); + struct winbindd_ndr_call *c, + void *_private_data, + void *_cont, + void *cont_private); static void gettoken_recvaliases(void *private_data, bool success, const DOM_SID *aliases, size_t num_aliases); @@ -993,8 +995,8 @@ void winbindd_gettoken_async(TALLOC_CTX *mem_ctx, const DOM_SID *user_sid, void *private_data) { struct winbindd_domain *domain; - struct winbindd_request request; struct gettoken_state *state; + struct winbind_lookup *r = NULL; state = TALLOC_ZERO_P(mem_ctx, struct gettoken_state); if (state == NULL) { @@ -1019,31 +1021,53 @@ void winbindd_gettoken_async(TALLOC_CTX *mem_ctx, const DOM_SID *user_sid, return; } - ZERO_STRUCT(request); - request.cmd = WINBINDD_GETUSERDOMGROUPS; - sid_to_fstring(request.data.sid, user_sid); + r = TALLOC_P(state, struct winbind_lookup); + if (!r) goto nomem; + r->in.level = TALLOC_P(r, enum winbind_lookup_level); + if (!r->in.level) goto nomem; + + *r->in.level = WINBIND_LOOKUP_LEVEL_SID2DOMGROUPS; + r->in.req.sid = &state->user_sid; + if (!r->in.req.sid) goto nomem; - do_async_domain(mem_ctx, domain, &request, gettoken_recvdomgroups, - NULL, state); + do_async_ndr_domain(mem_ctx, domain, + NDR_WINBIND_LOOKUP, r, + gettoken_recvdomgroups, state, + NULL, NULL); + return; +nomem: + DEBUG(5, ("%s: no memory\n",__location__)); + cont(private_data, False, NULL, 0); } static void gettoken_recvdomgroups(TALLOC_CTX *mem_ctx, bool success, - struct winbindd_response *response, - void *c, void *private_data) + struct winbindd_ndr_call *c, + void *_private_data, + void *_cont, + void *cont_private) { struct gettoken_state *state = - talloc_get_type_abort(private_data, struct gettoken_state); - char *sids_str; - + talloc_get_type_abort(_private_data, struct gettoken_state); + struct winbind_lookup *r = + talloc_get_type_abort(c->ndr.r, struct winbind_lookup); + uint32_t i; + if (!success) { DEBUG(10, ("Could not get domain groups\n")); - state->cont(state->private_data, False, NULL, 0); + TALLOC_FREE(r); + state->cont(state->private_data, false, NULL, 0); return; } - sids_str = (char *)response->extra_data.data; + if (r->out.result != WINBIND_STATUS_OK) { + DEBUG(5, ("Could not trigger lookup(sid2domgroups): 0x%08X\n", + r->out.result)); + TALLOC_FREE(r); + state->cont(state->private_data, false, NULL, 0); + return; + } - if (sids_str == NULL) { + if (state->num_sids == 0) { /* This could be normal if we are dealing with a local user and local groups */ @@ -1065,15 +1089,16 @@ static void gettoken_recvdomgroups(TALLOC_CTX *mem_ctx, bool success, return; } - if (sids_str && !parse_sidlist(mem_ctx, sids_str, &state->sids, - &state->num_sids)) { - DEBUG(0, ("Could not parse sids\n")); - state->cont(state->private_data, False, NULL, 0); - return; + for (i=0; i < r->out.rep->sid_array.num_sids; i++) { + if (!NT_STATUS_IS_OK(add_sid_to_array(mem_ctx, r->out.rep->sid_array.sids[i].sid, + &state->sids, &state->num_sids))) + { + DEBUG(0, ("Out of memory\n")); + state->cont(state->private_data, false, NULL, 0); + return; + } } - SAFE_FREE(response->extra_data.data); - if (state->alias_domain == NULL) { DEBUG(10, ("Don't expand domain local groups\n")); state->cont(state->private_data, True, state->sids,