Blame SOURCES/0050-LDAP-allow-multiple-user-principals.patch

b2d430
From f1eb45c3e8a198615c6731dfe9d965ab421723e8 Mon Sep 17 00:00:00 2001
b2d430
From: Sumit Bose <sbose@redhat.com>
b2d430
Date: Fri, 22 Jul 2016 12:19:26 +0200
b2d430
Subject: [PATCH 50/62] LDAP: allow multiple user principals
b2d430
b2d430
In general a user can have multiple principals and recent IPA version
b2d430
added support to defined multiple principals. With this patch SSSD does
b2d430
not only store the first but all principals read by LDAP from a server.
b2d430
b2d430
Resolves https://fedorahosted.org/sssd/ticket/2958
b2d430
b2d430
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
b2d430
(cherry picked from commit 0d5d490fb5ec685fd8ef7a75e612e6ec7ef6bde3)
b2d430
---
b2d430
 src/providers/ldap/sdap_async_users.c | 32 ++++++++++++++++++--------------
b2d430
 1 file changed, 18 insertions(+), 14 deletions(-)
b2d430
b2d430
diff --git a/src/providers/ldap/sdap_async_users.c b/src/providers/ldap/sdap_async_users.c
b2d430
index e44c045b3f8ff6aed33a42cf2919bc01aa41a243..28101a2d8a38f97d09d50a9f7e071a030b4f9719 100644
b2d430
--- a/src/providers/ldap/sdap_async_users.c
b2d430
+++ b/src/providers/ldap/sdap_async_users.c
b2d430
@@ -142,6 +142,7 @@ int sdap_save_user(TALLOC_CTX *memctx,
b2d430
     char *sid_str;
b2d430
     char *dom_sid_str = NULL;
b2d430
     struct sss_domain_info *subdomain;
b2d430
+    size_t c;
b2d430
 
b2d430
     DEBUG(SSSDBG_TRACE_FUNC, "Save user\n");
b2d430
 
b2d430
@@ -440,20 +441,23 @@ int sdap_save_user(TALLOC_CTX *memctx,
b2d430
         DEBUG(SSSDBG_TRACE_FUNC,
b2d430
               "User principal is not available for [%s].\n", user_name);
b2d430
     } else {
b2d430
-        upn = talloc_strdup(user_attrs, (const char*) el->values[0].data);
b2d430
-        if (!upn) {
b2d430
-            ret = ENOMEM;
b2d430
-            goto done;
b2d430
-        }
b2d430
-        if (dp_opt_get_bool(opts->basic, SDAP_FORCE_UPPER_CASE_REALM)) {
b2d430
-            make_realm_upper_case(upn);
b2d430
-        }
b2d430
-        DEBUG(SSSDBG_TRACE_FUNC,
b2d430
-              "Adding user principal [%s] to attributes of [%s].\n",
b2d430
-               upn, user_name);
b2d430
-        ret = sysdb_attrs_add_string(user_attrs, SYSDB_UPN, upn);
b2d430
-        if (ret) {
b2d430
-            goto done;
b2d430
+        for (c = 0; c < el->num_values; c++) {
b2d430
+            upn = talloc_strdup(tmpctx, (const char*) el->values[c].data);
b2d430
+            if (!upn) {
b2d430
+                ret = ENOMEM;
b2d430
+                goto done;
b2d430
+            }
b2d430
+
b2d430
+            if (dp_opt_get_bool(opts->basic, SDAP_FORCE_UPPER_CASE_REALM)) {
b2d430
+                make_realm_upper_case(upn);
b2d430
+            }
b2d430
+            DEBUG(SSSDBG_TRACE_FUNC,
b2d430
+                  "Adding user principal [%s] to attributes of [%s].\n",
b2d430
+                   upn, user_name);
b2d430
+            ret = sysdb_attrs_add_string(user_attrs, SYSDB_UPN, upn);
b2d430
+            if (ret) {
b2d430
+                goto done;
b2d430
+            }
b2d430
         }
b2d430
     }
b2d430
 
b2d430
-- 
b2d430
2.4.11
b2d430