Restore form elements' defaults

refs #2997
This commit is contained in:
Alexander A. Klimov 2017-10-09 12:05:30 +02:00
parent c259fe6e50
commit 9084ce2174
1 changed files with 15 additions and 3 deletions

View File

@ -116,6 +116,18 @@ class LdapBackendForm extends Form
);
}
if ($isAd) {
// ActiveDirectory defaults
$userClass = 'user';
$filter = '!(objectClass=computer)';
$userNameAttribute = 'sAMAccountName';
} else {
// OpenLDAP defaults
$userClass = 'inetOrgPerson';
$filter = null;
$userNameAttribute = 'uid';
}
$this->addElement(
'text',
'user_class',
@ -126,7 +138,7 @@ class LdapBackendForm extends Form
'disabled' => $isAd ?: null,
'label' => $this->translate('LDAP User Object Class'),
'description' => $this->translate('The object class used for storing users on the LDAP server.'),
'value' => $this->getSuggestion('user_class')
'value' => $this->getSuggestion('user_class', $userClass)
)
);
$this->addElement(
@ -135,7 +147,7 @@ class LdapBackendForm extends Form
array(
'preserveDefault' => true,
'allowEmpty' => true,
'value' => $this->getSuggestion('filter'),
'value' => $this->getSuggestion('filter', $filter),
'label' => $this->translate('LDAP Filter'),
'description' => $this->translate(
'An additional filter to use when looking up users using the specified connection. '
@ -178,7 +190,7 @@ class LdapBackendForm extends Form
'description' => $this->translate(
'The attribute name used for storing the user name on the LDAP server.'
),
'value' => $this->getSuggestion('user_name_attribute')
'value' => $this->getSuggestion('user_name_attribute', $userNameAttribute)
)
);
$this->addElement(