function ldap_api_edit_server_form in Lightweight Directory Access Protocol (LDAP) 6
Server Add/Edit/Modify implimentation of hook_form(). Creating the actual form itself happens here.
See also
http://api.drupal.org/api/file/developer/topics/forms_api.html/6
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/6
2 string references to 'ldap_api_edit_server_form'
- ldap_api_add_server in ./
ldap_server.admin.inc - Page callback created in the implementation of hook_menu.
- ldap_api_edit_server in ./
ldap_server.admin.inc - Page callback created in the implementation of hook_menu.
File
- ./
ldap_server.admin.inc, line 116
Code
function ldap_api_edit_server_form($form_state, $sid = NULL) {
drupal_add_js(drupal_get_path('module', 'ldap_api') . '/ldap_server.admin.js');
$form = array();
$config = new ldap_server($sid);
if (!is_null($sid)) {
$form['sid'] = array(
'#type' => 'hidden',
'#value' => $config->sid,
);
}
$form['server-settings'] = array(
'#type' => 'fieldset',
'#title' => t('Server settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['server-settings']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $config->name,
'#description' => t('Choose a <em><strong>unique</strong></em> name for this server configuration.'),
'#size' => 50,
'#maxlength' => 255,
'#required' => TRUE,
);
$form['server-settings']['address'] = array(
'#type' => 'textfield',
'#title' => t('Server Address'),
'#default_value' => $config->address,
'#size' => 50,
'#maxlength' => 255,
'#description' => t('The domain name or IP address of your LDAP Server.'),
'#required' => TRUE,
);
$form['server-settings']['port'] = array(
'#type' => 'textfield',
'#title' => t('LDAP port'),
'#default_value' => $config->port,
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The TCP/IP port on the above server which accepts LDAP connections. Must be an integer.'),
);
$form['server-settings']['tls'] = array(
'#type' => 'checkbox',
'#title' => t('Use Start-TLS'),
'#default_value' => $config->tls,
'#description' => t('Secure the connection between the Drupal and the LDAP servers using TLS.<br /><em>Note: To use START-TLS, you must set the LDAP Port to 389.</em>'),
);
$form['server-settings']['basedn'] = array(
'#type' => 'textarea',
'#title' => t('Base DNs'),
'#default_value' => $config->basedn,
'#cols' => 50,
'#rows' => 6,
'#description' => t('Base DNs for searches. Enter one per line in case you need several of them.'),
);
$form['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced configuration'),
'#description' => t('<p>The process of authentication starts by establishing an anonymous connection to the LDAP directory and looking up for the user on it. Once this user is found, LDAP authentication is performed on them.</p><p>However, 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, then you have to specify here a 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,
);
if (!$edit['bindpw']) {
$form['advanced']['binddn'] = array(
'#type' => 'textfield',
'#title' => t('DN for non-anonymous search'),
'#default_value' => $config
->__get('binddn'),
'#size' => 50,
'#maxlength' => 255,
);
$form['advanced']['bindpw'] = array(
'#type' => 'password',
'#title' => t('Password for non-anonymous search'),
'#size' => 12,
'#maxlength' => 255,
);
}
else {
$form['advanced']['binddn'] = array(
'#type' => 'item',
'#title' => t('DN for non-anonymous search'),
'#value' => $config
->__get('binddn'),
);
// Give an option to clear the password.
$form['advanced']['bindpw_clear'] = array(
'#type' => 'checkbox',
'#title' => t('Clear current password and change DN'),
'#default_value' => FALSE,
);
}
$form['advanced']['test'] = array(
'#type' => 'submit',
'#value' => t('Test'),
'#submit' => array(
'',
),
'#suffix' => '<div id="test-spinner" style="display: none;">' . theme_image(drupal_get_path('module', 'ldap_api') . '/images/spinner.gif') . '</div><div id="test-message" class="messages" style="display: none;"></div>',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
$form['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#submit' => array(
'_submit_cancel',
),
);
return $form;
}