I am authenticating using LDAP.
The function ldap_auth sends them to ldap_connect_ex to make the connection to ldap.
If I have multiple ldap servers then what would be the proper way to test for each.
This is the way it is written with just one ldap_host.
function ldap_connect_ex() {
global $CBT_config;
$connection = ldap_connect($CBT_config['ldap_host'], $CBT_config['ldap_port']);
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3);
return $connection;
}
If I also have ldap_host2 then what is the proper way to code this. I believe the return of $connection is boolean.
Would the following work or is there a better way?
$connection = ldap_connect($CBT_config['ldap_host'], $CBT_config['ldap_port']);
if ($connection == false) {
$connection = ldap_connect($CBT_config['ldap_host2'], $CBT_config['ldap_port']);
}
or..
$connection = ((ldap_connect($CBT_config['ldap_host'])) || (ldap_connect($CBT_config['ldap_host2'])));
If ldap_host is an actual url such as ldap://authldap1.xxxxx.com i have read that I don't need to include the ldap_port.