mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-08-31 18:46:02 +00:00
Allow LDAP drviver to use TLS (closes 1873513)
This commit is contained in:
parent
faf109875a
commit
66114ee754
@ -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!
|
||||
//
|
||||
// );
|
||||
//
|
||||
|
||||
@ -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';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user