Geeks With Blogs

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

Narendra Tiwari

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: Published Wednesday, November 22, 2006 12:23 PM by Charles_Sterling

*Article refered from MSDN BLogs.

Posted on Wednesday, November 22, 2006 9:26 AM .Net | Back to top

Comments on this post: ASP.Net Impersonation Tip

# re: ASP.Net Impersonation Tip
Requesting Gravatar...
Quite inspiring,

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

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

Left by web development company on Aug 20, 2009 8:41 AM

Your comment:
 (will show your gravatar)

Copyright © Narendra Tiwari | Powered by: