How to run SharePoint code with Elevated Privileges ?

SharePoint elevated privileges, site collection administrator code RunWithElevatedPrivileges is a class in SharePoint which comes under SPSecurity namespace. It allows developers to create the code that runs as the System Account instead of the logged in user, essentially giving that user Administrator Level Permissions in a specific space.

What are the security risks in it ?

So there is a question that, Run with elevated privileges can create high security risk ? Security risk is very minimal as the user will only have permission to do exactly what the developer will allow them through the code. Here is a syntax for that:

private void yourFunction() 
 { 
 // Non-Elevated Permission Code Goes Here 
SPSecurity.RunWithElevatedPrivileges(delegate() 
 { // Elevated Permission Code Goes Here }); // Non-Elevated Permission Code Goes Here 
}

Leave a Comment

RSS
YouTube
YouTube
Instagram