ldap_search Not returning more than 1000 user. I have also set the sizelimit to 0. Let me the know the solution.
ldap_search Not returning more than 1000 user
7.2k Views Asked by Senthilkumar Ramasamy At
2
There are 2 best solutions below
1

This solution works only for php version >5.4.
EDIT: as @derhansen mentioned, ldap_control_paged_result_response
is deprecated since PHP 7.4
It brings a given number of results at once until there is data available.
$ldap = ldap_connect($adServer, $adPort);
$bind = ldap_bind($ldap, $username, $password);
// enable pagination with a page size of 100.
$pageSize = 100;
$cookie = '';
$i=1;
do {
ldap_control_paged_result($ldap, $pageSize, true, $cookie);
$filter = '(objectCategory=group)';
$result = ldap_search($ldap, "dc=SOMETHING,dc=COM", $filter);
$entries = ldap_get_entries($ldap, $result);
array_shift($entries);
foreach ($entries as $e) {
echo '<br>';
echo $i. '. '. $e['dn'] . PHP_EOL;
echo '<br> Name: '. $e['name'][0] . PHP_EOL;
$i++;
}
ldap_control_paged_result_response($ldap, $result, $cookie);
} while($cookie !== null && $cookie != '');
Hope this helps.
You can find more info here: http://php.net/manual/en/function.ldap-control-paged-result.php
Read PHP ldap_search size limit exceeded for more details.
Alternatively, try to use following code
Source: http://www.administrator.de/forum/ldap-search-mit-php-mehr-als-1000-eintr%C3%A4ge-95576.html