title: User is not forced to reauthenticate in ADFS 2.0 after Sharepoint 2010 session expires
body: <p>This case is very much similar to question by Wiktor Zychla, see <a href="https://stackoverflow.com/questions/9130999/how-to-set-the-timeout-properly-when-federating-with-the-adfs-2-0">How to set the timeout properly when federating with the ADFS 2.0</a></p>
  
  <p>We are experiencing the same behavior, ADFS happily redirects the user back to Sharepoint site and FedAuth cookie is recreated, even though ADFS should prompt for credentials - we want the user to reauthenticate after some period of idle time. Basically it looks like the session is always sliding. </p>
  
  <p>We have disabled persistent cookies, so the FedAuth cookie is removed when session is ended by closing the browser, so the user is forced to reauthenticate after all browser windows are closed and a new session is started, so that works.</p>
  
  <p>As far as I understand the Web SSO lifetime setting in ADFS Snap-in controls the time after which the user should need to re-authenticate on AD FS (enter his credentials again). Tokenlifetime and LogonTokenCacheExpirationWindow together control, when Sharepoint should redirect back to AD FS to in order to renew FedAuth cookie.</p>
  
  <p>Following is a quote from <a href="http://msdn.microsoft.com/en-us/library/hh446526.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/hh446526.aspx</a> :</p>
  
  <p><em>To force users to re-enter their credentials whenever they are redirected back to ADFS, you should set the web SSO lifetime in ADFS to be less than or equal to SAMLtokenlifetime minus the value of LogonTokenCacheExpirationWindow.</em></p>
  
  <p>So, we have done following:</p>
  
  <p><strong>1. Setting the lifetime of SAML token</strong></p>
  
  <pre><code>Add-PSSnapin Microsoft.ADFS.PowerShell
  
  Set-AdfsRelyingPartyTrust –TargetName "[ourrelayingpartytrustreference]" –TokenLifeTime 7
  </code></pre>
  
  <p><strong>2. Setting LogonTokenCacheExpirationWindow (and disabling persistent cookies)</strong></p>
  
  <pre><code>Add-PSSnapin Microsoft.SharePoint.Powershell -EA 0
  
  $sts = Get-SPSecurityTokenServiceConfig
  $sts.UseSessionCookies = $true
  $sts.LogonTokenCacheExpirationWindow = (New-Timespan -Minutes 1)
  
  $sts.Update()
  
  iisreset
  </code></pre>
  
  <p><strong>3. Adjusted Web SSO lifetime: 5 minutes in AD FS 2.0 Management console snapin (running Get-ADFSProperties in Powershell correctly returns SsoLifetime: 5)</strong></p>
  
  <p>Thus the expected outcome is:</p>
  
  <ol>
  <li>User starts a fresh new session, requests the web site</li>
  <li>Browser is redirected to AD FS, user enter credentials, and browser is redirected back to Sharepoint site, FedAuth cookie is generated</li>
  <li>User remains idle for 10 minutes (to make sure that session sliding period has passed)</li>
  <li>User requests another page in Sharepoint, browser is redirected to AD FS</li>
  <li>Since Web SSO lifetime was 5 minutes, and it was, as in msdn documentation instructs, less than SAMLtokenlifetime minus the value
  of LogonTokenCacheExpirationWindow (SAMLtokenlifetime -
  LogontokenCacheExpirationWindow = 6 minutes), AD FS prompts the user
  for credentials, user enters credentials, and browser is redirected
  to Sharepoint page requested and FedAuth cookie is recreated.</li>
  </ol>
  
  <p><strong>Current actual behavior (steps 1-4 similar):</strong></p>
  
  <p>(5.) AD FS does not prompt for credentials, browser is redirected to Sharepoint page and FedAuth cookie is recreated.</p>
  
  <p>So - for us it looks like AD FS session never expires, no matter what we do.
  If we create a false configuration of setting LogonTokenCacheExpirationWindow value higher than SAMLtokenlifetime (e.g. LogonTokecacheExpirationWindow = 8 and SAMLtokenlifetime = 7), we get the expected behavior of loop between Sharepoint and AD FS.</p>
  
  <p>We are desperately seeking for a solution to properly expire the session, if user has remained idle for some period of time.</p>
  
  <p>We also tried following configuration change (as per the guidance at <a href="http://social.msdn.microsoft.com/Forums/en-US/Geneva/thread/802b1bb6-cda3-4470-a0d1-ee709d5c4b7c/" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/en-US/Geneva/thread/802b1bb6-cda3-4470-a0d1-ee709d5c4b7c/</a>):</p>
  
  <pre><code>Set-ADFSProperties -SsoLifetime 1
  
  Set-ADFSProperties -ReplayCacheExpirationInterval 1
  
  Set-ADFSProperties -SamlMessageDeliveryWindow 1
  </code></pre>
  
  <p>No Global.asax changes yet made.</p>
  
  <p>As far as I understand, we have configured everything according to the documentation, however we cannot force the user to reauthenticate. Any help pointing out the error in configuration is appreciated.</p>