Last post Jan 22, 2007 11:02 AM by IMBack
Jan 19, 2007 05:11 PM|IMBack|LINK
can some one expain me what is Impersonation
from an ASP.NET side and when it can be used. If you have any simple examples, please share.
Jan 19, 2007 06:14 PM|Rivelyn|LINK
I don't have an example coded because I have never had to use it yet in any of my application but it is pretty much what it says. You can programatically Impersonate a registered user.
Say for an example you need none administrative members of your website to briefly have administrative rights to perform a task of some kind on your site, when the code is called for your user that needs administrative rights you can use the Impersonation
class with an Administrative userName and Password for the action.
Jan 22, 2007 02:55 AM|Leijun Jie - MSFT|LINK
Jan 22, 2007 11:00 AM|IMBack|LINK
Hi I tried implementing the code from :
http://support.microsoft.com/kb/306158. But I am allitle bit confused of how it works.
for example: if(impersonateValidUser("username", "domain", "password")) //where do I get this information?
I have attached the code behind that I currenlty have, please let me know what should be changed.
[DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=
Response.Write("<BR>|Insert your code that runs under the security context of a specific user here.");
Response.Write("<BR>|Your impersonation failed");
Response.Write("<BR>|"+ ex.Message+ "|<BR>");
IntPtr token = IntPtr.Zero;
IntPtr tokenDuplicate = IntPtr.Zero;
impersonationContext = tempWindowsIdentity.Impersonate();
==========web config file===============
Jan 22, 2007 11:01 AM|IMBack|LINK
Jan 22, 2007 11:02 AM|IMBack|LINK