summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarkko Lehtoranta <devel@jlranta.com>2017-07-16 13:01:25 +0300
committerJarkko Lehtoranta <devel@jlranta.com>2017-07-23 14:50:01 +0300
commit79fbed40649744c862c9f5c1e435c624bef9521b (patch)
tree8a5ca292c58485e7272694be8262b0d4d6408ef8
parentd87375cbaac1671bda7dea6a53035f35ee99defb (diff)
downloadnextcloud-server-79fbed40649744c862c9f5c1e435c624bef9521b.tar.gz
nextcloud-server-79fbed40649744c862c9f5c1e435c624bef9521b.zip
LDAP: Clean-up doConnect
Signed-off-by: Jarkko Lehtoranta <devel@jlranta.com>
-rw-r--r--apps/user_ldap/lib/Connection.php25
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;
}