state->sids = sids;
state->num_sids = num_sids;
- if (num_sids == 0) {
- tevent_req_done(req);
- return tevent_req_post(req, ev);
- }
-
state->single_sids = talloc_array(state, uint32_t, num_sids);
if (tevent_req_nomem(state->single_sids, req)) {
return tevent_req_post(req, ev);
return tevent_req_post(req, ev);
}
+ if (num_sids == 0) {
+ tevent_req_done(req);
+ return tevent_req_post(req, ev);
+ }
+
for (i=0; i<num_sids; i++) {
struct wb_lookupsids_domain *d;
d = &state->domains[state->domains_done];
- if (sid_check_is_domain(&d->sid)) {
+ if (sid_check_is_our_sam(&d->sid)) {
state->rids.num_rids = d->sids.num_sids;
state->rids.rids = talloc_array(state, uint32_t,
state->rids.num_rids);
}
subreq = dcerpc_wbint_LookupRids_send(
state, state->ev, dom_child_handle(d->domain),
- &state->rids, &state->domain_name,
+ &d->sid, &state->rids, &state->domain_name,
&state->rid_names);
if (tevent_req_nomem(subreq, req)) {
return false;
return false;
}
- if (sid_check_is_in_our_domain(sid)) {
+ if (sid_check_is_in_our_sam(sid)) {
/*
* Passdb lookup via lookuprids
*/
struct lsa_DomainInfo *new_domain;
for (i=0; i<list->count; i++) {
- if (sid_equal(domain->sid, list->domains[i].sid)) {
+ if (dom_sid_equal(domain->sid, list->domains[i].sid)) {
*idx = i;
return true;
}
uint32_t src_domain_index, dst_domain_index;
src_domain_index = src_name->sid_index;
+ if (src_domain_index >= src_domains->count) {
+ return false;
+ }
src_domain = &src_domains->domains[src_domain_index];
if (!wb_lookupsids_find_dom_idx(
&state->tmp_domains, &state->tmp_names.names[i],
state->res_domains, state->res_names,
res_sid_index)) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return;
}
}
&src_domains, &src_name,
state->res_domains, state->res_names,
res_sid_index)) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return;
}
state->single_sids_done += 1;
&src_domains, &src_name,
state->res_domains, state->res_names,
res_sid_index)) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return;
}
}
if (tevent_req_is_nterror(req, &status)) {
return status;
}
+
+ /*
+ * The returned names need to match the given sids,
+ * if not we have a bug in the code!
+ *
+ */
+ if (state->res_names->count != state->num_sids) {
+ DEBUG(0, ("res_names->count = %d, expected %d\n",
+ state->res_names->count, state->num_sids));
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ /*
+ * Not strictly needed, but it might make debugging in the callers
+ * easier in future, if the talloc_array_length() returns the
+ * expected result...
+ */
+ state->res_domains->domains = talloc_realloc(state->res_domains,
+ state->res_domains->domains,
+ struct lsa_DomainInfo,
+ state->res_domains->count);
+
*domains = talloc_move(mem_ctx, &state->res_domains);
*names = talloc_move(mem_ctx, &state->res_names);
return NT_STATUS_OK;