views:

381

answers:

2

I used the Single Sign-on demo from: http://www.codeproject.com/KB/aspnet/SingleSignon.aspx

And I add a SignOut function for this demo, but found a problem:

when I set the cookie.Domain, FormsAuthentication.SignOut() is not working and the cookie can not be cleared.

If the cookie has not been set the cookie.Domain, FormsAuthentication.SignOut() works.

I used C# asp.net.

And could anybody tell me some simple and practical Single Sign-On and Single Sign-Off solutions using asp.net ?

+1  A: 

In case you are using the authentication for the same domain and subdomain, try adding the domain name in the web.config instead of adding the domain through code. you will no have to code anything if you use this web.config entry

<authentication mode="Forms">

<forms loginUrl="~/Account/LogOn" timeout="2880" domain="abc.com"/>

</authentication>

This entry tells the asp.net engine that the authentication cookie will be used for all subdomains of abc.com . Try using this and see if it works.

Bootcamp
Yes. It works perfectly. Thank you very much.
Mike108
+1  A: 

This worked for me:

In the Logout event/ method of each site, use Cookies collection in Request object & delete the relevant cookies as below:

enter code hereHttpCookie cookie = Request.Cookies.Get(".CommonCookieName"); 
cookie.Expires = DateTime.Now.AddDays(-1); 
HttpContext.Current.Response.Cookies.Add(cookie);

If all the sites in SSO use same cookie, then this is simple as described above. If few or each site participating in SSO use their own cookie/ user name for same subject (person), then u need to remove all the cookies. (perhaps establish a central location with just the mapping of the usernames & cookie names in each site in SSO collection of sites.

Praveen
Thanks for this alternative - this was what I needed on a site using DotNetOpenAuth for OpenID as well.
Jeff Wilcox