diff --git a/config/example-config.php b/config/example-config.php index b33655ae..7df3657f 100644 --- a/config/example-config.php +++ b/config/example-config.php @@ -657,6 +657,9 @@ $c->admin_email = 'calendar-admin@example.com'; // $c->authenticate_hook['call'] = 'LDAP_check'; // $c->authenticate_hook['config'] = array( +// /* Use URI to set one or more LDAP servers to connect to for redundancy. Also supports ldaps. +// * If no URI string is set, host and port can be used */ +// 'uri' => 'ldaps://hostname:port ldap://hostname2:port2' // 'host' => 'www.tennaxia.net', //host name of your LDAP Server // 'port' => '389', //port diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php index bdd6e5ca..94c581d2 100644 --- a/inc/drivers_ldap.php +++ b/inc/drivers_ldap.php @@ -54,13 +54,21 @@ class ldapDriver if (isset($config['networkTimeout'])) ldap_set_option($this->connect, LDAP_OPT_NETWORK_TIMEOUT, $config['networkTimeout']); - if ($port) + // If we are given a URI (or multiple) to connect to, use them. This allows support for LDAPS connections + // as well as redundant ldap servers to connect to + // Otherwise default to host and port + if (isset($config['uri'])) + $this->connect=ldap_connect($config['uri']); + elseif ($port) $this->connect=ldap_connect($host, $port); else $this->connect=ldap_connect($host); if (! $this->connect){ - $c->messages[] = sprintf(translate( 'drivers_ldap : Unable to connect to LDAP with port %s on host %s'), $port, $host ); + if (isset($config['uri'])) + $c->messages[] = sprintf(translate( 'drivers_ldap : Unable to connect to LDAP with URI: %s'), $config['uri'] ); + else + $c->messages[] = sprintf(translate( 'drivers_ldap : Unable to connect to LDAP with port %s on host %s'), $port, $host ); $this->valid=false; return ; }