SharePoint中自定义代码普通用户执行报Access Denied, 管理员执行就OK, 咋办?

正解如下:

把出错的代码调用放在SPSecurity.RunWithElevatedPrivileges中, 即可.

 

举例

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    // implementation details omitted
});

 

MSDN解释该方法的功能如下:

Executes the specified method with Full Control rights even if the user does not otherwise have Full Control.

 

参考资料

==============

SPSecurity.RunWithElevatedPrivileges Method

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx

你可能感兴趣的:(SharePoint)