You are here

function simple_ldap_admin in Simple LDAP 7.2

Same name and namespace in other branches
  1. 7 simple_ldap.admin.inc \simple_ldap_admin()

LDAP server configuration form.

1 string reference to 'simple_ldap_admin'
simple_ldap_menu in ./simple_ldap.module
Implements hook_menu().

File

./simple_ldap.admin.inc, line 10
Functions for Simple LDAP admin interface.

Code

function simple_ldap_admin() {
  $form = array();
  $form['server'] = array(
    '#type' => 'fieldset',
    '#title' => t('LDAP Server Connection Information'),
    '#collapsible' => FALSE,
  );
  $form['server']['simple_ldap_host'] = array(
    '#type' => 'textfield',
    '#title' => t('Host'),
    '#required' => TRUE,
    '#default_value' => variable_get('simple_ldap_host', ''),
    '#description' => t('To use SSL, prepend the host with "ldaps://".'),
  );
  $form['server']['simple_ldap_port'] = array(
    '#type' => 'textfield',
    '#title' => t('Port'),
    '#default_value' => variable_get('simple_ldap_port', '389'),
    '#required' => TRUE,
  );
  $form['server']['simple_ldap_starttls'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use startTLS'),
    '#default_value' => variable_get('simple_ldap_starttls', FALSE),
  );
  $form['server']['simple_ldap_readonly'] = array(
    '#type' => 'checkbox',
    '#title' => t('Read-only'),
    '#default_value' => variable_get('simple_ldap_readonly', FALSE),
  );
  $form['directory'] = array(
    '#type' => 'fieldset',
    '#title' => t('Directory Information'),
    '#collapsible' => FALSE,
  );
  $form['directory']['simple_ldap_binddn'] = array(
    '#type' => 'textfield',
    '#title' => t('Bind DN'),
    '#default_value' => variable_get('simple_ldap_binddn', ''),
    '#description' => t('Leave this blank to bind anonymously'),
  );
  $form['directory']['old_simple_ldap_bindpw'] = array(
    '#type' => 'value',
    '#value' => variable_get('simple_ldap_bindpw', ''),
  );
  $form['directory']['simple_ldap_bindpw'] = array(
    '#type' => 'password',
    '#title' => t('Bind password'),
    '#description' => t('Leave this blank to keep the existing password.'),
  );
  $form['directory']['simple_ldap_basedn'] = array(
    '#type' => 'textfield',
    '#title' => t('Base DN'),
    '#default_value' => variable_get('simple_ldap_basedn', ''),
    '#description' => t('Leave this blank to attempt to detect the base DN.'),
  );
  $form['directory']['simple_ldap_pagesize'] = array(
    '#type' => 'textfield',
    '#title' => t('Search result page size'),
    '#default_value' => variable_get('simple_ldap_pagesize', ''),
    '#description' => t('Leave this blank to disable paged queries.'),
  );

  // Disable the option if paged queries are not supported.
  if (!function_exists('ldap_control_paged_result_response') && !function_exists('ldap_control_paged_result')) {
    $form['directory']['simple_ldap_pagesize']['#disabled'] = TRUE;
    $form['directory']['simple_ldap_pagesize']['#default_value'] = '';
    $form['directory']['simple_ldap_pagesize']['#description'] = t('Paged queries are not supported by this PHP installation.  Support was added in PHP version 5.4.');
  }
  $form['ldap_down'] = array(
    '#type' => 'fieldset',
    '#title' => t('LDAP Server Failure'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['ldap_down']['simple_ldap_ldap_down_maintenance_mode'] = array(
    '#type' => 'checkbox',
    '#title' => t('Maintenance Mode on LDAP Failure'),
    '#description' => t('Check this to force the site into maintenance mode if no LDAP servers can be reached.'),
    '#default_value' => variable_get('simple_ldap_ldap_down_maintenance_mode', TRUE),
  );
  $form['ldap_down']['simple_ldap_ldap_down_message'] = array(
    '#type' => 'textfield',
    '#title' => t('Maintenance Mode Message on LDAP Failure'),
    '#description' => t('The message to show everyone when LDAP goes down.'),
    '#default_value' => variable_get('simple_ldap_ldap_down_message', t('The site is experiencing technical difficulties.')),
  );
  $form['ldap_down']['simple_ldap_ldap_down_notify_list'] = array(
    '#type' => 'textarea',
    '#title' => t('Notification List'),
    '#description' => t('Specify the list of email addresses to be notified when the LDAP server goes down, one per line.'),
    '#default_value' => variable_get('simple_ldap_ldap_down_notify_list', ''),
  );
  $form['ldap_down']['simple_ldap_ldap_down_notify_frequency'] = array(
    '#type' => 'textfield',
    '#title' => t('Notification Frequency'),
    '#description' => t('How often, in minutes, should the notify list be realerted?  Set to 0 for notify once per outage.'),
    '#default_value' => variable_get('simple_ldap_ldap_down_notify_frequency', '30'),
    '#size' => 4,
  );

  // Advanced settings.
  $form['advanced'] = array(
    '#type' => 'fieldset',
    '#title' => t('Advanced'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['advanced']['simple_ldap_opt_referrals'] = array(
    '#type' => 'checkbox',
    '#title' => t('Follow LDAP referrals'),
    '#default_value' => variable_get('simple_ldap_opt_referrals', TRUE),
  );
  $form['advanced']['simple_ldap_debug'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable watchdog debug logging.'),
    '#default_value' => variable_get('simple_ldap_debug', FALSE),
  );
  $form['#submit'][] = 'simple_ldap_admin_submit';
  return system_settings_form($form);
}