diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-06-10 09:14:17 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-06-10 09:14:17 +0200 |
commit | 429fb8738641bd090bcc49923c5391e8bc3dcb45 (patch) | |
tree | 2db51dece5fee767ab3e0ef941ee24ad225f5e7f /apps | |
parent | e5ff9f0b6b3171c4ed9baef4a62a7c7c1ad9301a (diff) | |
parent | ef16f4ba57e8a59300d5437ffe1921703038f64b (diff) | |
download | nextcloud-server-429fb8738641bd090bcc49923c5391e8bc3dcb45.tar.gz nextcloud-server-429fb8738641bd090bcc49923c5391e8bc3dcb45.zip |
Merge pull request #16759 from owncloud/backport-16748-stable7
Backport stable7: port detection needs to take care of now thrown exceptions when LDAP …
Diffstat (limited to 'apps')
-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 a2b86843ea5..dce86afed28 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; @@ -965,18 +967,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); @@ -987,9 +998,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; |