Allow to discover LDAP connections in the wizard as well
...
This commit is contained in:
parent
1de1f119d6
commit
83aafe8cda
|
@ -164,12 +164,7 @@ class UserBackend
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($backendConfig->resource instanceof ConfigObject) {
|
$resource = ResourceFactory::create($backendConfig->resource);
|
||||||
$resource = ResourceFactory::createResource($backendConfig->resource);
|
|
||||||
} else {
|
|
||||||
$resource = ResourceFactory::create($backendConfig->resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($backendType) {
|
switch ($backendType) {
|
||||||
case 'db':
|
case 'db':
|
||||||
$backend = new DbUserBackend($resource);
|
$backend = new DbUserBackend($resource);
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Setup\Forms;
|
namespace Icinga\Module\Setup\Forms;
|
||||||
|
|
||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Application\Config;
|
||||||
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Forms\Config\UserBackendConfigForm;
|
use Icinga\Forms\Config\UserBackendConfigForm;
|
||||||
use Icinga\Forms\Config\UserBackend\DbBackendForm;
|
use Icinga\Forms\Config\UserBackend\DbBackendForm;
|
||||||
use Icinga\Forms\Config\UserBackend\LdapBackendForm;
|
use Icinga\Forms\Config\UserBackend\LdapBackendForm;
|
||||||
|
@ -40,22 +41,18 @@ class AuthBackendPage extends Form
|
||||||
*/
|
*/
|
||||||
public function setResourceConfig(array $config)
|
public function setResourceConfig(array $config)
|
||||||
{
|
{
|
||||||
|
$resourceConfig = new Config();
|
||||||
|
$resourceConfig->setSection($config['name'], $config);
|
||||||
|
ResourceFactory::setConfig($resourceConfig);
|
||||||
|
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the resource configuration as Config object
|
* Create and add elements to this form
|
||||||
*
|
*
|
||||||
* @return ConfigObject
|
* @param array $formData
|
||||||
*/
|
|
||||||
public function getResourceConfig()
|
|
||||||
{
|
|
||||||
return new ConfigObject($this->config);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Form::createElements()
|
|
||||||
*/
|
*/
|
||||||
public function createElements(array $formData)
|
public function createElements(array $formData)
|
||||||
{
|
{
|
||||||
|
@ -74,7 +71,9 @@ class AuthBackendPage extends Form
|
||||||
));
|
));
|
||||||
} elseif ($this->config['type'] === 'ldap') {
|
} elseif ($this->config['type'] === 'ldap') {
|
||||||
$backendForm = new LdapBackendForm();
|
$backendForm = new LdapBackendForm();
|
||||||
$backendForm->create($formData)->removeElement('resource');
|
$backendForm->setResources(array($this->config['name']));
|
||||||
|
$backendForm->create($formData);
|
||||||
|
$backendForm->getElement('resource')->setIgnore(true);
|
||||||
$this->addDescription($this->translate(
|
$this->addDescription($this->translate(
|
||||||
'Before you are able to authenticate using the LDAP connection defined earlier you need to'
|
'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.'
|
. ' provide some more information so that Icinga Web 2 is able to locate account details.'
|
||||||
|
@ -139,13 +138,7 @@ class AuthBackendPage extends Form
|
||||||
|
|
||||||
if ($this->config['type'] === 'ldap' && (! isset($data['skip_validation']) || $data['skip_validation'] == 0)) {
|
if ($this->config['type'] === 'ldap' && (! isset($data['skip_validation']) || $data['skip_validation'] == 0)) {
|
||||||
$self = clone $this;
|
$self = clone $this;
|
||||||
$self->addElement(
|
$self->getSubForm('backend_form')->getElement('resource')->setIgnore(false);
|
||||||
'text',
|
|
||||||
'resource',
|
|
||||||
array(
|
|
||||||
'value' => $this->getResourceConfig()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$inspection = UserBackendConfigForm::inspectUserBackend($self);
|
$inspection = UserBackendConfigForm::inspectUserBackend($self);
|
||||||
if ($inspection && $inspection->hasError()) {
|
if ($inspection && $inspection->hasError()) {
|
||||||
$this->error($inspection->getError());
|
$this->error($inspection->getError());
|
||||||
|
|
Loading…
Reference in New Issue