diff options
-rw-r--r-- | apps/user_ldap/lib/Connection.php | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index aa8e9cf1eaa..799e63f268e 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -582,20 +582,23 @@ class Connection extends LDAPUtility { if ($host === '') { return false; } + $this->ldapConnectionRes = $this->ldap->connect($host, $port); - 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) { - if(!$this->ldap->startTls($this->ldapConnectionRes)) { - throw new \OC\ServerNotAvailableException('Start TLS failed, when connecting to LDAP host ' . $host . '.'); - } - } - } else { - throw new \OC\ServerNotAvailableException('Could not disable LDAP referrals.'); - } - } else { + + if(!$this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) { throw new \OC\ServerNotAvailableException('Could not set required LDAP Protocol version.'); } + + if(!$this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) { + throw new \OC\ServerNotAvailableException('Could not disable LDAP referrals.'); + } + + if($this->configuration->ldapTLS) { + if(!$this->ldap->startTls($this->ldapConnectionRes)) { + throw new \OC\ServerNotAvailableException('Start TLS failed, when connecting to LDAP host ' . $host . '.'); + } + } + return true; } |