diff options
author | Sumit Bose <sbose@redhat.com> | 2010-12-21 11:39:03 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-12-21 08:20:32 -0500 |
commit | 3767675546204e4b2ace9a3c17f9ff2aed2c18a4 (patch) | |
tree | 14b44da4523e7ec06fe5b305646ec306bced869a | |
parent | 22310aadc8733e87153d6519aff0aed7dea44e79 (diff) | |
download | sssd-3767675546204e4b2ace9a3c17f9ff2aed2c18a4.tar.gz sssd-3767675546204e4b2ace9a3c17f9ff2aed2c18a4.tar.bz2 sssd-3767675546204e4b2ace9a3c17f9ff2aed2c18a4.zip |
Add all values of a multi-valued user attribute
-rw-r--r-- | src/providers/ldap/sdap_async_accounts.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/providers/ldap/sdap_async_accounts.c b/src/providers/ldap/sdap_async_accounts.c index 004c69af..289b6373 100644 --- a/src/providers/ldap/sdap_async_accounts.c +++ b/src/providers/ldap/sdap_async_accounts.c @@ -51,6 +51,7 @@ static int sdap_save_user(TALLOC_CTX *memctx, char *val = NULL; int cache_timeout; char *usn_value = NULL; + size_t c; DEBUG(9, ("Save user\n")); @@ -235,18 +236,20 @@ static int sdap_save_user(TALLOC_CTX *memctx, goto fail; } if (el->num_values > 0) { - DEBUG(9, ("Adding [%s]=[%s] to user attributes.\n", - opts->user_map[i].sys_name, - (const char*) el->values[0].data)); - val = talloc_strdup(user_attrs, (const char*) el->values[0].data); - if (val == NULL) { - ret = ENOMEM; - goto fail; - } - ret = sysdb_attrs_add_string(user_attrs, - opts->user_map[i].sys_name, val); - if (ret) { - goto fail; + for (c = 0; c < el->num_values; c++) { + DEBUG(9, ("Adding [%s]=[%s] to user attributes.\n", + opts->user_map[i].sys_name, + (const char*) el->values[c].data)); + val = talloc_strdup(user_attrs, (const char*) el->values[c].data); + if (val == NULL) { + ret = ENOMEM; + goto fail; + } + ret = sysdb_attrs_add_string(user_attrs, + opts->user_map[i].sys_name, val); + if (ret) { + goto fail; + } } } } |