【问题标题】:SharePoint 2013 - System.UnauthorizedAccessException: Access is deniedSharePoint 2013 - System.UnauthorizedAccessException:访问被拒绝
【发布时间】:2014-06-28 04:58:11
【问题描述】:

当我尝试在我的网络服务中创建文件夹/项目时收到以下错误消息,请问您的建议?

System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at Microsoft.SharePoint.Utilities.SPUtility.HandleAccessDenied(Exception ex)
   at Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem …… (SKIP)

使用本地管理员帐户(也是网站集管理员)的 Web 服务(应用程序池和通过身份验证)

我的服务器信息如下: - 视窗服务器 2012 - SharePoint 2013 - SQL Server 2012

Web 服务 .NET 版本 (4.0)

Web 服务代码(用于测试):

使用委托(如果注释掉“RunWithElevatedPrivileges”仍然无效):

public string TestCreateFolderTestingElevatedSecurity()
        {

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {

                using (SPSite oSPsite = new SPSite(strSharePointSite))//http://localhost
                {
                    oSPsite.AllowUnsafeUpdates = true;

                    using (SPWeb oSPWeb = oSPsite.OpenWeb())
                    {
                        oSPWeb.AllowUnsafeUpdates = true;

                        /* Path within the list where the new folder gets created
                           Leave it empty if it needs to be created under root */
                        String nodeDepthPath = @"";

                        /* get the list instance by name */
                        SPList list = oSPWeb.Lists.TryGetList(strTestDocLib);//DocumentLibrary

                        /* create a folder under the path specified */
                        SPListItem folderItem = list.Items.Add(
                            list.RootFolder.ServerRelativeUrl + nodeDepthPath,
                            SPFileSystemObjectType.Folder, strNewFolderName);//FolderName

                        /* set the folder name and update */
                        folderItem.Update();

                        oSPWeb.AllowUnsafeUpdates = false;
                    }

                    oSPsite.AllowUnsafeUpdates = false;
                }
            });
            return "Success";
        }

非常感谢您的关注。

【问题讨论】:

    标签: c# sharepoint sharepoint-2013 access-denied


    【解决方案1】:

    此问题与 SP 2013 和 Web 服务有关。相同的代码可以在 SP 2010 中正常工作。要解决此问题,请使用 Win32 API 模拟。查看这篇文章的答案 - http://social.msdn.microsoft.com/Forums/sharepoint/en-US/6c306583-5d90-49e7-a213-c0410b705b27/impersonation-not-working-in-sharepoint-web-service

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-19
      • 2015-02-28
      • 2017-01-24
      相关资源
      最近更新 更多