diff --git a/simplesamlphp_auth.admin.inc b/simplesamlphp_auth.admin.inc
index 5d933cf..45469c1 100644
--- a/simplesamlphp_auth.admin.inc
+++ b/simplesamlphp_auth.admin.inc
@@ -87,6 +87,11 @@ function simplesamlphp_auth_settings() {
     '#default_value' => variable_get('simplesamlphp_auth_roleevaleverytime', 0),
     '#description' => t('NOTE: This means users could loose any roles that have been assigned manually in Drupal.'),
   );
+  $form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_autoenablesaml'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Automatically enable SAML authentication for existing users upon successful login'),
+    '#default_value' => variable_get('simplesamlphp_auth_autoenablesaml', 0),
+  );
 
   $form['simplesamlphp_auth_grp_reg'] = array(
     '#type' => 'fieldset',
diff --git a/simplesamlphp_auth.inc b/simplesamlphp_auth.inc
index b1f5c36..a43a669 100644
--- a/simplesamlphp_auth.inc
+++ b/simplesamlphp_auth.inc
@@ -33,7 +33,18 @@ function _simplesaml_auth_login_register() {
 
       // If we did not find a Drupal user, register a new one.
       if (!$ext_user) {
-        $ext_user = _simplesaml_auth_user_register($authname);
+        // Check if a local drupal account exists (to auto-enable SAML).
+        $local_user = user_load_by_mail($authname);
+        if (!$local_user) {
+          $local_user = user_load_by_name($authname);
+        }
+        if ($local_user && variable_get('simplesamlphp_auth_autoenablesaml', FALSE)) {
+          user_set_authmaps($local_user, array('authname_simplesamlphp_auth' => $authname));
+          $ext_user = $local_user;
+        }
+        else {
+          $ext_user = _simplesaml_auth_user_register($authname);
+        }
       }
 
       // Log the user in.
diff --git a/simplesamlphp_auth.install b/simplesamlphp_auth.install
index fe91369..9267d76 100644
--- a/simplesamlphp_auth.install
+++ b/simplesamlphp_auth.install
@@ -45,6 +45,7 @@ function simplesamlphp_auth_uninstall() {
   variable_del('simplesamlphp_auth_allowdefaultloginroles');
   variable_del('simplesamlphp_auth_allowdefaultloginusers');
   variable_del('simplesamlphp_auth_logoutgotourl');
+  variable_del('simplesamlphp_auth_autoenablesaml');
 }
 
 /**
