我有一个使用表单身份验证的sharepoint服务器。 现在我想连接到该服务器以通过列表Webservice获取所有列表。
我能够连接到使用Windows身份验证的SharePoint服务器,但我无法使用FormsAuthentication进行此操作。
请你帮我解决一下。
public static Lists CreateSharepointService(string sharepointHost)
{
Lists wssSrvc = new Lists();
if (sharepointHost.EndsWith("/"))
wssSrvc.Url = sharepointHost + "_vti_bin/Lists.asmx";
else
wssSrvc.Url = sharepointHost + "/_vti_bin/Lists.asmx";
return wssSrvc;
}
public static Lists CreateSharepointService(string sharepointHost, string sharepointUsername, string sharepointPassword, string sharepointDomain)
{
NetworkCredential credential = new NetworkCredential(sharepointUsername, sharepointPassword, sharepointDomain);
Lists wssSrvc = CreateSharepointService(sharepointHost);
wssSrvc.Credentials = credential;
return wssSrvc;
}
答案 0 :(得分:0)
您可以使用wsdl.exe添加服务引用或创建代理类,并使用以下代码从特定的sharepoint站点获取所有列表:
XmlNode ndLists = listService.GetListCollection();
如果您在调用GetListCollection()
方法时遇到错误,请告诉我。只要您能够传递正确的凭据,这应该有效。 :)