diff --git a/docs/simplesamlphp-authproc.txt b/docs/simplesamlphp-authproc.txt
index 51fae63c4b88aeb38bb3764495ab70133bdc2d95..b00a3fe03dd5ae299e3c28e47ff5175167c322cf 100644
--- a/docs/simplesamlphp-authproc.txt
+++ b/docs/simplesamlphp-authproc.txt
@@ -128,6 +128,7 @@ The following filters are included in the simpleSAMLphp distribution:
 - [`authorize:Authorize`](./authorize:authorize): Access control based on regular expressions.
 - [`consent:Consent`](./consent:consent): Ask the user for consent before transmitting attributes.
 - [`core:AttributeAdd`](./core:authproc_attributeadd): Add attributes to the response.
+- [`core:AttributeCopy`](./core:authproc_attributecopy): Copy existing attributes to the response.
 - [`core:AttributeAlter`](./core:authproc_attributealter): Do search-and-replace on attributevalues.
 - [`core:AttributeLimit`](./core:authproc_attributelimit): Limit the attributes in the response.
 - [`core:AttributeMap`](./core:authproc_attributemap): Change the name of the attributes.
diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php
index c57070850e5def914bf879733c3b88bbac901136..e3687bd954613ca23420cc360c5f9b4da64bca39 100644
--- a/lib/SimpleSAML/Auth/Default.php
+++ b/lib/SimpleSAML/Auth/Default.php
@@ -98,7 +98,7 @@ class SimpleSAML_Auth_Default {
 		}
 
 		/* Add those that should always be included. */
-		foreach (array('Attributes', 'Expire', 'LogoutState', 'AuthnInstant', 'RememberMe') as $a) {
+		foreach (array('Attributes', 'Expire', 'LogoutState', 'AuthnInstant', 'RememberMe', 'saml:sp:NameID') as $a) {
 			if (isset($state[$a])) {
 				$persistentAuthState[$a] = $state[$a];
 			}
diff --git a/modules/core/docs/authproc_attributecopy.txt b/modules/core/docs/authproc_attributecopy.txt
new file mode 100644
index 0000000000000000000000000000000000000000..37c99eaec11990186613e799bad6af4c8587c777
--- /dev/null
+++ b/modules/core/docs/authproc_attributecopy.txt
@@ -0,0 +1,18 @@
+`core:AttributeCopy`
+===================
+
+Filter that renames attributes.
+
+
+Examples
+--------
+
+Copy a single attribute (user's uid will be copied to the user's username):
+
+    'authproc' => array(
+        50 => array(
+            'class' => 'core:AttributeCopy',
+            'uid' => 'username',
+        ),
+    ),
+
diff --git a/modules/saml/www/sp/saml1-acs.php b/modules/saml/www/sp/saml1-acs.php
index a8d1dc7246250bbfd86b7781c267f172ddf0a27a..45b317dc3b932776898a605667fadc4c424ac0d4 100644
--- a/modules/saml/www/sp/saml1-acs.php
+++ b/modules/saml/www/sp/saml1-acs.php
@@ -81,5 +81,7 @@ $logoutState = array(
 	);
 $state['LogoutState'] = $logoutState;
 
+$state['saml:sp:NameID'] = $response->getNameID();
+
 $source->handleResponse($state, $responseIssuer, $attributes);
 assert('FALSE');