Impersonation in ASP.NET I have a coworker who was trying to get impersonation working in ASP.NET and indicated despite setting the Web.config to impersonate:

...and he indicated "IT" didnt' seem to be working....hmm. My first question was how do you know your impersonation isn't working? He indicated when he ran the following code:

Label1.Text = My.User.Name.ToString();

The label was still showing his Windows identity not "Guss" which he wanted....Turns out the identity he wanted to change (the and one being displayed) is the Page identity NOT the Windows Identity. To change this he needed the following code:

Dim id As New System.Security.Principal.GenericIdentity("Guss");
Dim p As New System.Security.Principal.GenericPrincipal(id, New String(){"Administrator"})
HttpContext.Current.User = p;

Jon Wojtowicz has written a great article on this topis at eggheadcage: http://www.eggheadcafe.com/articles/20050703.asp Published Wednesday, November 22, 2006 12:23 PM by Charles_Sterling

*Article refered from MSDN BLogs.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# re: ASP.Net Impersonation Tip

Quite inspiring,

so this is how we can test if it its working or not

Label1.Text = My.User.Name.ToString();

Thanks 8/20/2009 8:41 AM | web development company

Post a comment





 

 

News

Employers
Soppa Group India
iSmart Panache Inc
R Systems Internationals Ltd
Technovate eSolutions Pvt Ltd
The contents of this blog are my personal opinion and do not represent in any way the view of my employer.
These postings are provided "AS IS" with no warranties, and confer no rights.

Google PR™ - Post your Page Rank with MyGooglePageRank.com

Archives

Post Categories

Image Galleries

Articles & Magazines

ASP.Net 2.0 Compilation

ASP.Net, Blogs I refer...

Atlas

Dost

Drivers and Software Download

Garhwal

Travel Domain

WSS and WebParts

Syndication: