From 9400bf922412675a333c8943bd38bfb8721da3b6 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 31 May 2017 18:11:37 +0200 Subject: [PATCH] LDAP user backend form: implement populateDomains() refs #2153 --- .../Config/UserBackend/LdapBackendForm.php | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/application/forms/Config/UserBackend/LdapBackendForm.php b/application/forms/Config/UserBackend/LdapBackendForm.php index 46ab71209..fec5f9691 100644 --- a/application/forms/Config/UserBackend/LdapBackendForm.php +++ b/application/forms/Config/UserBackend/LdapBackendForm.php @@ -264,19 +264,32 @@ class LdapBackendForm extends Form public function isValidPartial(array $formData) { if (isset($formData['btn_discover_domains']) && parent::isValid($formData)) { - try { - $domains = $this->discoverDomains(ResourceFactory::create($this->getElement('resource')->getValue())); - } catch (LdapException $e) { - $this->_elements['btn_discover_domains']->addError($e->getMessage()); - return false; - } - - $this->_elements['domains']->setValue(implode(',', $domains)); + return $this->populateDomains(ResourceFactory::create($this->getElement('resource')->getValue())); } return true; } + /** + * Discover the domains the LDAP server is responsible for and fill them in the form + * + * @param LdapConnection $connection + * + * @return bool Whether the discovery succeeded + */ + public function populateDomains(LdapConnection $connection) + { + try { + $domains = $this->discoverDomains($connection); + } catch (LdapException $e) { + $this->_elements['btn_discover_domains']->addError($e->getMessage()); + return false; + } + + $this->_elements['domains']->setValue(implode(',', $domains)); + return true; + } + /** * Discover the domains the LDAP server is responsible for *