Click here to Skip to main content
Click here to Skip to main content

Implement Impersonation in ASP.NET

, 2 Jan 2013
Rate this:
Please Sign up or sign in to vote.
Implementing impersonation in ASP.NET.

Introduction

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:

<system.web>
<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.

Steps

  1. Open IIS Manager.
  2. Expand computer name.
  3. Expand websites.
  4. Click on the specific website for which you want to use impersonation.
  5. On the right panel, under the heading "IIS", double click "Authentication".
  6. Right click on "ASP.NET Impersonation" and select "Edit".
  7. Choose "Specific User".
  8. 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. Select "Identity" under "Process Model".
  6. Click on the button to set the user account.
  7. Select "Custom account".
  8. Click on the button to specify the user account and password.
  9. 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.

License

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

About the Author

j0y209
Web Developer
India India
No Biography provided

Comments and Discussions

 
GeneralMy vote of 1 PinmemberMember 102493734-Sep-13 0:59 
GeneralRe: My vote of 1 Pinmemberj0y2095-Sep-13 21:49 
GeneralRe: My vote of 1 PinmemberMember 1024937310-Sep-13 22:25 
GeneralMy vote of 5 PinprofessionalMaimonides30-Jul-13 20:52 
GeneralMy vote of 5 PingroupPurushotham Agaraharam24-Jul-13 23:17 
GeneralMy vote of 4 Pinmembersandeepkumarvemula11-Feb-13 22:29 
GeneralRe: My vote of 4 Pinmemberj0y2096-Mar-13 20:42 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 2 Jan 2013
Article Copyright 2013 by j0y209
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid