我越来越试图通过SharePoint API从ASP.NET MVC应用程序中访问SharePoint 2010网站时,出现以下错误:访问被拒绝从MVC应用程序中访问的SharePoint API
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
MVC应用与SharePoint安装上的站点管理员的应用程序池用户以64位模式驻留在IIS7上。 重要的是,调用SharePoint API的WCF服务在同一个Web应用程序中托管,没有任何问题,所以我觉得很奇怪我无法从Controller Action获取相同的结果。
我曾尝试:
- 设置
System.web/identity impersonate="true" etc etc
- 设置
System.web/authentication mode="Windows"
- 以上的组合。
不管是什么上面试过,System.Security.Principal.WindowsIdentity.GetCurrent().Name
返回预期的应用程序池用户,但Request.IsAuthenticated
返回false。这既是编程通过调试检查,以及在事件日志中验证:
Event code: 4011
Event message: An unhandled access exception has occurred.
...
Process information:
Process ID: 1234
Process name: w3wp.exe
Account name: VALIDDOMAIN\VALIDUSER
Request information:
Request URL: http://localhost:2000/Service/
Request path: /Service/
User host address: ::1
User:
Is authenticated: False
Authentication Type:
Thread account name: VALIDDOMAIN\VALIDUSER
我怎么能说一个标准MVC3 Web应用程序控制器操作在SharePoint 2010 API?
更新01:
下面是我使用的代码:
using (SPSite site = new SPSite(siteUrl))
{
workflow.SPSiteCollectionID = site.ID;
using (SPWeb web = site.OpenWeb())
{
foreach (SPGroup group in web.SiteGroups)
{
//some code
}
}
}
这无法上线foreach (SPGroup group in web.SiteGroups)
您定位哪个框架? 3.5? – int32
.NET 3.5 - 这是我们可以与SharePoint 2010 API一起使用的唯一版本。 –
是的,我知道,这就是为什么我问:P,所以当你构建一个新的SPSite对象的权利时,拒绝访问?您是否尝试过提升特权?另外,在wcf服务中,您是否在任何地方(config/code)设置了默认(网络)凭据? – int32