我尝试提取我创建的一些 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-with-401-for-all-users.aspx http://blogs.msdn.com/b/sridhara/archive/2014/02/06/sharepoint-2013-csom-call-from-web-part-fails-with-401-for-all-users.aspx
这提到尝试设置默认网络凭据:https://sharepoint.stackexchange.com/questions/10364/http-401-unauthorized-using-the-driven-client-object-model 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);
服务器运行 IIS 6.0
任何建议将不胜感激!
谢谢