diff --git a/src/Service/SimplesamlphpDrupalAuth.php b/src/Service/SimplesamlphpDrupalAuth.php
index 2fefed3..ab65565 100644
--- a/src/Service/SimplesamlphpDrupalAuth.php
+++ b/src/Service/SimplesamlphpDrupalAuth.php
@@ -140,6 +140,7 @@ class SimplesamlphpDrupalAuth {
 
     // It's possible that a user with their username set to this authname
     // already exists in the Drupal database.
+    $linked_by_name = FALSE;
     $existing_user = $this->entityManager->getStorage('user')->loadByProperties(array('name' => $authname));
     $existing_user = $existing_user ? reset($existing_user) : FALSE;
     if ($existing_user) {
@@ -153,6 +154,7 @@ class SimplesamlphpDrupalAuth {
         }
         $this->externalauth->linkExistingAccount($authname, 'simplesamlphp_auth', $existing_user);
         $account = $existing_user;
+        $linked_by_name = TRUE;
       }
       else {
         if ($this->config->get('debug')) {
@@ -184,6 +186,7 @@ class SimplesamlphpDrupalAuth {
                 '%id' => $account->id(),
               ));
             }
+            $linked_by_name = $return_value->getAccountName() == $account->getAccountName();
             $this->externalauth->linkExistingAccount($authname, 'simplesamlphp_auth', $account);
           }
         }
@@ -202,9 +205,11 @@ class SimplesamlphpDrupalAuth {
     }
 
     if ($account) {
-      $this->synchronizeUserAttributes($account, TRUE);
-      return $this->externalauth->userLoginFinalize($account, $authname, 'simplesamlphp_auth');
+      $this->synchronizeUserAttributes($account, TRUE, !$linked_by_name);
+      $this->currentUser = $this->externalauth->userLoginFinalize($account, $authname, 'simplesamlphp_auth');
+      return $this->currentUser;
     }
+    return FALSE;
   }
 
   /**
@@ -215,10 +220,14 @@ class SimplesamlphpDrupalAuth {
    * @param bool $force
    *   Define whether to force syncing of the user attributes, regardless of
    *   SimpleSAMLphp settings.
+   * @param bool $sync_user_name
+   *   Runtime determination whether user name syncing should be enabled.
+   *   This may be overridden if another method matched the user by name, for instance.
    */
-  public function synchronizeUserAttributes(AccountInterface $account, $force = FALSE) {
+  public function synchronizeUserAttributes(AccountInterface $account, $force = FALSE, $sync_user_name = NULL) {
     $sync_mail = $force || $this->config->get('sync.mail');
-    $sync_user_name = $force || $this->config->get('sync.user_name');
+    // Change to ?? operator when PHP 7 is standard for Drupal.
+    $sync_user_name = !isset($sync_user_name) ? $sync_user_name : ($force || $this->config->get('sync.user_name'));
 
     if ($sync_user_name) {
       $name = $this->simplesamlAuth->getDefaultName();
