diff --git a/simplesamlphp_auth.module b/simplesamlphp_auth.module
index 9cc870d..fad0059 100644
--- a/simplesamlphp_auth.module
+++ b/simplesamlphp_auth.module
@@ -291,7 +291,7 @@ function simplesaml_auth_user_profile_form_submit(&$form, $form_state) {
           'module' => 'simplesamlphp_auth',
         ))
         ->fields(array(
-          'authname' => $values['mail'],
+          'authname' => $values['name'],
         ))
         ->execute();
     }
