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()
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().
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: