diff --git a/modules/adfs/www/idp/prp.php b/modules/adfs/www/idp/prp.php
index 69d1489036baa773131c71506f33fc67940b6953..51159a81407183ba498351bad32a1538be10f024 100644
--- a/modules/adfs/www/idp/prp.php
+++ b/modules/adfs/www/idp/prp.php
@@ -51,6 +51,7 @@ function ADFS_GenerateResponse($issuer, $target, $nameid, $attributes) {
            <saml:NameIdentifier Format="' . $nameidFormat . '">' . $nameid . '</saml:NameIdentifier>
          </saml:Subject>';
 	foreach ($attributes as $name => $values) {
+		if ((!is_array($values)) || (count($values) == 0)) continue;
 		$result .= '<saml:Attribute AttributeNamespace="http://schemas.xmlsoap.org/claims" AttributeName="' . $name .'">';
 		foreach ($values as $value) {
 			$result .= '<saml:AttributeValue>' . $value . '</saml:AttributeValue>';