Connecting Tech Pros Worldwide Help | Site Map

Changing user when using Windows Authentication?

Newbie
 
Join Date: Sep 2009
Posts: 2
#1: Sep 16 '09
I am using Windows Authentication and I am trying to determine how to swap users (like when a supervisor needs to temporarily boost the priviledges of a session by logging into his own account and then punting back)

I am trying to do this by adding a LinkButton that does the following:

Response.StatusCode = 401;
Response.End();

This *works* but it pops up the login screen 3 times before it settles down with the new credentials (I can enter the user/pass the first time and then just hit Ok and other two times because it comes back up already filled out.)

So two problems: the multiple prompting and the fact that when it finishes it leaves me on a blank screen and I need to navigate somewhere useful to do anything. Even hitting Refresh just reposts and puts me back on the blank screen after once again prompting 3 times for my credentials.

Any ideas would be awesome! Thanks!
Newbie
 
Join Date: Sep 2009
Posts: 2
#2: Sep 17 '09

re: Changing user when using Windows Authentication?


I found this code somewhere and it seems to do the trick.

Response.StatusCode = 401;
Response.StatusDescription = "Unauthorized";
Response.SuppressContent = true;
HttpContext.Current.ApplicationInstance.CompleteRe quest();

However, now I need to refresh the screen after doing this to update the user preferences. I have tried doing a Response.Redirect(..) and adding:
Response.AddHeader("Refresh", string.Format("0;URL={0}", Request.Url.ToString()));

No dice though... if I turn the SupressContent back off, then I get the mutliple login pop-ups again. I'm about ready to set a Session variable and have a timer to check it so that I can invoke a refresh from a different postback after this postback has completed. I think that has promise but feels kind of cludgy.
Reply

Tags
asp.net, logoff, security, windows authentication