$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