小编use*_*960的帖子

共享点中的“RunWithElevatedPrivileges”

“RunWithElevatedPrivileges”:在 C# 中以编程方式允许没有管理列表权限的用户将文件上传到共享点列表项对我没有帮助。我的代码是:

SPSecurity.RunWithElevatedPrivileges(delegate
{
    SPWeb web = SPContext.Current.Site;

    // my logic to upload file and edit list item attachments.
});
Run Code Online (Sandbox Code Playgroud)

完整代码

protected void btn_Upload_Click(object sender, EventArgs e)
    {
        StreamWriter sw = new StreamWriter(@"C:\Upload.txt", true);
        try
        {
            if (this.FileUpload1.HasFile)
            {
                string siteURL = SPContext.Current.Web.Url.ToString();
                if (Request["Items"] != null && Request["ListId"] != null)
                {

                    string SelectedItems = Convert.ToString(Request["Items"]);
                    string[] lstJobsIds = SelectedItems.Split(new string[] { "|" }, StringSplitOptions.None);
                    SPList list = null;

                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {

                        //SPSite site = SPContext.Current.Site;
                        using (SPSite …
Run Code Online (Sandbox Code Playgroud)

c# asp.net sharepoint iis-7 code-access-security

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

asp.net ×1

c# ×1

code-access-security ×1

iis-7 ×1

sharepoint ×1