Users can not change their own username, even if they have the 'change own username' right from the user module.

Changing the beginning of the ldapprov_form_alter function to the following will check if the user are the 'change own username' right and if the current user is the same as the one on the form.

function ldapprov_form_alter(&$form, $form_state, $form_id) {
  global $user;
  switch ($form_id) {
    case "user_profile_form":
      if ((LDAPPROV_ENABLED && user_access(LDAPPROV_PERMISSION)) ||
      (user_access('change own username') && ($account = $form['_account']['#value']->uid == $user->uid))) {
      	// Set a custom form validate and submit handlers.
        $form['#validate'][] = 'ldapprov_account_validate';
        $form['#submit'][] = 'ldapprov_account_submit';
      }
      break;

Comments

batje’s picture

Title: Use can not change his own username » User can not change his own username

changed the title to be english

miglius’s picture

Status: Needs review » Fixed

Committed with a minor change, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit df4457a on master, 6.x-2.x, 6.x-1.x by miglius:
    ldap_provisioning: allowed users to change their own usernames, #449352...

  • Commit df4457a on master, 6.x-2.x, 6.x-1.x by miglius:
    ldap_provisioning: allowed users to change their own usernames, #449352...