diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2013-07-23 12:55:25 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-07-24 13:52:33 +0200 |
commit | bfd59d1a2d0d45125e5164ef12c425690d519f61 (patch) | |
tree | aa1c8ea874622481d9b75b3f9a31f980601baed8 /src/providers/ldap/sdap.c | |
parent | bbb7ba8890908613b1b723746e091aed740af9f9 (diff) | |
download | sssd-bfd59d1a2d0d45125e5164ef12c425690d519f61.tar.gz sssd-bfd59d1a2d0d45125e5164ef12c425690d519f61.tar.bz2 sssd-bfd59d1a2d0d45125e5164ef12c425690d519f61.zip |
LDAP: Use domain-specific name where appropriate
The subdomain users user FQDN in their name attribute. However, handling
of whether to use FQDN in the LDAP code was not really good. This patch
introduces a utility function and converts code that was relying on
user/group names matching to this utility function.
This is a temporary fix until we can refactor the sysdb API in #2011.
Diffstat (limited to 'src/providers/ldap/sdap.c')
-rw-r--r-- | src/providers/ldap/sdap.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c index 5497d943..7741030c 100644 --- a/src/providers/ldap/sdap.c +++ b/src/providers/ldap/sdap.c @@ -1209,3 +1209,54 @@ int sdap_replace_id(struct sysdb_attrs *entry, const char *attr, id_t val) return EOK; } + +static errno_t +sdap_get_primary_name(TALLOC_CTX *memctx, + const char *attr_name, + struct sysdb_attrs *attrs, + struct sss_domain_info *dom, + const char **_primary_name) +{ + errno_t ret; + const char *orig_name = NULL; + char *name; + + ret = sysdb_attrs_primary_name(dom->sysdb, attrs, attr_name, &orig_name); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, ("The object has no name attribute\n")); + return EINVAL; + } + + name = sss_get_domain_name(memctx, orig_name, dom); + if (name == NULL) { + DEBUG(SSSDBG_OP_FAILURE, + ("Failed to format original name [%s]\n", orig_name)); + return ENOMEM; + } + DEBUG(SSSDBG_TRACE_FUNC, ("Processing object %s\n", name)); + + *_primary_name = name; + return EOK; +} + +errno_t sdap_get_user_primary_name(TALLOC_CTX *memctx, + struct sdap_options *opts, + struct sysdb_attrs *attrs, + struct sss_domain_info *dom, + const char **_user_name) +{ + return sdap_get_primary_name(memctx, + opts->group_map[SDAP_AT_USER_NAME].name, + attrs, dom, _user_name); +} + +errno_t sdap_get_group_primary_name(TALLOC_CTX *memctx, + struct sdap_options *opts, + struct sysdb_attrs *attrs, + struct sss_domain_info *dom, + const char **_group_name) +{ + return sdap_get_primary_name(memctx, + opts->group_map[SDAP_AT_GROUP_NAME].name, + attrs, dom, _group_name); +} |