473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

FormsAuthentication.SignOut() and User.Identity

FormsAuthentication.SignOut() removes the authorization ticket from a user (and the user's roles), but does not change the user's
identity.

I need to be able to either revert the user to the "totally unauthenticated" state, or change his identity to a different state
after SignOut().

Unfortunately, calling SetAuthCookie() after SignOut() doesn't change the identity. It's as if once an identiy is assigned, you're
stuck with it for the entire session.

How can I do this?

- Mark
Jan 13 '06 #1
3 2734
The HttpContext.User.Identity property is get / set:

[C#]
public IPrincipal User {get; set;}

This *should* mean that you can set it to either null or some neutral
Identity object.

Hope that helps.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Mark Olbert" wrote:
FormsAuthentication.SignOut() removes the authorization ticket from a user (and the user's roles), but does not change the user's
identity.

I need to be able to either revert the user to the "totally unauthenticated" state, or change his identity to a different state
after SignOut().

Unfortunately, calling SetAuthCookie() after SignOut() doesn't change the identity. It's as if once an identiy is assigned, you're
stuck with it for the entire session.

How can I do this?

- Mark

Jan 13 '06 #2
Peter,

You got it in 1. Sometimes I wonder how programming got done before the internet...

Thanks!

- Mark
Jan 13 '06 #3
Hi Mark

As for the Forms Authentication, the current User Identity is attached
during the begining of each asp.net request (done in the
FormsAuthentication's HttpModule....), in ASP.NET 1.1 we need to manually
do this while asp.net 2.0 encapsulate this....

You can visit the following kb (discussing asp.net 1.1 forms
authentication/role based ...) to get a clear view on this:
http://support.microsoft.com/?id=311495

So the HttpContext.Current.User will remain there in during the ASP.NET
request's serverside lifecycle.... And for your scenario when you
explicitly use FormsAuthentication.SignOut to discard the current
authentication ticket, you can make a Response.Redirect call right after it
so as to let the client make a new request to the page (or any other
protected page....), this time the User won't be set since there is no
associated authenticated ticket....
BTW, the means Peter mentioned is also reasonable if you want the
HttpContext.User get cleared during the same request lifecycle (without
waiting until the sequential request...)

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| NNTP-Posting-Date: Thu, 12 Jan 2006 19:34:44 -0600
| From: Mark Olbert <Ch*********@newsgroups.nospam>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Subject: Re: FormsAuthentication.SignOut() and User.Identity
| Date: Thu, 12 Jan 2006 17:34:44 -0800
| Organization: Olbert & McHugh, LLC
| Reply-To: ma**@arcabama.com
| Message-ID: <ls********************************@4ax.com>
| References: <ed********************************@4ax.com>
<3F**********************************@microsoft.co m>
| X-Newsreader: Forte Agent 3.1/32.783
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Lines: 7
| X-Trace:
sv3-rQwhPjcWMTvsqwJo11Gf9zxzOujebWz+sLYwuvJ1H8BasdNexn DFZOeQ1Gswh+CYpkalXbft
f+BtmCk!SC3v5IQ/eQPITPjShe9OX747xXbbNSAAw62Qprk3lKk0VQpu5wJgOLLC/LdzkuSDb1+e
2A==
| X-Complaints-To: ab***@giganews.com
| X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
| X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
| X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
| X-Postfilter: 1.3.32
| Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfee d00.sul.t-online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!border1.nntp.d ca.giganews.com!nntp.gigan
ews.com!local01.nntp.dca.giganews.com!news.giganew s.com.POSTED!not-for-mail
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:370523
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Peter,
|
| You got it in 1. Sometimes I wonder how programming got done before the
internet...
|
| Thanks!
|
| - Mark
|

Jan 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeff Johnson | last post by:
I'm using forms authentication to protect a subfolder within my site. I've got it working fine except for two issues: (1) When I do a RedirectFromLogin page I have to put a cookie path ("/"...
2
by: George Durzi | last post by:
When you call FormsAuthentication.SignOut(), is the FormsAuthentication cookie supposed to be destroyed automatically? I'm creating my FormsAuthentication cookie by doing: HttpCookie oCookie =...
0
by: Ed West | last post by:
Hello This SignOut code is not working, any ideas? TIA. public class logout : System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { FormsAuthentication.SignOut();...
4
by: Jeff B | last post by:
I am having a very perplexing problem with setting the user's roles. I have tried to figure this out for 2 days now. When the user logs in to the site, I retrieve the roles from the database and...
4
by: Matthias S. | last post by:
Hi there, I've created an application which is using Forms-based authentification. My Login-Button event handler looks somewhat like this: // validate the input, etc... // sUserName holds now...
1
by: Dean R. Henderson | last post by:
I setup FormsAuthentication on a couple websites where it has been working as expected for a long time. I used this code to setup the same type of authentication on a new website I am working on...
9
by: Patrick Olurotimi Ige | last post by:
When i add the following code below to a userControl it doesn't fire. Any ideas? Sub SignOut(ByVal objSender As Object, ByVal objArgs As EventArgs) FormsAuthentication.SignOut()...
3
by: David | last post by:
Hi all, I am having a slight issue with FormsAuthentication. I need to authenticate a user and while the page is still being processed, need to work with that authenticated user. I have set up...
2
by: parez | last post by:
Hi ALl, I had problem with FormsAuthentication.SignOut(). It wasnt working. Looked arround and saw a lot of posts and different solutions to the problem. And some how (i dont nkow what...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.