LDAP_OPT_REFHOPLIMIT

Use the LDAP_OPT_REFHOPLIMIT setting to specify the maximum number of hops that the client library takes when it chases referrals.

The default is 10. For example:
hoplimit=7;    
ldap_set_option( ld, LDAP_OPT_REFHOPLIMIT, &hoplimit);    
ldap_get_option( ld, LDAP_OPT_REFHOPLIMIT, &hoplimit);