【发布时间】: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