function hook_ldap_attributes_needed_alter in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_servers/ldap_servers.api.php \hook_ldap_attributes_needed_alter()
- 8.3 ldap_servers/ldap_servers.api.php \hook_ldap_attributes_needed_alter()
Perform alterations of ldap attributes before query is made.
To avoid excessive attributes in an ldap query, modules should alter attributes needed based on $op parameter.
Parameters
array $attributes: array of attributes to be returned from ldap queries where:
- each key is ldap attribute name (e.g. mail, cn)
- each value is associative array of form:
- 'conversion' => NULL,
- 'values' => array(0 => 'john', 1 => 'johnny'))
array $params: context array with some or all of the following key/values 'sid' => drupal account object, 'ldap_context' => , 'direction' =>.
3 functions implement hook_ldap_attributes_needed_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- 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_user_ldap_attributes_needed_alter in ldap_user/
ldap_user.module - Implements hook_ldap_attributes_needed_alter().
1 invocation of hook_ldap_attributes_needed_alter()
- ldap_servers_attributes_needed in ldap_servers/
ldap_servers.functions.inc - Get array of required attributes for an ldap query.
File
- ldap_servers/
ldap_servers.api.php, line 107 - Hooks provided by ldap_servers module.
Code
function hook_ldap_attributes_needed_alter(&$attributes, $params) {
$attributes['dn'] = ldap_servers_set_attribute_map(@$attributes['dn'], 'ldap_dn');
// Puid attributes are server specific.
if ($params['sid']) {
$ldap_server = is_object($params['sid']) ? $params['sid'] : ldap_servers_get_servers($params['sid'], 'enabled', TRUE);
switch ($op) {
case 'user_insert':
case 'user_update':
if (!isset($attributes[$ldap_server->user_attr])) {
// don't provide attribute if it exists, unless you are adding data_type or value information
// in that case, don't overwrite the whole array (see $ldap_server->mail_attr example below)
$attributes[$ldap_server->user_attr] = ldap_servers_set_attribute_map();
}
if (!isset($attributes[$ldap_server->mail_attr])) {
// Set default values for an attribute, force data_type.
$attributes[$ldap_server->mail_attr] = ldap_servers_set_attribute_map();
}
ldap_servers_token_extract_attributes($attributes, $ldap_server_obj->mail_template);
$attributes[$ldap_server->unique_persistent_attr] = ldap_servers_set_attribute_map(@$attributes[$ldap_server->unique_persistent_attr]);
break;
}
}
}