User who is responsible for running current thread can be impersonated programmatically.

Logged in Page user and user who is running current thread could be different. That's where impersonation comes into picture. Impersonation allows logged in user to access network resources/sql server/file server e.t.c. Logged in user would able to access resources due to impersonated user who has privilege to access resources.

Doing impersonation programmatically works with most of the authentication mechanism but there are limitation as windowsIdentity only work with 2000 and 2003.Please see URL at bottom for more information.
Impersonation can be done either through web.config or programmatically.
Following web.config entry inside System.Web ensures that specified user will be responsible for running current thread.
identity impersonate="true" password="Password" userName="userName"

One can do impersonation programmatically.
Scenario/Context in which impersonation is useful.

(a) Impersonation helps in accessing network resouces/sql server e.t.c. Default thread user(ASPNET) might not have previlege you are looking for.
(b) if network resources are allocated to different users.

Attached snippet shows how to impersonate programmatically.



  • Impersonation (38229-785-DotNetSpider.rar)
  • Related Articles

    Login code in c#

    Code for login form ,user enter username,password this is verified from database and according to that user is logged in or invalid user message is given

    Login As different user

    It helps in performing action like "login As". different user can loging into system by clicking some link.

    More articles: Authentication Impersonation Web application security Authentication web.config


    No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: