};
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);
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) {
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 */
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,