diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-06-10 09:10:55 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-06-10 09:10:55 +0200 |
commit | c391f74c2e80e6237526631020c775dd87d33010 (patch) | |
tree | 20f4cd7a86a6a8db5eee5fcff0ff69da54b8b442 | |
parent | 952e774a0e96073a3931ce5a004091ca4625cfb0 (diff) | |
parent | b2548b01df3f56a6be9b034eea07fac7632e0874 (diff) | |
download | nextcloud-server-c391f74c2e80e6237526631020c775dd87d33010.tar.gz nextcloud-server-c391f74c2e80e6237526631020c775dd87d33010.zip |
Merge pull request #16758 from owncloud/backport-16748-stable8
Backport stable8: port detection needs to take care of now thrown exceptions when LDAP …
-rw-r--r-- | apps/user_ldap/lib/wizard.php | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php index 2e4507a2585..ea1cdbdcc7e 100644 --- a/apps/user_ldap/lib/wizard.php +++ b/apps/user_ldap/lib/wizard.php @@ -23,6 +23,8 @@ namespace OCA\user_ldap\lib; +use OC\ServerNotAvailableException; + class Wizard extends LDAPUtility { static protected $l; protected $access; @@ -1001,18 +1003,27 @@ class Wizard extends LDAPUtility { $this->ldap->setOption($cr, LDAP_OPT_PROTOCOL_VERSION, 3); $this->ldap->setOption($cr, LDAP_OPT_REFERRALS, 0); $this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT); - if($tls) { - $isTlsWorking = @$this->ldap->startTls($cr); - if(!$isTlsWorking) { - return false; + + try { + if($tls) { + $isTlsWorking = @$this->ldap->startTls($cr); + if(!$isTlsWorking) { + return false; + } } - } - \OCP\Util::writeLog('user_ldap', 'Wiz: Attemping to Bind ', \OCP\Util::DEBUG); - //interesting part: do the bind! - $login = $this->ldap->bind($cr, - $this->configuration->ldapAgentName, - $this->configuration->ldapAgentPassword); + \OCP\Util::writeLog('user_ldap', 'Wiz: Attemping to Bind ', \OCP\Util::DEBUG); + //interesting part: do the bind! + $login = $this->ldap->bind($cr, + $this->configuration->ldapAgentName, + $this->configuration->ldapAgentPassword + ); + $errNo = $this->ldap->errno($cr); + $error = ldap_error($cr); + $this->ldap->unbind($cr); + } catch(ServerNotAvailableException $e) { + return false; + } if($login === true) { $this->ldap->unbind($cr); @@ -1023,9 +1034,6 @@ class Wizard extends LDAPUtility { return true; } - $errNo = $this->ldap->errno($cr); - $error = ldap_error($cr); - $this->ldap->unbind($cr); if($errNo === -1 || ($errNo === 2 && $ncc)) { //host, port or TLS wrong return false; |