Hid*_*dan 8 asp.net sharepoint http-status-code-401 asp.net-mvc-4 csom
我试图提取一些我创建的SharePoint 2013列表数据,这些数据在我的机器上本地运行时运行正常,并且在本地运行一个服务器.在服务器上本地和本地运行时,我使用相同的凭据.问题是,当我发布并导航到服务器上的ASP.NET应用程序时,我得到"远程服务器返回错误:(401)未经授权." 错误...
我查看了stackoverflow上的一些帖子以及网络上的其他一些文章
这指出上下文似乎正在使用IUSR:http: //blogs.msdn.com/b/sridhara/archive/2014/02/06/sharepoint-2013-csom-call-from-web-part-fails-与-401换全users.aspx
这个提到尝试设置默认网络凭据:https: //sharepoint.stackexchange.com/questions/10364/http-401-unauthorized-using-the-managed-client-object-model
我尝试使用文章中提到的修复程序以及尝试强制上下文使用DefaultNetworkCredentials但没有运气.我想让应用程序使用登录用户的凭据而不是机器...
这是我正在使用的代码:
SP.ClientContext context = new SP.ClientContext("MySPDevInstance");
context.Credentials = CredentialCache.DefaultNetworkCredentials;
Entity entity = context.Web.GetEntity(collectionNamespace, collectionName);
LobSystem lobSystem = entity.GetLobSystem();
LobSystemInstanceCollection lobSystemInstanceCollection = lobSystem.GetLobSystemInstances();
context.Load(lobSystemInstanceCollection);
context.ExecuteQuery();
LobSystemInstance lobSystemInstance = lobSystemInstanceCollection[0];
FilterCollection filterCollection = entity.GetFilters(filter);
filterCollection.SetFilterValue("LimitFilter", 0, 1000);
EntityInstanceCollection items = entity.FindFiltered(filterCollection, filter, lobSystemInstance);
Run Code Online (Sandbox Code Playgroud)
服务器正在运行IIS 6.0
任何建议将不胜感激!
谢谢
我假设您的ASP.NET网站正在使用Windows集成(NTLM)身份验证.以这种方式进行身份验证的用户无法从服务器端(Web服务器)向第二个位置进行身份验证.您正在遇到所谓的NTLM的"双跳"(1)限制.您必须在服务器端使用专用帐户,或者如果您确实要使用登录用户的身份,则必须使用允许委派的身份验证方案,例如Kerberos.
如果您确实需要用户的身份来访问SharePoint数据而您无法更改身份验证方案,那么最好的方法是使用JavaScript CSOM.这意味着用户直接向SharePoint服务器进行身份验证(单跳,而不是双重),并且ASP.NET站点向用户提供包含此脚本的页面.
(1)http://blogs.msdn.com/b/knowledgecast/archive/2007/01/31/the-double-hop-problem.aspx
| 归档时间: |
|
| 查看次数: |
50443 次 |
| 最近记录: |