条件spsecurity.runwithelevateprivileges.
-
10-12-2019 - |
题
有条件有一种方法可以使用 spsecurity.runwithelevateprivileges 。 例如,假设我有一个代码块,如果满足某些条件,我想在 Spsecurity.RunwithElevatePrivileges 中运行此代码块,否则我希望在没有 Spsecurity.RunWithElevatePrivileges的情况下运行此代码块
解决方案
将代码放在带有void返回的方法中(委托要求)。之后,使用如果确定您的状况,以及实际方法。
//Run the MyElevatedFunctionCall function with elevated priviledges
SPSecurity.CodeToRunElevated elevatedCall = new SPSecurity.CodeToRunElevated(MyElevatedFunctionCall);
.