How to run SharePoint code with Elevated Privileges ?What are the security risks in it ?


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. 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 }

Comments

Popular

C# 6.0 New Features

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX

What is Cloud Computing - A guide for beginners