ldap_search不返回超过1000个用户。我还将sizelimit设置为0.让我知道解决方案。
答案 0 :(得分:3)
此解决方案仅适用于php版本> 5.4
在有可用数据之前,它会立即带来一定数量的结果。
$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 != '');
希望这有帮助。
您可以在此处找到更多信息: http://php.net/manual/en/function.ldap-control-paged-result.php
答案 1 :(得分:0)
阅读PHP ldap_search size limit exceeded了解更多详情。
或者,尝试使用以下代码
// Verbindung mit dem LDAP-Server herstellen
$ldap_connect = ldap_connect($ldap_host) or die( "Could not connect!" );
// Beim LDAP-Server authentifizieren
ldap_set_option($ldap_connect, LDAP_OPT_PROTOCOL_VERSION, 3) or die ("Could not set ldap protocol");
ldap_set_option($ldap_connect, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ldap_connect, LDAP_OPT_SIZELIMIT, 33);
$ldap_bind_anonym = ldap_bind($ldap_connect, "*************", "*************");
$filter = "objectclass=group";
$attrb = array("cn");
$ldap_search = ldap_search($ldap_connect, $base_dn, $filter, $attrb, 0, 0) or die ("Could not search!");
$ldap_result = ldap_get_entries($ldap_connect, $ldap_search);
$counter = 0;
foreach ($ldap_result AS $key => $ldap_value) {
echo $ldap_value["cn"][0]."<br>";
$counter++;
}
echo $counter;
来源:http://www.administrator.de/forum/ldap-search-mit-php-mehr-als-1000-eintr%C3%A4ge-95576.html