Код: Выделить всё
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)
Информация о моем сервере приведена ниже:
- Windows Server 2012
- SharePoint 2013
- SQL Server 2012
Веб-служба .NET Версия (4.0)
Код веб-службы (для теста):
С делегатом (и все равно не работает, если закомментируйте "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";
}
Подробнее здесь: https://stackoverflow.com/questions/235 ... -is-denied