diff --git a/config/example-config.php b/config/example-config.php index 4b076568..0799d7d1 100644 --- a/config/example-config.php +++ b/config/example-config.php @@ -191,7 +191,13 @@ $c->admin_email ='calendar-admin@example.com'; // 'default_value' => array("date_format_type" => "E","locale" => "fr_FR"), /** foreach key set start and length in the string provided by ldap example for openLDAP timestamp : 20070503162215Z **/ -// 'format_updated'=> array('Y' => array(0,4),'m' => array(4,2),'d'=> array(6,2),'H' => array(8,2),'M'=>array(10,2),'S' => array(12,2)) +// 'format_updated'=> array('Y' => array(0,4),'m' => array(4,2),'d'=> array(6,2),'H' => array(8,2),'M'=>array(10,2),'S' => array(12,2)), + +// 'starttls' => 'yes', // If ldap_start_tls is not working, it is probably + // because php wants to validate the server's + // certificate. Try adding "TLS_REQCERT never" to the + // ldap configuration file that php uses (e.g. /etc/ldap.conf + // or /etc/ldap/ldap.conf). Of course, this lessens security! // // ); // diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php index ba7be4cc..ae23f765 100644 --- a/inc/drivers_ldap.php +++ b/inc/drivers_ldap.php @@ -66,6 +66,20 @@ class ldapDrivers //Set LDAP protocol version if (isset($config['protocolVersion'])) ldap_set_option($this->connect,LDAP_OPT_PROTOCOL_VERSION, $config['protocolVersion']); + // Start TLS if desired + if (isset($config['starttls'])) { + if (!ldap_set_option($this->connect, LDAP_OPT_PROTOCOL_VERSION, 3)) { + $c->messages[] = sprintf(i18n("Failed to set LDAP Protocol version to 3, TLS not supported.")); + $this->valid=false; + return; + } + if (!ldap_start_tls($this->connect)) { + $c->messages[] = sprintf(i18n("Could not start TLS. Ldap_start_tls() failed.")); + $this->valid=false; + return; + } + } + //connect as root if (!ldap_bind($this->connect,$config['bindDN'],$config['passDN'])){ $bindDN = isset($config['bindDN']) ? $config['bindDN'] : 'anonymous';