diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php
index 15f584d7e6bea66470d37eaef1e95f64139d1548..8fbf2355aa2b3ca55ddfd390a184109d01dad182 100644
--- a/modules/saml/lib/IdP/SAML2.php
+++ b/modules/saml/lib/IdP/SAML2.php
@@ -718,7 +718,7 @@ class sspmod_saml_IdP_SAML2 {
 						$doc = \SAML2\DOMDocumentFactory::fromString('<root>' . $value . '</root>');
 						$value = $doc->firstChild->childNodes;
 					}
-					assert('$value instanceof DOMNodeList');
+					assert('$value instanceof DOMNodeList || $value instanceof \SAML2\XML\saml\NameID');
 					break;
 				default:
 					throw new SimpleSAML_Error_Exception('Invalid encoding for attribute ' .