Reader Level:

Impersonation in Sharepoint

By Destin joy on Aug 13, 2010
There are many situations while we work with share point that we need to impersonate a user with higher permission or with Admin privileged user. This will help to do the same.
  • 0
  • 0
  • 18526
Download Files:

While working with share point there are several situations that we need to do impersonation. For example, while you work with site creation programmatically and you don't want to give full privilege to the user who does the same. In such Scenarios this small code be helpful to you.

Before starting you have to use the below two namespaces

using System.Security.Permissions;

using System.Security.Principal;

Add the below two functions





Please call the function UseAppPoolIdentity() where ever you want to impersonate the user with admin rights. When you finished with admin privileged operation just call t he second function  ReturnToImpersonatingCurrentUser().

Destin joy

Destin Joy is  a Microsoft MVP in SharePoint Server. He is a blogger, author and a Speaker.He also holds Mindcracker MVP and Microsoft Certified TrainerYou can reach him @