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

posted on 2012-03-13 18:04  中道学友  阅读(396)  评论(0编辑  收藏  举报

导航

技术追求准确,态度积极向上