LDAP: Throw an exception if Start TLS fails

This ensures that only a secure connection to the LDAP server will be used,
if Start TLS has been enabled.

Signed-off-by: Jarkko Lehtoranta <devel@jlranta.com>
This commit is contained in:
Jarkko Lehtoranta 2017-06-13 21:30:41 +03:00
parent ee2c6e8215
commit de9a9bc004
1 changed files with 3 additions and 1 deletions

View File

@ -586,7 +586,9 @@ class Connection extends LDAPUtility {
if($this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) {
if($this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) {
if($this->configuration->ldapTLS) {
$this->ldap->startTls($this->ldapConnectionRes);
if(!$this->ldap->startTls($this->ldapConnectionRes)) {
throw new \OC\ServerNotAvailableException('Start TLS failed, when connecting to LDAP host ' . $host . '.');
}
}
}
} else {