From d95874b84c4107289d91c35e6d06ddc430c924e8 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 25 Jun 2015 14:22:50 +0200 Subject: [PATCH] Setup: Provide a default user filter for ActiveDirectory backends fixes #8703 --- .../Config/UserBackend/LdapBackendForm.php | 12 +++++++----- .../setup/application/forms/AuthBackendPage.php | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/application/forms/Config/UserBackend/LdapBackendForm.php b/application/forms/Config/UserBackend/LdapBackendForm.php index df6e0a4c4..2402c9a6a 100644 --- a/application/forms/Config/UserBackend/LdapBackendForm.php +++ b/application/forms/Config/UserBackend/LdapBackendForm.php @@ -92,17 +92,19 @@ class LdapBackendForm extends Form 'text', 'filter', array( - 'allowEmpty' => true, - 'label' => $this->translate('LDAP Filter'), - 'description' => $this->translate( + 'preserveDefault' => true, + 'allowEmpty' => true, + 'value' => $isAd ? '!(objectClass=computer)' : null, + 'label' => $this->translate('LDAP Filter'), + 'description' => $this->translate( 'An additional filter to use when looking up users using the specified connection. ' . 'Leave empty to not to use any additional filter rules.' ), - 'requirement' => $this->translate( + 'requirement' => $this->translate( 'The filter needs to be expressed as standard LDAP expression.' . ' (e.g. &(foo=bar)(bar=foo) or foo=bar)' ), - 'validators' => array( + 'validators' => array( array( 'Callback', false, diff --git a/modules/setup/application/forms/AuthBackendPage.php b/modules/setup/application/forms/AuthBackendPage.php index bb68792a6..7590d2f73 100644 --- a/modules/setup/application/forms/AuthBackendPage.php +++ b/modules/setup/application/forms/AuthBackendPage.php @@ -78,6 +78,23 @@ class AuthBackendPage extends Form 'Before you are able to authenticate using the LDAP connection defined earlier you need to' . ' provide some more information so that Icinga Web 2 is able to locate account details.' )); + $this->addElement( + 'select', + 'type', + array( + 'ignore' => true, + 'required' => true, + 'autosubmit' => true, + 'label' => $this->translate('Backend Type'), + 'description' => $this->translate( + 'The type of the resource being used for this authenticaton provider' + ), + 'multiOptions' => array( + 'ldap' => 'LDAP', + 'msldap' => 'ActiveDirectory' + ) + ) + ); } else { // $this->config['type'] === 'external' $backendForm = new ExternalBackendForm(); $backendForm->createElements($formData);