You are here

function hook_user_ldap_servers_username_to_ldapname_alter in Lightweight Directory Access Protocol (LDAP) 7.2

Allows other modules to transform the Drupal login username to an LDAP UserName attribute. Invoked in LdapServer::userUsernameToLdapNameTransform()

Parameters

$ldap_username: The ldap username that will be used for the AuthName attribute

$drupal_username: The Drupal user name

$context: An array of additional contextual information

  • ldap_server: The LDAP server that is invoking the hook
1 function implements hook_user_ldap_servers_username_to_ldapname_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

ldap_user_ldap_servers_username_to_ldapname_alter in ldap_user/ldap_user.module
Implements hook_ldap_servers_username_to_ldapname_alter

File

ldap_servers/ldap_servers.api.php, line 174
Hooks provided by ldap_servers module.

Code

function hook_user_ldap_servers_username_to_ldapname_alter(&$ldap_username, $drupal_username, $context) {

  // Alter the name only if it has not been altered already, ie php eval code.
  if ($ldap_username == $drupal_username) {
    $authname = ldap_user_get_authname($ldap_username);
    if (!empty($authname)) {
      $ldap_username = $authname;
    }
  }
}