summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/usertools.c17
-rw-r--r--src/util/util.h7
2 files changed, 24 insertions, 0 deletions
diff --git a/src/util/usertools.c b/src/util/usertools.c
index cc8f583b..dc863ce8 100644
--- a/src/util/usertools.c
+++ b/src/util/usertools.c
@@ -627,3 +627,20 @@ sss_fqdom_len(struct sss_names_ctx *nctx,
len += fq_part_len(nctx, domain, FQ_FMT_FLAT_NAME, domain->flat_name);
return len;
}
+
+char *
+sss_get_domain_name(TALLOC_CTX *mem_ctx,
+ const char *orig_name,
+ struct sss_domain_info *dom)
+{
+ char *user_name;
+
+ if (IS_SUBDOMAIN(dom) && dom->fqnames) {
+ /* we always use the fully qualified name for subdomain users */
+ user_name = sss_tc_fqname(mem_ctx, dom->names, dom, orig_name);
+ } else {
+ user_name = talloc_strdup(mem_ctx, orig_name);
+ }
+
+ return user_name;
+}
diff --git a/src/util/util.h b/src/util/util.h
index e55c0b4d..8ae85f4f 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -390,6 +390,13 @@ size_t
sss_fqdom_len(struct sss_names_ctx *nctx,
struct sss_domain_info *domain);
+/* Subdomains use fully qualified names in the cache while primary domains use
+ * just the name. Return either of these for a specified domain or subdomain
+ */
+char *
+sss_get_domain_name(TALLOC_CTX *mem_ctx, const char *orig_name,
+ struct sss_domain_info *dom);
+
/* from backup-file.c */
int backup_file(const char *src, int dbglvl);