2

I am currently migrating our server side event receivers to be remote event receivers. Now, one thing I can not find a way of doing it is how I can run part of my remote event receiver code in elevated privileges?

For example, inside my current server side ER, I have a method to create a subsite, and users who cause the server-side ER to run do not have permission to create subsites, so for this method I wrap it with this code:

private void yourFunction()
{
      SPSite site = SPContext.Current.Site;
      SPWeb web = SPContext.Current.Web;

      SPSecurity.RunWithElevatedPrivileges(delegate()

But I can not find a equivalent method to run part of the remote event receiver in elevated privilege? Can anyone help?

Thanks.

0

In On-Premise, using the code below:

ClientContext context = new ClientContext("http://yourserver/");
context.Credentials = new NetworkCredential("admin user", "password", "domain");

In SharePoint Online, using the code below:

var password = "password";
var securePassword = new SecureString();
foreach (char c in password){securePassword.AppendChar(c);}
ClientContext context = new ClientContext("https://contoso.sharepoint.com")
context.Credentials = new SharePointOnlineCredentials("User Name", securePassword);

Articles below for your reference:

Elevated privileges in SharePoint Add-ins

Elevate Permissions for your SharePoint CSOM code

App-only and elevated privileges in the SharePoint add-in model

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.