function hook_ldap_attributes_needed_alter in LDAP integration 6
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
See ldapauth_attributes_needed() function.
Parameters
array $attributes: array of attributes to be returned from ldap queries
enum $op: context query will be run in. Should be one of the LDAPATUH_SYNC_CONTEXT* constants.
mixed $server: server id (sid) or server object.
2 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.
- ldapauth_ldap_attributes_needed_alter in ./
ldapauth.module - Implements hook_ldap_attributes_needed_alter
- ldapdata_ldap_attributes_needed_alter in ./
ldapdata.module - Implements hook_ldap_attributes_needed_alter
1 invocation of hook_ldap_attributes_needed_alter()
- ldapauth_attributes_needed in includes/
ldap.core.inc - get array of required attributes for an ldap query.
File
- ./
ldapauth.api.php, line 47 - LDAPAuth API function documentation
Code
function hook_ldap_attributes_needed_alter(&$attributes, $op, $server) {
// Sample code to add homedirectory attribute to all standard calls..
$attributes[] = 'dn';
// DN is minimum attribute for all ops.
if ($server) {
$ldap_server = is_object($server) ? $server : ldapauth_server_loade($server);
switch ($op) {
case LDAPAUTH_SYNC_CONTEXT_AUTHENTICATE_DRUPAL_USER:
case LDAPAUTH_SYNC_CONTEXT_INSERT_DRUPAL_USER:
case LDAPAUTH_SYNC_CONTEXT_UPDATE_DRUPAL_USER:
$attributes[] = 'homedirectory';
break;
}
}
}