更正将文件写入SharePoint内部磁盘的权限';s事件接收器

本文关键字:权限 接收器 事件 磁盘 文件 正将 内部 SharePoint | 更新日期: 2023-09-27 18:26:14

我一直在SharePoint中处理PoC,在处理文档库中添加或更新的项目的EventReceiver上,必须将文件复制到临时文件夹中。

我想知道,有没有办法知道哪个用户会在文件夹中写入文件?因为这可能在不同的服务器上工作,所以必须授予权限。

更正将文件写入SharePoint内部磁盘的权限';s事件接收器

对所有磁盘操作使用SPSecurity.RunWithElevatedPrivileges,因为传入用户不太可能拥有向服务器文件系统写入任何内容的权限。

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    // open/write/close file here. 
    // Avoid touching SPxxxx objects from outside of this delegate
});