diff --git a/modules/saml/www/sp/metadata.php b/modules/saml/www/sp/metadata.php
index 6a9a153dc80b985a6dd9da3a0d14c2452b22a638..b20788ec4771339f65a8d371d24383da9f53f8c4 100644
--- a/modules/saml/www/sp/metadata.php
+++ b/modules/saml/www/sp/metadata.php
@@ -118,6 +118,11 @@ if ($certInfo !== NULL && array_key_exists('certData', $certInfo)) {
 	$certData = NULL;
 }
 
+$format = $spconfig->getString('NameIDPolicy', NULL);
+if ($format !== NULL) {
+    $metaArray20['NameIDFormat'] = $format;
+}
+
 $name = $spconfig->getLocalizedString('name', NULL);
 $attributes = $spconfig->getArray('attributes', array());