summaryrefslogtreecommitdiffstats
path: root/src/providers/ldap
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2016-03-29 22:18:07 +0200
committerJakub Hrozek <jhrozek@redhat.com>2016-07-07 10:26:37 +0200
commit4bea9a8fe8c561b42b617494550d18564c293fd8 (patch)
tree8af46f7c22809e9830ddd06e3c34bc299cd359d5 /src/providers/ldap
parentc4eb21582937362e09aa34e6a18b7f33815d4940 (diff)
downloadsssd-4bea9a8fe8c561b42b617494550d18564c293fd8.tar.gz
sssd-4bea9a8fe8c561b42b617494550d18564c293fd8.tar.xz
sssd-4bea9a8fe8c561b42b617494550d18564c293fd8.zip
LDAP: save users with FQDN
The username we receive from LDAP is short name. Convert it to a qualified name before saving the user. Reviewed-by: Sumit Bose <sbose@redhat.com>
Diffstat (limited to 'src/providers/ldap')
-rw-r--r--src/providers/ldap/sdap.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c
index b0ff02b30..97b8f126d 100644
--- a/src/providers/ldap/sdap.c
+++ b/src/providers/ldap/sdap.c
@@ -1557,7 +1557,6 @@ sdap_get_primary_name(TALLOC_CTX *memctx,
{
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) {
@@ -1567,17 +1566,52 @@ sdap_get_primary_name(TALLOC_CTX *memctx,
DEBUG(SSSDBG_TRACE_FUNC, "Processing object %s\n", orig_name);
- *_primary_name = talloc_steal(memctx, name);
+ *_primary_name = talloc_strdup(memctx, orig_name);
return EOK;
}
+static errno_t
+sdap_get_primary_fqdn(TALLOC_CTX *mem_ctx,
+ const char *attr_name,
+ struct sysdb_attrs *attrs,
+ struct sss_domain_info *dom,
+ const char **_primary_fqdn)
+{
+ errno_t ret;
+ const char *shortname = NULL;
+ const char *primary_fqdn = NULL;
+ TALLOC_CTX *tmp_ctx;
+
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ return ENOMEM;
+ }
+
+ ret = sdap_get_primary_name(tmp_ctx, attr_name, attrs, dom, &shortname);
+ if (ret != EOK) {
+ goto done;
+ }
+
+ primary_fqdn = sss_create_internal_fqname(tmp_ctx, shortname, dom->name);
+ if (primary_fqdn == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = EOK;
+ *_primary_fqdn = talloc_steal(mem_ctx, primary_fqdn);
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
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,
+ return sdap_get_primary_fqdn(memctx,
opts->user_map[SDAP_AT_USER_NAME].name,
attrs, dom, _user_name);
}
@@ -1588,7 +1622,7 @@ errno_t sdap_get_group_primary_name(TALLOC_CTX *memctx,
struct sss_domain_info *dom,
const char **_group_name)
{
- return sdap_get_primary_name(memctx,
+ return sdap_get_primary_fqdn(memctx,
opts->group_map[SDAP_AT_GROUP_NAME].name,
attrs, dom, _group_name);
}