diff --git a/modules/core/lib/Auth/Process/AttributeMap.php b/modules/core/lib/Auth/Process/AttributeMap.php
index 8df240c3b9963d18caafea854b6338ec94c24bcc..4193f95217b9fd4f55474d575699f6d2f62233ea 100644
--- a/modules/core/lib/Auth/Process/AttributeMap.php
+++ b/modules/core/lib/Auth/Process/AttributeMap.php
@@ -82,13 +82,16 @@ class sspmod_core_Auth_Process_AttributeMap extends SimpleSAML_Auth_ProcessingFi
 
 		foreach($attributes as $name => $values) {
 			if(array_key_exists($name, $this->map)) {
-				unset($attributes[$name]);
 				if(!is_array($this->map[$name])) {
+					unset($attributes[$name]);
 					$attributes[$this->map[$name]] = $values;
 				} else {
 					foreach($this->map[$name] as $to_map) {
 						$attributes[$to_map] = $values;
 					}
+					if (!in_array($name, $this->map[$name])) {
+						unset($attributes[$name]);
+					}
 				}
 			}
 		}