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

Login to add your contents and source code to this article
post comment
     

Many people asked me the same So i written a blog for it.you can check my blog
http://www.c-sharpcorner.com/UploadFile/Blogs/3918/

Posted by Destin joy Nov 09, 2010

Hi Destin,

Thank you for you time, this was what I was look for :)

Could you please also explain what is the difference between Impersonisation and Run With elevated privilages?

Thanks
Aneesh

Posted by Aneesh Bhargavan Nov 09, 2010
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.