LDAP user backend form: implement populateDomains()

refs #2153
This commit is contained in:
Alexander A. Klimov 2017-05-31 18:11:37 +02:00
parent 0b8e4d4b5c
commit 9400bf9224
1 changed files with 21 additions and 8 deletions

View File

@ -264,16 +264,29 @@ class LdapBackendForm extends Form
public function isValidPartial(array $formData)
{
if (isset($formData['btn_discover_domains']) && parent::isValid($formData)) {
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(ResourceFactory::create($this->getElement('resource')->getValue()));
$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;
}