Following LDAP Referrals in PHP

To follow referrals in PHP, you have to explicitly tell PHP that you want the LDAP server to return the referral to you. In PHP, the default is for the PHP LDAP library to tell the LDAP server not to follow referrals. In PHP, not only do you have to set the referral option, but you also have to explicitly set the LDAP v3 protocol. Below is an example of how to have PHP tell the LDAP server that referrals should be returned:

$ds = ldap_connect('');
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ds, LDAP_OPT_REFERRALS, 1);

Please see the following reference for more information: ldap_set_option.