You are here

function ldap_servers_set_attribute_map in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.2 ldap_servers/ldap_servers.module \ldap_servers_set_attribute_map()

Parameters

array $attribute_map for a given attribute in form array('values' => array(), 'data_type' => NULL) as outlined in ldap_user/README.developers.txt:

enum string $conversion as type of conversion to do @see ldap_servers_convert_attribute(). e.g. base64_encode, bin2hex, msguid, md5:

array $values in form array(<ordinal> => <value> | NULL) where NULL indicates value is needed for provisioning or other operations.:

Return value

array $attribute_map with converted values. If nothing passed in create empty array in proper structure. array('values' => array( 0 => 'john', 1 => 'johnny' ) ); ))

5 calls to ldap_servers_set_attribute_map()
hook_ldap_attributes_needed_alter in ldap_servers/ldap_servers.api.php
Perform alterations of ldap attributes before query is made.
ldap_authorization_ldap_attributes_needed_alter in ldap_authorization/ldap_authorization.module
Implements hook_ldap_attributes_needed_alter().
ldap_servers_ldap_attributes_needed_alter in ldap_servers/ldap_servers.module
Implements hook_ldap_attributes_needed_alter().
ldap_servers_token_extract_attributes in ldap_servers/ldap_servers.tokens.inc
ldap_user_ldap_attributes_needed_alter in ldap_user/ldap_user.module
Implements hook_ldap_attributes_needed_alter().

File

ldap_servers/ldap_servers.module, line 738

Code

function ldap_servers_set_attribute_map($attribute = NULL, $conversion = NULL, $values = NULL) {
  $attribute = is_array($attribute) ? $attribute : array();
  $attribute['conversion'] = $conversion;
  if (!$values && (!isset($attribute['values']) || !is_array($attribute['values']))) {
    $attribute['values'] = array(
      0 => NULL,
    );
  }
  elseif (is_array($values)) {

    //merge into array overwriting ordinals
    foreach ($values as $ordinal => $value) {
      if ($conversion) {
        $value = ldap_servers_convert_attribute($value, $conversion);
      }
      $attribute['values'][(int) $ordinal] = $value;
    }
  }
  return $attribute;
}