I would like to know if it's possible to separate login and name. For example, if my name is "George Dupont" and my login is "gdupont", the name user into Drupal is "George Dupont" and not "gdupont" (actually, in my account, my name is "gdupont").
In the function ldapauth_login_validate(), there is (line 255):

// Authenticate LDAP user.
  if (!($dn = _ldapauth_auth($name, $pass)))
    return;

  $account = user_load(array('name' => $name));

  if (!isset($account->uid)) {
    // Register this new user.
    if ($ldap_user = _ldapauth_user_lookup($name)) {
      // Generate a random drupal password. LDAP password will be used anyways.
      $pass = user_password(20);

      // If mail attribute is missing, set the name as mail.
      $init = $mail = key_exists(($_ldapauth_ldap->getOption('mail_attr') ? $_ldapauth_ldap->getOption('mail_attr') : LDAPAUTH_DEFAULT_MAIL_ATTR), $ldap_user) ? $ldap_user[$_ldapauth_ldap->getOption('mail_attr')][0] : $name;
      
      $userinfo = array('name' => $name, 'pass' => $pass, 'mail' => $mail, 'init' => $init, 'status' => 1, 'authname_ldapauth' => $name, 'ldap_authentified' => TRUE, 'ldap_dn' => $ldap_user['dn'], 'ldap_config' => $_ldapauth_ldap->getOption('sid'));
      $user = user_save('', $userinfo);
      watchdog('ldapauth', 'New external user %name created from the LDAP server %server.', array('%name' => $name, '%server' => $_ldapauth_ldap->getOption('name')), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
    }
  }

So the name user is the login user.
Perhaps it would be better to offer to new user to choose a name instead of requiring that it is the login. No ?
Or maybe it's possible by other means ? but i don't know it.

Comments

miglius’s picture

What you are looking for is a manual mapping between drupal username and the ldap username. This is not supported.

fab65’s picture

Status: Active » Postponed (maintainer needs more info)

Thank you for your reply.
Do you think this can be done in a future version? if it is planned ?

Thank you again

cgmonroe’s picture

Clearing out old support requests - reopen if problem still exists in newest code....

That said, if I understand this correctly, you can solve this with the realname module and ldapdata. This will let the system use 'gdupont' as the user id (e.g. user->name) but with ldapdata mapping sn and givenName to profile fields, then set up realname to use these when displaying user->Name.

cgmonroe’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)