diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php
index 15adaa0e3d7af93122131ce4d2e6a27c17d0c7e0..6d402781d1099f624b63de05541479d5d73c2a94 100644
--- a/www/saml2/idp/metadata.php
+++ b/www/saml2/idp/metadata.php
@@ -51,6 +51,13 @@ try {
 		unset($metaArray['SingleLogoutServiceResponse']);
 	}
 
+	if (array_key_exists('NameIDFormat', $idpmeta)) {
+		$metaArray['NameIDFormat'] = $idpmeta['NameIDFormat'];
+	} else {
+		$metaArray['NameIDFormat'] = 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient';
+	}
+
+
 	$metaflat = var_export($idpentityid, TRUE) . ' => ' . var_export($metaArray, TRUE) . ',';
 
 	$metaArray['certData'] = $certInfo['certData'];
diff --git a/www/saml2/sp/metadata.php b/www/saml2/sp/metadata.php
index be5b53200719e4d7cab912df4c3def56693c29dc..e62de3c8e6569d614eaa00e3bd2b875aa208ae70 100644
--- a/www/saml2/sp/metadata.php
+++ b/www/saml2/sp/metadata.php
@@ -31,6 +31,13 @@ try {
 		'SingleLogoutService' => $metadata->getGenerated('SingleLogoutService', 'saml20-sp-hosted'),
 	);
 
+	if (array_key_exists('NameIDFormat', $spmeta)) {
+		$metaArray['NameIDFormat'] = $spmeta['NameIDFormat'];
+	} else {
+		$metaArray['NameIDFormat'] = 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient';
+	}
+
+
 	$certInfo = SimpleSAML_Utilities::loadPublicKey($spmeta);
 	if ($certInfo !== NULL && array_key_exists('certData', $certInfo)) {
 		$metaArray['certData'] = $certInfo['certData'];
diff --git a/www/shib13/idp/metadata.php b/www/shib13/idp/metadata.php
index 9599867e1197e0407703ce2cfda3477e3bd225ec..624ab6113492c186a9d242e3ea2a4b5fc4053410 100644
--- a/www/shib13/idp/metadata.php
+++ b/www/shib13/idp/metadata.php
@@ -39,6 +39,13 @@ try {
 		'certFingerprint' => $certFingerprint,
 	);
 
+	if (array_key_exists('NameIDFormat', $idpmeta)) {
+		$metaArray['NameIDFormat'] = $idpmeta['NameIDFormat'];
+	} else {
+		$metaArray['NameIDFormat'] = 'urn:mace:shibboleth:1.0:nameIdentifier';
+	}
+
+
 	$metaflat = var_export($idpentityid, TRUE) . ' => ' . var_export($metaArray, TRUE) . ',';
 	
 	$metaArray['certData'] = $certInfo['certData'];
diff --git a/www/shib13/sp/metadata.php b/www/shib13/sp/metadata.php
index 57b81d94967664a9a8efd83c042ec61c7eda93bd..4e10cffc91fa8bd08786ce53f9514b78f8fe6d30 100644
--- a/www/shib13/sp/metadata.php
+++ b/www/shib13/sp/metadata.php
@@ -36,6 +36,13 @@ try {
 		$metaArray['certData'] = $certInfo['certData'];
 	}
 
+	if (array_key_exists('NameIDFormat', $spmeta)) {
+		$metaArray['NameIDFormat'] = $spmeta['NameIDFormat'];
+	} else {
+		$metaArray['NameIDFormat'] = 'urn:mace:shibboleth:1.0:nameIdentifier';
+	}
+
+
 	$metaflat = var_export($spentityid, TRUE) . ' => ' . var_export($metaArray, TRUE) . ',';
 
 	if (array_key_exists('certificate', $spmeta)) {