struct winbindd_domain *domain;
int i;
+ char *domain_name = NULL;
char *name = NULL;
enum SID_NAME_USE type;
sid_copy(&dom_sid, sid);
sid_split_rid(&dom_sid, &rid);
- domain = find_domain_from_sid(&dom_sid);
+ domain = find_lookup_domain_from_sid(sid);
if (domain == NULL) {
DEBUG(3, ("Could not find domain for sid %s\n",
}
result = domain->methods->sid_to_name(domain, mem_ctx, sid,
- &name, &type);
+ &domain_name, &name, &type);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(3, ("sid_to_name failed for sid %s\n",
DEBUG(10, ("Found name %s, type %d\n", name, type));
if (type == SID_NAME_USER) {
- add_member(domain->name, name, members, num_members);
+ add_member(domain_name, name, members, num_members);
goto done;
}
goto done;
}
- /* Expand the domain group */
+ /* Expand the domain group, this must be done via the target domain */
+
+ domain = find_domain_from_sid(sid);
+
+ if (domain == NULL) {
+ DEBUG(3, ("Could not find domain from SID %s\n",
+ sid_string_static(sid)));
+ goto done;
+ }
result = domain->methods->lookup_groupmem(domain, mem_ctx,
sid, &num_names,
return NT_STATUS_OK;
}
- talloced_info = (struct acct_info *)
- talloc_memdup(mem_ctx, *info,
+ talloced_info = (struct acct_info *)TALLOC_MEMDUP(mem_ctx, *info,
*num_entries * sizeof(struct acct_info));
SAFE_FREE(*info);
/* convert a single name to a sid in a domain */
static NTSTATUS name_to_sid(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
+ const char *domain_name,
const char *name,
DOM_SID *sid,
enum SID_NAME_USE *type)
if (!pdb_find_alias(name, sid))
return NT_STATUS_NONE_MAPPED;
- *type = SID_NAME_ALIAS;
+ if (sid_check_is_in_builtin(sid))
+ *type = SID_NAME_WKN_GRP;
+ else
+ *type = SID_NAME_ALIAS;
+
return NT_STATUS_OK;
}
static NTSTATUS sid_to_name(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const DOM_SID *sid,
+ char **domain_name,
char **name,
enum SID_NAME_USE *type)
{
if (!pdb_get_aliasinfo(sid, &info))
return NT_STATUS_NONE_MAPPED;
+ *domain_name = talloc_strdup(mem_ctx, domain->name);
*name = talloc_strdup(mem_ctx, info.acct_name);
- *type = SID_NAME_ALIAS;
+ if (sid_check_is_in_builtin(sid))
+ *type = SID_NAME_WKN_GRP;
+ else
+ *type = SID_NAME_ALIAS;
return NT_STATUS_OK;
}
char ***alt_names,
DOM_SID **dom_sids)
{
- return NT_STATUS_OK;
+ NTSTATUS nt_status;
+ int enum_ctx = 0;
+ int num_sec_domains;
+ TRUSTDOM **domains;
+ *num_domains = 0;
+ *names = NULL;
+ *alt_names = NULL;
+ *dom_sids = NULL;
+ do {
+ int i;
+ nt_status = secrets_get_trusted_domains(mem_ctx, &enum_ctx, 1,
+ &num_sec_domains,
+ &domains);
+ *names = TALLOC_REALLOC_ARRAY(mem_ctx, *names, char *,
+ num_sec_domains + *num_domains);
+ *alt_names = TALLOC_REALLOC_ARRAY(mem_ctx, *alt_names, char *,
+ num_sec_domains + *num_domains);
+ *dom_sids = TALLOC_REALLOC_ARRAY(mem_ctx, *dom_sids, DOM_SID,
+ num_sec_domains + *num_domains);
+
+ for (i=0; i< num_sec_domains; i++) {
+ if (pull_ucs2_talloc(mem_ctx, &(*names)[*num_domains],
+ domains[i]->name) == -1) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ (*alt_names)[*num_domains] = NULL;
+ (*dom_sids)[*num_domains] = domains[i]->sid;
+ (*num_domains)++;
+ }
+
+ } while (NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES));
+
+ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_MORE_ENTRIES)) {
+ return NT_STATUS_OK;
+ }
+ return nt_status;
}
/* find the domain sid for a domain */