What role does the PHP function ldap_set_option() play in configuring LDAP connections?

The PHP function ldap_set_option() is used to set options for the LDAP connection, such as setting the LDAP protocol version or enabling TLS encryption. This function allows you to configure various aspects of the LDAP connection to ensure it meets your specific requirements.

// Set LDAP options for the connection
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);