Click here to Skip to main content
15,032,256 members
Articles / Web Development / ASP.NET
Posted 2 Jan 2013

Tagged as


12 bookmarked

Implement Impersonation in ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.29/5 (8 votes)
2 Jan 2013CPOL1 min read
Implementing impersonation in ASP.NET.


One of our websites uses Impersonation and a specific user account with special permissions to access certain system resources. The first step in enabling impersonation is setting up the correct attributes in the web.config file:

<identity impersonate="true" password="xxxxxx" userName="xxxxxxx" />

By using the attribute impersonate="true", you are telling IIS that this website will be impersonating the configured user account.

Configure the website to use a specific user account

The next step is you need to go to IIS Manager and configure the user account you want to impersonate by this website.


  1. Open IIS Manager.
  2. Image 1

  3. Expand computer name.
  4. Expand websites.
  5. Click on the specific website for which you want to use impersonation.
  6. On the right panel, under the heading "IIS", double click "Authentication".
  7. Image 2

  8. Right click on "ASP.NET Impersonation" and select "Edit".
  9. Choose "Specific User".
  10. Click the SET button to provide the specific user name and password.

Press OK at the popup dialog to complete this step on enabling impersonation for website in IIS 7.0.

How to choose process identity for Application Pool in IIS 7.0

To set the correct user identity for the application pool, follow the steps below:

  1. Open IIS Manager.
  2. Click on "Application Pools" under the computer name.
  3. On the right panel, right click on the application pool name (your website’s relevant application pool).
  4. Select "Advanced properties".
  5. Image 3

  6. Select "Identity" under "Process Model".
  7. Click on the button to set the user account.
  8. Select "Custom account".
  9. Click on the button to specify the user account and password.
  10. Press "OK".

Recycle the app pool by right clicking on the application pool name and selecting "Recycle" on the right click context menu to ensure all configuration changes have taken place.

You are all set to use your application with the impersonated user account.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
India India
No Biography provided

Comments and Discussions

Generalthanks. it was helpful Pin
shamim07821-Mar-17 18:57
Membershamim07821-Mar-17 18:57 
GeneralMy vote of 1 Pin
Member 102493734-Sep-13 0:59
MemberMember 102493734-Sep-13 0:59 
GeneralRe: My vote of 1 Pin
jayeshkumar.rathod5-Sep-13 21:49
Memberjayeshkumar.rathod5-Sep-13 21:49 
GeneralRe: My vote of 1 Pin
Member 1024937310-Sep-13 22:25
MemberMember 1024937310-Sep-13 22:25 
GeneralMy vote of 5 Pin
Joezer BH30-Jul-13 20:52
professionalJoezer BH30-Jul-13 20:52 
GeneralMy vote of 5 Pin
Purushotham Agaraharam24-Jul-13 23:17
MemberPurushotham Agaraharam24-Jul-13 23:17 
GeneralMy vote of 4 Pin
sandeepkumarvemula11-Feb-13 22:29
Membersandeepkumarvemula11-Feb-13 22:29 
GeneralRe: My vote of 4 Pin
jayeshkumar.rathod6-Mar-13 20:42
Memberjayeshkumar.rathod6-Mar-13 20:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.