You are here

protected function SimpleLdapUserMap::processSettings in Simple LDAP 7

Process the settings from variable_get(), looking up LDAP mappings in the schema to be sure the mappings are correct.

1 call to SimpleLdapUserMap::processSettings()
SimpleLdapUserMap::__construct in simple_ldap_user/SimpleLdapUserMap.class.php

File

simple_ldap_user/SimpleLdapUserMap.class.php, line 41
Class defining the LDAP <-> Drupal user field mappings.

Class

SimpleLdapUserMap
@file Class defining the LDAP <-> Drupal user field mappings.

Code

protected function processSettings() {
  $this->settings = variable_get('simple_ldap_user_attribute_map', array());
  $this->map = array();
  foreach ($this->settings as $key => $value) {

    // Look up the ldap attribute in the schema, to be sure we have the
    // correct name of the attribute, and not an alias. Convert to lowercase
    // before doing this, just in case.
    $schema = $this
      ->getAttributeSchema(strtolower($value['ldap']));

    // If we don't have a name, log a warning and skip this mapping.
    if (!isset($schema['name'])) {
      $message = 'Unable to lookup schema for ldap attribute @attribute.';
      $t_args = array(
        '@attribute' => $value['ldap'],
      );
      watchdog('SimpleLdapUserMap::processSettings()', $message, $t_args, WATCHDOG_WARNING);
      continue;
    }

    // Convert to all lowercase.
    $this->map[$key]['ldap'] = strtolower($schema['name']);

    // Make sure the Drupal attribute is an array.
    $this->map[$key]['drupal'] = (array) $value['drupal'];
  }
}