You are here

function ldapgroups_user_test in LDAP integration 6

Test users against the current ldapgroups settings

Parameters

Array $form_state:

1 string reference to 'ldapgroups_user_test'
ldapgroups_menu in ./ldapgroups.module
Implementation of hook_menu().

File

./ldapgroups.admin.inc, line 349
Module admin page callbacks.

Code

function ldapgroups_user_test(&$form_state) {
  $servers = ldapauth_server_load_all();
  $options_servers = array();
  foreach ($servers as $server) {
    $options_servers[$server->sid] = $server->name;
  }
  $form['user_selection'] = array(
    '#type' => 'fieldset',
    '#title' => t('User Selection'),
    '#description' => t('This page will let you test the ldapgroups settings against different users.  This is useful to make sure they are setup correctly and to help debug settings (e.g. user group name does not match rule name).  Enter either an existing LDAP authenticated Drupal user name or a server / dn combination and press Test to see results'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );
  $form['user_selection']['test_user'] = array(
    '#type' => 'textfield',
    '#title' => t('Drupal User name to test'),
    '#size' => 50,
    '#maxlength' => 255,
    '#default_value' => $form_state['values']['test_user'],
    '#description' => t('Enter an existing LDAP authenticated Drupal user to test group settings with.'),
  );
  $form['user_selection']['or'] = array(
    '#value' => t('OR'),
  );
  $form['user_selection']['server'] = array(
    '#type' => 'radios',
    '#title' => t('Select a server'),
    '#options' => $options_servers,
    '#default_value' => $form_state['values']['server'],
  );
  $form['user_selection']['dn'] = array(
    '#type' => 'textfield',
    '#title' => t('LDAP DN to test'),
    '#size' => 100,
    '#maxlength' => 255,
    '#description' => t('Enter an LDAP user\'s DN to test group settings with.'),
    '#default_value' => $form_state['values']['dn'],
  );
  $form['user_selection']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Test'),
  );
  if (isset($form_state['storage']['results'])) {
    $form['results'] = array(
      '#type' => 'fieldset',
      '#title' => t('Test Results'),
      '#description' => t('The following information was found for this user.'),
      '#collapsible' => FALSE,
      '#collapsed' => FALSE,
    );
    $form['results']['test_user_results'] = array(
      '#title' => t('Test Results'),
      '#value' => $form_state['storage']['results'],
    );
  }
  return $form;
}