You are here

function ldapdata_ldap_attributes_needed_alter in LDAP integration 6

Implements hook_ldap_attributes_needed_alter

Parameters

Array $attributes array of attributes to be returned from ldap queries:

String $op The operation being performed such as 'user_update', 'user_insert', ...:

Mixed $server Server sid or server object:

File

./ldapdata.module, line 1184
ldapdata provides data maping against ldap server.

Code

function ldapdata_ldap_attributes_needed_alter(&$attributes, $op, $server = NULL) {
  if ($server) {
    $sid = is_object($server) ? $server->sid : $server;
    switch ($op) {
      case LDAPAUTH_SYNC_CONTEXT_INSERT_DRUPAL_USER:
      case LDAPAUTH_SYNC_CONTEXT_UPDATE_DRUPAL_USER:
        $attributes[] = 'dn';
        foreach (_ldapdata_ldap_info($sid, 'ldapdata_mappings') as $key => $value) {
          if (!in_array($key, array(
            'access',
            'status',
          ))) {
            $attributes[] = $value;
          }
        }
        $ldapdata_attrs = _ldapdata_ldap_info($sid, 'ldapdata_attrs');
        foreach ($ldapdata_attrs as $attr_name => $attr_info) {
          if (!in_array($attr_name, $attributes)) {
            $attributes[] = $attr_name;
          }
        }
        break;
    }
  }
}