我试图提取一些我创建的 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
这提到尝试设置默认网络凭据: 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
任何建议将不胜感激!
谢谢