I need to get more than the 1000 entries returned by my current LDAP search. Currently I am running on a Windows server with IIS and PHP 7.4 but will soon upgrade to 8.0.
What I have tried so far is this:
# Connect to the LDAP server
$ldap = ldap_connect("ldaps://my.ldap.server:636");
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
$ldapBind = ldap_bind($ldap, "UserName", "Password");
# Do a search
$searchResult = ldap_search($ldap, "DC=something1,DC=something2", "LDAP query);
$countEntries += ldap_count_entries($ldap, $searchResult);
$info = ldap_get_entries($ldap, $searchResult);
# Process each found LDAP data row - this will be a maximum of 1000 rows
for($i=0; $i < $info["count"]; $i++) {
# do something ...
}
This will only give me the first 1000 rows but I need to read at least 30000 rows. Using "named queries" like mail=a*
and mail=b*
is not a viable solution as there could be more than 1000 entries in there, so I need some kind of trusted paged approach - one page by another.
I can see that I most likely should use LDAP controls as ldap_control_paged_result
is no longer an option after PHP 7.4 but I really don't get that - how to use this?
Would anyone have a few hints on what to do here? :-)