From 9f5ec3e8542704d15e010fc031e4981ac4cd6b9a Mon Sep 17 00:00:00 2001
From: Didier Raboud <didier.raboud@liip.ch>
Date: Fri, 17 Aug 2012 17:07:23 +0200
Subject: [PATCH] Take all multiple values from LDAP, not only the first one.

---
 auth/ldap/auth.php |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php
index bc90ebc..a87e74b 100644
--- a/auth/ldap/auth.php
+++ b/auth/ldap/auth.php
@@ -243,7 +243,15 @@ class auth_plugin_ldap extends auth_plugin_base {
                     continue; // wrong data mapping!
                 }
                 if (is_array($entry[$value])) {
-                    $newval = textlib::convert($entry[$value][0], $this->config->ldapencoding, 'utf-8');
+                    if ($entry[$value]['count'] == 1) {
+                        $newval = textlib::convert($entry[$value][0], $this->config->ldapencoding, 'utf-8');
+                    } else {
+                        $newval = array();
+                        foreach($entry[$value] as $newval_k => $newval_i) {
+                            if (is_numeric($newval_k))
+                                array_push($newval,textlib::convert($newval_i, $this->config->ldapencoding, 'utf-8'));
+                        }
+                    }
                 } else {
                     $newval = textlib::convert($entry[$value], $this->config->ldapencoding, 'utf-8');
                 }
-- 
1.7.10.4

