using System.Security.Permissions; using System.Security.Principal;
Before starting you have to use the below two name spaces
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().

Join the conversation! Your thoughts help the community grow.