ARTICLE

Impersonation in Sharepoint

Posted by Destin joy Articles | SharePoint 2010 August 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.
Reader Level:
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

UseAppPoolIdentity()

ReturnToImpersonatingCurrentUser()


First.jpg

Second.jpg

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().

COMMENT USING