如何使用 FormsAuthentication 连接到 SharePoint 列表服务以获取所有列表
我有一个使用表单身份验证的共享点服务器。 现在我想连接到该服务器以通过列表 Web 服务获取所有列表。
我能够连接到使用 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;
}
I have a sharepoint server which uses Forms Authentication.
Now i want to connect to that server to fetch all the List via Lists Webservice.
i am able to connect to the SharePoint server which uses Windows Authentication, but i am not able to do it with the FormsAuthentication.
Can you please help me to figure that out.
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
您可以添加服务引用或使用 wsdl.exe 创建代理类,并使用以下代码从某个共享点站点获取所有列表:
如果您在调用
GetListCollection()
方法。只要您能够传递正确的凭据,这应该可行。 :)You can either add a Service Reference or create a proxy class using wsdl.exe and use the code below to get all lists from a certain sharepoint site:
Let me know if you are having errors calling the
GetListCollection()
method. As long as you are able to pass the correct credentials this should work. :)