You are here

function hook_ldap_drupal_user_name_alter in LDAP integration 6

Called after LDAP user has been authenticated but before the drupal user mapping/creation done.

Allows modules to alter the drupal account name that maps to an ldap account. For example, adding a prefix or suffix based on server.

Parameters

String $name The name to alter:

LDAPInterface $ldap LDAP server interface object bound to server as ldap user.:

String $dn The DN for the authenticated user:

1 invocation of hook_ldap_drupal_user_name_alter()
ldapauth_drupal_user_name in includes/ldap.core.inc
Allow modules to do site dependent login form name to drupal account name mapping.

File

./ldapauth.api.php, line 90
LDAPAuth API function documentation

Code

function hook_ldap_drupal_user_name_alter(&$name, $ldap, $dn) {

  // Some example code to add the server machine name to the drupal name
  // E.g. LDAP user on server AD1 with sAMAccount=jsmith will map to drupal
  // user AD1-jsmith.  While LDAP user on server OL1 with uid=jsmith will
  // map to drupal user OL1-jsmith.
  $server = ldapauth_server_load($ldap
    ->getOption('sid'));
  $name = $server->machine_name . "-" . $name;
}