mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
commit
9bc64d931e
@ -22,6 +22,13 @@ class LdapBackendForm extends Form
|
|||||||
*/
|
*/
|
||||||
protected $resources;
|
protected $resources;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default values for the form elements
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $suggestions = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize this form
|
* Initialize this form
|
||||||
*/
|
*/
|
||||||
@ -60,7 +67,8 @@ class LdapBackendForm extends Form
|
|||||||
'label' => $this->translate('Backend Name'),
|
'label' => $this->translate('Backend Name'),
|
||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
'The name of this authentication provider that is used to differentiate it from others.'
|
'The name of this authentication provider that is used to differentiate it from others.'
|
||||||
)
|
),
|
||||||
|
'value' => $this->getSuggestion('name')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
@ -74,11 +82,11 @@ class LdapBackendForm extends Form
|
|||||||
),
|
),
|
||||||
'multiOptions' => !empty($this->resources)
|
'multiOptions' => !empty($this->resources)
|
||||||
? array_combine($this->resources, $this->resources)
|
? array_combine($this->resources, $this->resources)
|
||||||
: array()
|
: array(),
|
||||||
|
'value' => $this->getSuggestion('resource')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$baseDn = null;
|
|
||||||
$hasAdOid = false;
|
$hasAdOid = false;
|
||||||
if (! $isAd && !empty($this->resources)) {
|
if (! $isAd && !empty($this->resources)) {
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
@ -141,7 +149,7 @@ class LdapBackendForm extends Form
|
|||||||
'disabled' => $isAd ?: null,
|
'disabled' => $isAd ?: null,
|
||||||
'label' => $this->translate('LDAP User Object Class'),
|
'label' => $this->translate('LDAP User Object Class'),
|
||||||
'description' => $this->translate('The object class used for storing users on the LDAP server.'),
|
'description' => $this->translate('The object class used for storing users on the LDAP server.'),
|
||||||
'value' => $userClass
|
'value' => $this->getSuggestion('user_class', $userClass)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
@ -150,7 +158,7 @@ class LdapBackendForm extends Form
|
|||||||
array(
|
array(
|
||||||
'preserveDefault' => true,
|
'preserveDefault' => true,
|
||||||
'allowEmpty' => true,
|
'allowEmpty' => true,
|
||||||
'value' => $filter,
|
'value' => $this->getSuggestion('filter', $filter),
|
||||||
'label' => $this->translate('LDAP Filter'),
|
'label' => $this->translate('LDAP Filter'),
|
||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
'An additional filter to use when looking up users using the specified connection. '
|
'An additional filter to use when looking up users using the specified connection. '
|
||||||
@ -193,7 +201,7 @@ class LdapBackendForm extends Form
|
|||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
'The attribute name used for storing the user name on the LDAP server.'
|
'The attribute name used for storing the user name on the LDAP server.'
|
||||||
),
|
),
|
||||||
'value' => $userNameAttribute
|
'value' => $this->getSuggestion('user_name_attribute', $userNameAttribute)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
@ -201,7 +209,7 @@ class LdapBackendForm extends Form
|
|||||||
'backend',
|
'backend',
|
||||||
array(
|
array(
|
||||||
'disabled' => true,
|
'disabled' => true,
|
||||||
'value' => $isAd ? 'msldap' : 'ldap'
|
'value' => $this->getSuggestion('backend', $isAd ? 'msldap' : 'ldap')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
@ -215,7 +223,7 @@ class LdapBackendForm extends Form
|
|||||||
'The path where users can be found on the LDAP server. Leave ' .
|
'The path where users can be found on the LDAP server. Leave ' .
|
||||||
'empty to select all users available using the specified connection.'
|
'empty to select all users available using the specified connection.'
|
||||||
),
|
),
|
||||||
'value' => $baseDn
|
'value' => isset($baseDn) ? $baseDn : $this->getSuggestion('base_dn')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -233,7 +241,8 @@ class LdapBackendForm extends Form
|
|||||||
. ' If your LDAP backend holds usernames with a domain part or if it is not necessary in your setup'
|
. ' If your LDAP backend holds usernames with a domain part or if it is not necessary in your setup'
|
||||||
. ' to authenticate users based on their domains, leave this field empty.'
|
. ' to authenticate users based on their domains, leave this field empty.'
|
||||||
),
|
),
|
||||||
'preserveDefault' => true
|
'preserveDefault' => true,
|
||||||
|
'value' => $this->getSuggestion('domain')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -318,4 +327,41 @@ class LdapBackendForm extends Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default values for the form elements
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getSuggestions()
|
||||||
|
{
|
||||||
|
return $this->suggestions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default value for the given form element or the given default
|
||||||
|
*
|
||||||
|
* @param string $element
|
||||||
|
* @param string $default
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSuggestion($element, $default = null)
|
||||||
|
{
|
||||||
|
return isset($this->suggestions[$element]) ? $this->suggestions[$element] : $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the default values for the form elements
|
||||||
|
*
|
||||||
|
* @param string[] $suggestions
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setSuggestions(array $suggestions)
|
||||||
|
{
|
||||||
|
$this->suggestions = $suggestions;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,13 @@ class AuthBackendPage extends Form
|
|||||||
*/
|
*/
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default values for the subform's elements suggested by a previous step
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $suggestions = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize this page
|
* Initialize this page
|
||||||
*/
|
*/
|
||||||
@ -78,6 +85,7 @@ class AuthBackendPage extends Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
$backendForm = new LdapBackendForm();
|
$backendForm = new LdapBackendForm();
|
||||||
|
$backendForm->setSuggestions($this->suggestions);
|
||||||
$backendForm->setResources(array($this->config['name']));
|
$backendForm->setResources(array($this->config['name']));
|
||||||
$backendForm->create($formData);
|
$backendForm->create($formData);
|
||||||
$backendForm->getElement('resource')->setIgnore(true);
|
$backendForm->getElement('resource')->setIgnore(true);
|
||||||
@ -231,4 +239,28 @@ class AuthBackendPage extends Form
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get default values for the subform's elements suggested by a previous step
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getSuggestions()
|
||||||
|
{
|
||||||
|
return $this->suggestions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set default values for the subform's elements suggested by a previous step
|
||||||
|
*
|
||||||
|
* @param string[] $suggestions
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setSuggestions(array $suggestions)
|
||||||
|
{
|
||||||
|
$this->suggestions = $suggestions;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,17 +132,17 @@ class WebWizard extends Wizard implements SetupWizard
|
|||||||
if ($page->getName() === 'setup_requirements') {
|
if ($page->getName() === 'setup_requirements') {
|
||||||
$page->setWizard($this);
|
$page->setWizard($this);
|
||||||
} elseif ($page->getName() === 'setup_authentication_backend') {
|
} elseif ($page->getName() === 'setup_authentication_backend') {
|
||||||
|
/** @var AuthBackendPage $page */
|
||||||
|
|
||||||
$authData = $this->getPageData('setup_authentication_type');
|
$authData = $this->getPageData('setup_authentication_type');
|
||||||
if ($authData['type'] === 'db') {
|
if ($authData['type'] === 'db') {
|
||||||
$page->setResourceConfig($this->getPageData('setup_auth_db_resource'));
|
$page->setResourceConfig($this->getPageData('setup_auth_db_resource'));
|
||||||
} elseif ($authData['type'] === 'ldap') {
|
} elseif ($authData['type'] === 'ldap') {
|
||||||
$page->setResourceConfig($this->getPageData('setup_ldap_resource'));
|
$page->setResourceConfig($this->getPageData('setup_ldap_resource'));
|
||||||
|
|
||||||
if (! $this->hasPageData('setup_authentication_backend')) {
|
$suggestions = $this->getPageData('setup_ldap_discovery');
|
||||||
$suggestions = $this->getPageData('setup_ldap_discovery');
|
if (isset($suggestions['backend'])) {
|
||||||
if (isset($suggestions['backend'])) {
|
$page->setSuggestions($suggestions['backend']);
|
||||||
$page->populate($suggestions['backend']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getDirection() === static::FORWARD) {
|
if ($this->getDirection() === static::FORWARD) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user