In SharePoint, when I need to execute an action when the user doesn't have privileges to do so, I use:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
// DO SOMETHING WITH PRIVILEGES
});
But now I need to execute JavaScript with elevated privileges:
var context = new SP.ClientContext.get_current();
context.executeQueryAsync(); // NEED PRIVILEGES TO WORK
Is this possible?
In SharePoint, when I need to execute an action when the user doesn't have privileges to do so, I use:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
// DO SOMETHING WITH PRIVILEGES
});
But now I need to execute JavaScript with elevated privileges:
var context = new SP.ClientContext.get_current();
context.executeQueryAsync(); // NEED PRIVILEGES TO WORK
Is this possible?
Share Improve this question edited Jun 16, 2015 at 13:27 William 4139 silver badges21 bronze badges asked May 17, 2011 at 9:38 Dr. NoDr. No 1,3365 gold badges28 silver badges57 bronze badges2 Answers
Reset to default 7No, that isn't possible.
The user would be able to manipulate the JavaScript which would open a huge security gap. You just can do this on the server-side. If you need something like this it must all take place at the server.
Agreed that you can't do this from JavaScript and it would be foolish if you could. One scenario that could help you is to look into Designer no-code workflows. New in SP2010 is the ability to have chunks of the workflow execute as the person who designed the workflow rather than the person who has started the workflow instance. This could be used to get around your permissions problem.