You are here

function ldap_help_get_ldap_servers in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_help/ldap_help.status.inc \ldap_help_get_ldap_servers()
  2. 7.2 ldap_help/ldap_help.status.inc \ldap_help_get_ldap_servers()
1 call to ldap_help_get_ldap_servers()
ldap_help_status in ldap_help/ldap_help.status.inc
@file status file for ldaphelp module

File

ldap_help/ldap_help.status.inc, line 259
status file for ldaphelp module

Code

function ldap_help_get_ldap_servers() {
  if (!module_exists('ldap_servers')) {
    return FALSE;
  }
  ldap_server_module_load_include('inc', 'ldap_servers', 'ldap_servers.settings');
  ldap_server_module_load_include('inc', 'ldap_servers', 'ldap_servers.admin');
  $conf_form = ldap_servers_settings();
  $selected = @$conf_form['encryption']['ldap_servers_encryption']['#default_value'];
  $status[] = array(
    'title' => 'encryption',
    'value' => @$conf_form['encryption']['ldap_servers_encryption']['#options'][$selected],
  );
  $servers_objects = ldap_servers_get_servers(NULL, 'all');
  $servers = array();
  $field_to_properties = LdapServer::field_to_properties_map();
  $props = array_values($field_to_properties);

  // array('sid', 'name', 'status', 'ldap_type', 'port', 'tls', 'user_attr', 'mail_attr', 'user_dn_expression', 'ldap_to_drupal_user');
  foreach ($servers_objects as $sid => $server_object) {
    $server_admin = new LdapServerAdmin($sid);
    $form = $server_admin
      ->drupalForm('update');
    foreach ($props as $property) {
      $value = print_r($server_object->{$property}, TRUE);
      if ($property == 'bind_method') {
        $value = $form['bind_method']['bind_method']['#options'][$value];
      }
      $servers[$sid][] = array(
        'title' => $property,
        'value' => $value,
      );
    }
    $ldaps = strpos(drupal_strtolower($server_object->address), 'ldaps') !== FALSE ? 'y' : 'n';
    $servers[$sid][] = array(
      'title' => 'ldaps in address',
      'value' => $ldaps,
    );
    $binddn = trim($server_object->binddn) ? 'yes' : 'no';
    $servers[$sid][] = array(
      'title' => 'binddn present',
      'value' => $binddn,
    );
    $basedn = count($server_object->basedn);
    $servers[$sid][] = array(
      'title' => 'basedn count',
      'value' => $basedn,
    );
  }
  return array(
    $status,
    $servers,
  );
}