LdapBackendForm: Fail gracefully if the discovery is not possible

This commit is contained in:
Johannes Meyer 2015-07-28 15:07:23 +02:00
parent d2467fee16
commit 5411efd546
1 changed files with 12 additions and 3 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Forms\Config\UserBackend;
use Exception;
use Icinga\Data\ResourceFactory;
use Icinga\Web\Form;
@ -123,9 +124,17 @@ class LdapBackendForm extends Form
$connection = ResourceFactory::create(
isset($formData['resource']) ? $formData['resource'] : reset($this->resources)
);
$capabilities = $connection->bind()->getCapabilities();
$baseDn = $capabilities->getDefaultNamingContext();
$hasAdOid = $capabilities->isActiveDirectory();
try {
$capabilities = $connection->bind()->getCapabilities();
$baseDn = $capabilities->getDefaultNamingContext();
$hasAdOid = $capabilities->isActiveDirectory();
} catch (Exception $e) {
$this->warning(sprintf(
$this->translate('Failed to discover the chosen LDAP connection: %s'),
$e->getMessage()
));
}
}
}