[SSSD] [PATCH] Add all values of a multi-valued user attribute
Sumit Bose
sbose at redhat.com
Tue Dec 21 10:44:33 UTC 2010
Hi,
Stephen found that currently we only write the first value of a
multi-valued attribute to the cache. This patch should fix it.
bye,
Sumit
-------------- next part --------------
From 9cc9b94b4cf75c6c4c8c5cc5002b3971d5ad7ca4 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose at redhat.com>
Date: Tue, 21 Dec 2010 11:39:03 +0100
Subject: [PATCH] Add all values of a multi-valued user attribute
---
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 004c69a..289b637 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;
+ }
}
}
}
--
1.7.3.2
More information about the sssd-devel
mailing list