我正在尝试获取Office 365 SharePoint网站文档库中的文件名列表。
我使用下面的代码使用Visual Studio 2010访问List.asmx
服务。
ServiceReference1.ListsSoapClient ws = new ServiceReference1.ListsSoapClient();
ws.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("USERNAME", "PASSWORD", "sharepoint");
ws.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
ws.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://XYZ.sharepoint.com/_vti_bin/lists.asmx");
XElement li = ws.GetListCollection();
执行ws.GetListCollection()
函数时,此代码给出了以下错误:
The HTTP request was forbidden with client authentication scheme 'Ntlm'.
任何人都可以帮助我吗? SharePoint网站访问权限是否有任何问题,或者我在代码部分或某些配置事项中遗漏了什么?