diff --git a/application/forms/Config/Resource/LdapResourceForm.php b/application/forms/Config/Resource/LdapResourceForm.php index 604e34199..b385610a8 100644 --- a/application/forms/Config/Resource/LdapResourceForm.php +++ b/application/forms/Config/Resource/LdapResourceForm.php @@ -154,19 +154,17 @@ class LdapResourceForm extends Form */ public static function isValidResource(Form $form) { - try { - $resource = ResourceFactory::createResource(new ConfigObject($form->getValues())); - $resource->bind(); - } catch (Exception $e) { - $msg = $form->translate('Connectivity validation failed, connection to the given resource not possible.'); - if (($error = $e->getMessage())) { - $msg .= ' (' . $error . ')'; - } - - $form->addError($msg); - return false; + $result = ResourceFactory::createResource(new ConfigObject($form->getValues()))->inspect(); + if ($result->hasError()) { + $form->addError(sprintf( + '%s (%s)', + $form->translate('Connectivity validation failed, connection to the given resource not possible.'), + $result->getError() + )); } - return true; + // TODO: display diagnostics in $result->toArray() to the user + + return ! $result->hasError(); } } diff --git a/library/Icinga/Protocol/Ldap/LdapConnection.php b/library/Icinga/Protocol/Ldap/LdapConnection.php index fb20a59ef..2e97b8c9b 100644 --- a/library/Icinga/Protocol/Ldap/LdapConnection.php +++ b/library/Icinga/Protocol/Ldap/LdapConnection.php @@ -945,7 +945,7 @@ class LdapConnection implements Selectable, Inspectable /** * Prepare and establish a connection with the LDAP server * - * @param Inspection $info Optional inspection to fill with diagnosis info + * @param Inspection $info Optional inspection to fill with diagnostic info * * @return resource A LDAP link identifier * @@ -1090,6 +1090,9 @@ class LdapConnection implements Selectable, Inspectable /** * Inspect if this LDAP Connection is working as expected * + * Check if connection, bind and encryption is working as expected and get additional + * information about the used + * * @return Inspection Inspection result */ public function inspect()