* wbint_LookupSid. Preallocated with num_sids.
*/
uint32_t *single_sids;
+ /* Pointer into the "domains" array above*/
+ struct wb_lookupsids_domain **single_domains;
uint32_t num_single_sids;
uint32_t single_sids_done;
if (tevent_req_nomem(state->single_sids, req)) {
return tevent_req_post(req, ev);
}
+ state->single_domains = talloc_zero_array(state,
+ struct wb_lookupsids_domain *,
+ num_sids);
+ if (tevent_req_nomem(state->single_domains, req)) {
+ return tevent_req_post(req, ev);
+ }
state->res_domains = talloc_zero(state, struct lsa_RefDomainList);
if (tevent_req_nomem(state->res_domains, req)) {
state->single_sids[state->num_single_sids] =
res_sid_index;
+ state->single_domains[state->num_single_sids] = d;
state->num_single_sids += 1;
}
state->domains_done += 1;
&domain_name, &name);
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
+ struct wb_lookupsids_domain *wb_domain;
+ const char *tmpname;
+
type = SID_NAME_UNKNOWN;
- domain_name = talloc_strdup(talloc_tos(), "");
+ wb_domain = state->single_domains[state->single_sids_done];
+ if (wb_domain != NULL) {
+ /*
+ * If the lookupsid failed because the rid not
+ * found in a domain and we have a reference
+ * to the lookup domain, use the name from
+ * there.
+ *
+ * Callers like sid2xid will use the domain
+ * name in the idmap backend to figure out
+ * which domain to use in processing.
+ */
+ tmpname = wb_domain->domain->name;
+ } else {
+ tmpname = "";
+ }
+ domain_name = talloc_strdup(talloc_tos(), tmpname);
if (tevent_req_nomem(domain_name, req)) {
return;
}