Hits

May 12, 2010

ADFS 2 SharePoint 2010 Signout


Issue
Logging out of a Claims Aware SharePoint 2010 application does not log out of the ADFS 2 SSO instance. Upon a subsequent login to SharePoint, the user is not prompted for a user id and password and the last login is remembered.



Resolution
To correctly log out, you need to browse to the ADFS sign out url like so:
https://your_sts_server/adfs/ls/?wa=wsignout1.0


In order to correctly implement this, go to the 14 hive\TEMPLATES\CONTROLTEMPLATES folder and edit the Welcome.ascx file as shown below:

Find a control called ID_Logout and rename to ID_Logout2. Apply the following changes and save.


* Update *

In spite of the change above, we still noticed "sticky" logins after the user had signed out (by browsing to the ADFS signout url).

This is because SharePoint 2010 also creates an auth cookie which is saved to local file. The trick is to force SharePoint 2010 to use a session-based cookie, so that it is destroyed when the page is closed. In order to do that, run the following PowerShell script on the SharePoint WFE:


$sts = Get­SPSecurityTokenServiceConfig
$sts.UseSessionCookies = $true
$sts.Update()
iisreset

Now with the SharePoint AND ADFS cookies being session based, the user can log off by simply closing their browser window.

One thing to note is that there is another cookie called the Home Realm Discovery Cookie, which is saved to disk. Its purpose is to “remember” the last mode of login. This will not be destroyed. The effect of this will be that if you have multiple sites using ADFS SSO, the last mode of login will be remembered. So if a user last used Live ID, then when another application is accessed, which uses the same ADFS SSO instance, then Live ID will be shown to the user instead of the login "choice" screen.

For special case users like testers, it is better to use In Private browsing mode to be able to choose the login mode in subsequent screens. The user can also delete their cookies to get rid if this persistance behaviour. There is also supposed to be a special url from ADFS that will delete this cookie, but this is not normally shared by the ADFS team.

12 comments:

  1. It works,This change applies to whole farm.. But, only issue is if we have multiple web apps in a farm with some being claims and others windows authenticaiton.

    ReplyDelete
  2. Phani, a custom user control and a MasterPage edit would be required for a per root level site collection change.

    ReplyDelete
  3. Anonymous4:52 AM

    Hi All,

    I am facing a problem while doing signout from ADFS2.0 through SharePoint Application.
    I have used FederatedSignOut() method,but after clicking on SignOut link it never go back in the SignIn page and shows 'User is Still signing' ..

    Please can any one help me how can i signout from ADFS and return back in SignIn page of ADFS through SharePoint Application.

    Thanks in advance

    ReplyDelete
  4. Hi All,

    I am facing a problem while doing signout from ADFS2.0 through SharePoint Application.

    When I clicking on SignOut link it never go back in the SignIn page and shows 'User is Still signing' ..

    Please can any one help me how can i signout from ADFS and return back in SignIn page of ADFS through SharePoint Application.

    Thanks in advance

    ReplyDelete
  5. Did you try out the method suggested in this post?

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Here is the sign out url we are using, replace the placeholders with your own value

    https://[corp url]/adfs/ls/?wa=wsignin1.0&wreply=[Site to redirectd to]&wtrealm=[Realm]&wctx=[Website Url]%2f_layouts%2fAuthenticate.aspx%3fSource%3d%7b0%7d&whr=[Hint, if applicable, otherwise omit]

    ReplyDelete
  8. Hey there.

    Great article!
    Do you have any good tips for the "Sign in as different user" method ?
    I would like to use the same approach but somehow automaticaly redirect the users to the Sign In Form of ADFS.

    Thanks in advance for your answer.

    Cheers.
    ETienne.

    ReplyDelete
  9. Here is my Sign out URL if this helps. One KEY that made my signout experience better was to add the -UseWReply parameter when creating the SPTrustedIdentityTokenIssuer. This instructs SharePoint to send the users Back to SharePoint after logging out, and because their tokens are all cleared (from all IDP's) SharePoint ends up sending them back to the IDP which for me is our login page. This way you do not end up at the ADFS signout page when you all done. Works great. Also if you have already created your SPTrustedIdentityTokenIssuer, then you can simply modify the UseWReplyParameter setting like this:
    $x = Get-SPTrustedIdentityTokenIssuer
    $x.UseWReplyParameter = $true
    $x.Update()

    ReplyDelete
  10. Here is my Sign out URL if this helps. One KEY that made my signout experience better was to add the -UseWReply parameter when creating the SPTrustedIdentityTokenIssuer. This instructs SharePoint to send the users Back to SharePoint after logging out, and because their tokens are all cleared (from all IDP's) SharePoint ends up sending them back to the IDP which for me is our login page. This way you do not end up at the ADFS signout page when you all done. Works great. Also if you have already created your SPTrustedIdentityTokenIssuer, then you can simply modify the UseWReplyParameter setting like this:
    $x = Get-SPTrustedIdentityTokenIssuer
    $x.UseWReplyParameter = $true
    $x.Update()

    ReplyDelete
  11. Anonymous5:41 PM

    We are using OAM
    How do we generate https://[corp url]/adfs/ls/?wa=wsignin1.0&wreply=[Site to redirectd to]&wtrealm=[Realm]&wctx=[Website Url]%2f_layouts%2fAuthenticate.aspx%3fSource%3d%7b0%7d&whr=[Hint, if applicable, otherwise omit]

    I am not clear abour ADFS.
    I am trying to signout, cleared aal the cookies etc., but still not able to signout completely

    ReplyDelete
  12. @Anonymous, please re-read the article above. If you have followed my steps, it is likely that your SharePoint cookies are not session based and persisting even after the logout.

    ReplyDelete

I always welcome feedback from my readers.