function ldap_servers_test_form in Lightweight Directory Access Protocol (LDAP) 7
Same name and namespace in other branches
- 8.2 ldap_servers/ldap_servers.test_form.inc \ldap_servers_test_form()
- 7.2 ldap_servers/ldap_servers.test_form.inc \ldap_servers_test_form()
Implements the LDAP server test page.
Parameters
$form_state: A form state array.
$op: An operatin - add or edit.
$sid: A LDAP server ID.
Return value
The form structure.
1 string reference to 'ldap_servers_test_form'
- ldap_servers_menu in ldap_servers/
ldap_servers.module
File
- ldap_servers/
ldap_servers.test_form.inc, line 24
Code
function ldap_servers_test_form($form, &$form_state, $op = NULL, $sid = NULL) {
$ldap_server = ldap_servers_get_servers($sid, 'all', TRUE);
$form['#prefix'] = t('<h1>Test %name LDAP Server Configuration</h1>', array(
'%name' => $ldap_server->name,
));
$form['#prefix'] .= t('This form simply tests an LDAP configuration to see if
it can bind and if the sample username is mapped correctly. It does not
alter the settings.');
$variables = array(
'ldap_server' => $ldap_server,
'actions' => FALSE,
'type' => 'detail',
);
$form['#prefix'] .= theme('ldap_servers_server', $variables);
$form['sid'] = array(
'#type' => 'hidden',
'#default_value' => $sid,
);
$form['binding']['bindpw'] = array(
'#type' => 'password',
'#title' => t('Password for non-anonymous search'),
'#size' => 20,
'#maxlength' => 255,
);
if ($form['binding']['bindpw']) {
$form['binding']['bindpw']['#description'] = t('<p>Leave empty to test with currently stored password.</p>');
}
$form['testing_drupal_username'] = array(
'#type' => 'textfield',
'#title' => t('Testing Drupal Username'),
'#default_value' => $ldap_server->testingDrupalUsername,
'#size' => 30,
'#maxlength' => 255,
'#description' => t('This is optional and used for testing this server\'s configuration against an actual username. The user need not exist in Drupal and testing will not affect the user\'s LDAP or Drupal Account.'),
);
if ($ldap_server->bind_method == LDAP_SERVERS_BIND_METHOD_ANON_USER) {
$form['testing_drupal_userpw'] = array(
'#type' => 'password',
'#title' => t('Testing Drupal User Password'),
'#size' => 30,
'#maxlength' => 255,
'#description' => t('This is optional and used for testing this server\'s configuration against the username above.'),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'test',
'#weight' => 100,
);
if (isset($_SESSION['ldap_server_test_data']) && count($_SESSION['ldap_server_test_data']) > 0) {
$form['#suffix'] = theme('ldap_server_ldap_entry_table', array(
'entry' => $_SESSION['ldap_server_test_data']['LDAP Entry']['attr'],
'username' => $_SESSION['ldap_server_test_data']['username'],
));
if (function_exists('dpm')) {
$user_name = $_SESSION['ldap_server_test_data']['username'];
dpm("ldap full result array for: " . $user_name);
dpm($_SESSION['ldap_server_test_data']['LDAP Entry']['attr']);
$user = user_load_by_name($user_name);
dpm("drupal user object for: {$user_name}");
dpm($user);
$user_entity = entity_load('user', array(
$user->uid,
));
if (count($user_entity) > 0) {
dpm("drupal user entity for: {$user_name}");
dpm($user_entity);
}
}
unset($_SESSION['ldap_server_test_data']);
}
return $form;
}