diff --git a/www/saml2/idp/SSOService.php b/www/saml2/idp/SSOService.php
index d7f44fd849f26846f9879bb284b5979cb0f11e93..aea1ad10c038009af1cae1ca73ed6086503dad31 100644
--- a/www/saml2/idp/SSOService.php
+++ b/www/saml2/idp/SSOService.php
@@ -30,6 +30,7 @@ $session = SimpleSAML_Session::getInstance(TRUE);
 
 try {
 	$idpentityid = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted');
+	$idmetaindex = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted', 'metaindex');
 	$idpmetadata = $metadata->getMetaDataCurrent('saml20-idp-hosted');
 	
 	if (!array_key_exists('auth', $idpmetadata)) {
@@ -277,7 +278,7 @@ if($needAuth) {
 	
 		// Sending the AuthNResponse using HTTP-Post SAML 2.0 binding
 		$httppost = new SimpleSAML_Bindings_SAML20_HTTPPost($config, $metadata);
-		$httppost->sendResponse($authnResponseXML, $idpentityid, $spentityid, 
+		$httppost->sendResponse($authnResponseXML, $idmetaindex, $spentityid, 
 			isset($requestcache['RelayState']) ? $requestcache['RelayState'] : null
 		);