How to Enable and Disable Impersonation in ASP.NET

Impersonation helps you to run an application for a particular user using that particular user account. With this the application uses the settings of the NTFS for that particular user to gain access to the files and the directories in the system.

To use impersonation you have to enable impersonation. By default impersonation is disabled and the anonymous user account is used by IIS.

To enable impersonation you have to modify the configuration file that is found in the applications root directory. Open up the configuration file in the application root directory and you will find an entry like,

<identity impersonate = “false” />

This is the default entry. You have to change the attribute value of impersonate to that of ‘true’ to enable impersonation. After changing it, you will find that to be,

<identity impersonate = “true” />

By changing this attribute you can enable or disable impersonation for an application.