From 3767675546204e4b2ace9a3c17f9ff2aed2c18a4 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Tue, 21 Dec 2010 11:39:03 +0100 Subject: Add all values of a multi-valued user attribute --- src/providers/ldap/sdap_async_accounts.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/providers/ldap/sdap_async_accounts.c') diff --git a/src/providers/ldap/sdap_async_accounts.c b/src/providers/ldap/sdap_async_accounts.c index 004c69aff..289b63733 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; + } } } } -- cgit