]> git.nbdom.net Git - nb.git/commitdiff
lib/php/nb.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 12 Dec 2017 06:08:53 +0000 (06:08 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 12 Dec 2017 06:08:53 +0000 (06:08 +0000)
lib/php/nb.php

index d86e865efad5dffec64931484059b4a7889b43da..fdcb3ee91b1746570b73568f0ab44afbb7f569c5 100644 (file)
@@ -1084,20 +1084,29 @@ class NB {
                $bind = ldap_bind($connect, $ldap_user, $ldap_pass) or exit(">>Could not bind to $ldap_host<<");
                $read = ldap_search($connect, $base_dn, $filter) or exit(">>Unable to search ldap server<<");
                $info = ldap_get_entries($connect, $read);
-               #return $info;
                #echo $info["count"]." entries returned<p>/";
 
                $recs = [];
                for ($r=0; $r<$info["count"]; $r++){
                        $rec = $info[$r];
+
                        for ($i=0; $i<$rec["count"]; $i++){
+                               # Fields
                        $key = $info[$r][$i];
                                if (!empty($keys) and !in_array($key,$keys)) continue;
-                       $recs[$r][$key] = $info[$i][$key][0];
+                       $recs[$r][$key] = [];
+
+                               # Values
+                               for ($j=0; $j<$info[$i][$key]['count']; $j++){
+                                       $recs[$r][$key][] = $info[$i][$key][$j];
+                               }
+                               if (count($recs[$r][$key]) == 1) $recs[$r][$key] = $recs[$r][$key][0];
+
                        }
                }
 
                ldap_close($connect);
+               #return $info;
                return $recs;
 
        } # < ldap_search