public function LdapServerAdmin::drupalForm in Lightweight Directory Access Protocol (LDAP) 7
Same name and namespace in other branches
- 8.2 ldap_servers/LdapServerAdmin.class.php \LdapServerAdmin::drupalForm()
- 7.2 ldap_servers/LdapServerAdmin.class.php \LdapServerAdmin::drupalForm()
File
- ldap_servers/
LdapServerAdmin.class.php, line 176
Class
Code
public function drupalForm($op) {
drupal_add_css(drupal_get_path('module', 'ldap_servers') . '/ldap_servers.admin.css', 'module', 'all');
// $form['#validate'] = array('ldap_servers_admin_form_validate');
$form['#prefix'] = <<<EOF
<p>Setup an LDAP server configuration to be used by other modules such as LDAP Authentication,
LDAP Authorization, etc.</p>
<p>More than one LDAP server configuration can exist for a physical LDAP server.
Multiple configurations for the same physical ldap server are useful in cases such as: (1) different
base dns for authentication and authorization and (2) non anonymous bind users with different privileges
for different purposes.</p>
EOF;
$form['#prefix'] = t($form['#prefix']);
$form['server'] = array(
'#type' => 'fieldset',
'#title' => t('LDAP Server settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['bind_method'] = array(
'#type' => 'fieldset',
'#title' => t('Binding Method.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'boolean' => FALSE,
);
$form['binding_service_acct'] = array(
'#type' => 'fieldset',
'#title' => t('Service Account Binding Credentials'),
'#description' => t('<p>Required when "Service Account Bind" selected above. </p>
<p>Some LDAP configurations (specially common in <strong>Active Directory</strong>
setups) restrict anonymous searches.</p><p>If your LDAP setup does not allow anonymous searches,
or these are restricted in such a way that login names for users cannot be retrieved as a result
of them, you have to specify a service account DN//password pair that will be used for these searches.</p>
<p>For security reasons, this pair should belong to an LDAP account with stripped down permissions.</p>'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['users'] = array(
'#type' => 'fieldset',
'#title' => t('LDAP User to Drupal User Relationship'),
'#description' => t('How are LDAP user entries found based on Drupal username or email? And vice-versa?
Needed for LDAP Authentication and Authorization functionality.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['groups'] = array(
'#type' => 'fieldset',
'#title' => t('LDAP Groups'),
'#description' => t('How are groups defined on your LDAP server? This varies slightly from one LDAP implementation to another
such as Active Directory, Novell, OpenLDAP, etc.'),
'#collapsible' => TRUE,
'#collapsed' => !module_exists('ldap_authorization'),
);
$supports = ldap_servers_php_supports_pagination() ? t('support pagination!') : t('NOT support pagination.');
$form['pagination'] = array(
'#type' => 'fieldset',
'#title' => t('LDAP Pagination'),
'#description' => t('In PHP 5.4, pagination is supported in ldap queries.
A patch to earlier versions of PHP also supports this.') . ' <strong>' . t('This PHP installation appears to ') . $supports . '</strong> ' . '<p>' . t('The advantage to pagination support is that if an ldap server is setup to return only
1000 entries at a time,
you can use page through 1000 records at a time;
without pagination you would never see more than the first 1000 entries.
Pagination is most useful when large queries for batch creating or
synching accounts are used. If you are not using this server for such
tasks, its recommended to leave pagination disabled.') . '</p>',
'#collapsible' => TRUE,
'#collapsed' => !ldap_servers_php_supports_pagination(),
);
$field_to_prop_maps = $this
->field_to_properties_map();
foreach ($this
->fields() as $field_id => $field) {
if (isset($field['form'])) {
if (!isset($field['form']['required']) && isset($field['schema']['not null']) && $field['form']['#type'] != 'checkbox') {
$field['form']['#required'] = (bool) $field['schema']['not null'];
}
if (isset($field['schema']['length']) && !isset($field['form']['#maxlength'])) {
$field['form']['#maxlength'] = $field['schema']['length'];
}
if (isset($field_to_prop_maps[$field_id])) {
$field['form']['#default_value'] = $this->{$field_to_prop_maps[$field_id]};
}
$fieldset = @$field['form']['fieldset'];
if ($fieldset) {
unset($field['form']['fieldset']);
$form[$fieldset][$field_id] = $field['form'];
}
else {
$form[$field_id] = $field['form'];
}
}
}
$form['server']['sid']['#disabled'] = $op == 'edit';
$form['server']['tls']['#required'] = FALSE;
$form['bind_method']['bind_method']['#default_value'] = $this->bind_method ? $this->bind_method : LDAP_SERVERS_BIND_METHOD_DEFAULT;
$form['users']['basedn']['#default_value'] = $this
->arrayToLines($this->basedn);
if ($this->bindpw) {
$pwd_directions = t('You currently have a password stored in the database.
Leave password field empty to leave password unchanged. Enter a new password
to replace the current password. Check the checkbox below to simply
remove it from the database.');
$pwd_class = 'ldap-pwd-present';
}
else {
$pwd_directions = t('No password is currently stored in the database.
If you are using a service account, enter one.');
if ($this->bind_method == LDAP_SERVERS_BIND_METHOD_SERVICE_ACCT) {
$pwd_class = 'ldap-pwd-abscent';
}
else {
$pwd_class = 'ldap-pwd-not-applicable';
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
$action = $op == 'add' ? 'Add' : 'Update';
$form['submit'] = array(
'#type' => 'submit',
'#value' => $action,
'#weight' => 100,
);
return $form;
}