0

Is there a way to use SPSecurity.RunWithElevatedPrivileges conditionally. For example, assume that i have a code block, if some condition is met i want to run this code block in SPSecurity.RunWithElevatedPrivileges, otherwise i want to run this code block without SPSecurity.RunWithElevatedPrivileges

1

Put your code in a method with the VOID return (required by the delegate). Afterwards, use the if to determine your condition, and the actual method.

 //Run the MyElevatedFunctionCall function with elevated priviledges
       SPSecurity.CodeToRunElevated elevatedCall = new SPSecurity.CodeToRunElevated(MyElevatedFunctionCall);

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.