diff --git a/lib/SimpleSAML/XML/AttributeFilter.php b/lib/SimpleSAML/XML/AttributeFilter.php
index 1bc0079e390fda8a3b54e5010f1c6761a0adee7f..6430782edc50f2a9d4c7f5e415902e90f5ffbb9f 100644
--- a/lib/SimpleSAML/XML/AttributeFilter.php
+++ b/lib/SimpleSAML/XML/AttributeFilter.php
@@ -36,22 +36,22 @@ class SimpleSAML_XML_AttributeFilter {
 		if (isset($idpmetadata['attributealter'])) {
 			if (!is_array($idpmetadata['attributealter'])) {
 				SimpleSAML_Logger::debug('Applying IdP specific attribute alter: ' . $idpmetadata['attributealter']);
-				$this->alter($idpmetadata['attributealter']);
+				$this->alter($idpmetadata['attributealter'],$spmetadata['entityid'],$idpmetadata['entityid']);
 			} else {
 				foreach($idpmetadata['attributealter'] AS $alterfunc) {
 					SimpleSAML_Logger::debug('Applying IdP specific attribute alter: ' . $alterfunc);
-					$this->alter($alterfunc);
+					$this->alter($alterfunc,$spmetadata['entityid'],$idpmetadata['entityid']);
 				}
 			}
 		}
 		if (isset($spmetadata['attributealter'])) {
 			if (!is_array($spmetadata['attributealter'])) {
 				SimpleSAML_Logger::debug('Applying SP specific attribute alter: ' . $spmetadata['attributealter']);
-				$this->alter($spmetadata['attributealter']);
+				$this->alter($spmetadata['attributealter'],$spmetadata['entityid'],$idpmetadata['entityid']);
 			} else {
 				foreach($spmetadata['attributealter'] AS $alterfunc) {
 					SimpleSAML_Logger::debug('Applying SP specific attribute alter: ' . $alterfunc);
-					$this->alter($alterfunc);
+					$this->alter($alterfunc,$spmetadata['entityid'],$idpmetadata['entityid']);
 				}
 			}
 		}