How can the issue of "Partial search results returned: Sizelimit exceeded" be resolved when querying an LDAP directory using PHP?

When querying an LDAP directory using PHP, the issue of "Partial search results returned: Sizelimit exceeded" occurs when the LDAP server returns more results than the client is configured to handle. This can be resolved by increasing the sizelimit parameter in the LDAP search query to accommodate more results.

<?php

$ldapconn = ldap_connect("ldap.example.com");
ldap_set_option($ldapconn, LDAP_OPT_SIZELIMIT, 1000); // Set the sizelimit to 1000
ldap_bind($ldapconn, "cn=admin,dc=example,dc=com", "password");

$ldapsearch = ldap_search($ldapconn, "dc=example,dc=com", "(&(objectClass=person))");
$ldapentries = ldap_get_entries($ldapconn, $ldapsearch);

ldap_close($ldapconn);

foreach ($ldapentries as $entry) {
    // Process LDAP search results
}

?>