如何使用 FormsAuthentication 连接到 SharePoint 列表服务以获取所有列表

发布于 2024-12-06 15:35:30 字数 929 浏览 1 评论 0原文

我有一个使用表单身份验证的共享点服务器。 现在我想连接到该服务器以通过列表 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幻想少年梦 2024-12-13 15:35:30

您可以添加服务引用或使用 wsdl.exe 创建代理类,并使用以下代码从某个共享点站点获取所有列表:

XmlNode ndLists = listService.GetListCollection();

如果您在调用 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:

XmlNode ndLists = listService.GetListCollection();

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. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文