handle unallowed auth exception on port detection
This commit is contained in:
parent
5a56393657
commit
cdb0689334
|
@ -288,7 +288,7 @@ class LDAP implements ILDAPWrapper {
|
||||||
} else if ($errorCode === -1) {
|
} else if ($errorCode === -1) {
|
||||||
throw new ServerNotAvailableException('Lost connection to LDAP server.');
|
throw new ServerNotAvailableException('Lost connection to LDAP server.');
|
||||||
} else if ($errorCode === 48) {
|
} else if ($errorCode === 48) {
|
||||||
throw new \Exception('LDAP authentication method rejected');
|
throw new \Exception('LDAP authentication method rejected', $errorCode);
|
||||||
} else if ($errorCode === 1) {
|
} else if ($errorCode === 1) {
|
||||||
throw new \Exception('LDAP Operations error', $errorCode);
|
throw new \Exception('LDAP Operations error', $errorCode);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -657,12 +657,26 @@ class Wizard extends LDAPUtility {
|
||||||
\OCP\Util::writeLog('user_ldap', 'Wiz: trying port '. $p . ', TLS '. $t, \OCP\Util::DEBUG);
|
\OCP\Util::writeLog('user_ldap', 'Wiz: trying port '. $p . ', TLS '. $t, \OCP\Util::DEBUG);
|
||||||
//connectAndBind may throw Exception, it needs to be catched by the
|
//connectAndBind may throw Exception, it needs to be catched by the
|
||||||
//callee of this method
|
//callee of this method
|
||||||
if($this->connectAndBind($p, $t) === true) {
|
|
||||||
$config = array('ldapPort' => $p,
|
// unallowed anonymous bind throws 48. But if it throws 48, we
|
||||||
'ldapTLS' => intval($t)
|
// detected port and TLS, i.e. it is successful.
|
||||||
);
|
try {
|
||||||
|
$settingsFound = $this->connectAndBind($p, $t);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
if($e->getCode() === 48) {
|
||||||
|
$settingsFound = true;
|
||||||
|
} else {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($settingsFound === true) {
|
||||||
|
$config = array(
|
||||||
|
'ldapPort' => $p,
|
||||||
|
'ldapTLS' => intval($t)
|
||||||
|
);
|
||||||
$this->configuration->setConfiguration($config);
|
$this->configuration->setConfiguration($config);
|
||||||
\OCP\Util::writeLog('user_ldap', 'Wiz: detected Port '. $p, \OCP\Util::DEBUG);
|
\OCP\Util::writeLog('user_ldap', 'Wiz: detected Port ' . $p, \OCP\Util::DEBUG);
|
||||||
$this->result->addChange('ldap_port', $p);
|
$this->result->addChange('ldap_port', $p);
|
||||||
return $this->result;
|
return $this->result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue