使用默认提供的方式认证 Office 365 SharePoint Online 服务

7
我想在非 .Net 平台上使用 SharePoint 数据。我已经使用了 SharePoint OOTB 服务,如 Lists.asmx、Webs.asmx 和 search.asmx 来实现这个目的。 我已经成功地添加了对使用 Authentication.asmx 的基于表单的身份验证的支持。 现在,我想提供对 Office 365 SharePoint 在线的支持。为此,我正在使用一个演示 SharePoint Online 站点进行工作。 问题是,当我使用 Authentication.asmx 的 Mode 方法时,我得到了 'Forms' 的响应:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
    <ModeResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
        <ModeResult>Forms</ModeResult>
    </ModeResponse>
</soap:Body>
</soap:Envelope>

然而,当我使用Login.asmx并输入正确的用户名和密码时,我会收到“PasswordNotMatch”错误提示。在浏览器中,同样的凭据可以正常工作。

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
    <LoginResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
        <LoginResult>
         <ErrorCode>PasswordNotMatch</ErrorCode>
            <TimeoutSeconds>0</TimeoutSeconds>
        </LoginResult>
    </LoginResponse>
</soap:Body>
</soap:Envelope>

注意:此方法适用于非Office 365 SharePoint站点。请问能否有人帮我实现对Office 365 SharePoint在线OOTB服务的支持?
1个回答

6
我一直在研究类似的想法,这个帖子非常有帮助。他们实际上使用了PInvoke编写了一个Web服务示例,这可能会对你有所帮助。 编辑:我的搜索结果引导我到Wictor Wilen的另一篇文章,但现在我试图避免使用ClientOM。 编辑2:好的,我已经搞定了。使用来自Wictor的代码,我下载了他的示例解决方案,并将“MsOnlineClaimsHelper.cs”和“WcfClientContracts.cs”移动到我的项目中,稍后我将调整这些文件中真正使用的内容。我只是改变了它们以删除包括clientContext_ExecutingWebRequest方法在内的ClientOM引用。
在一个样本MVC3应用程序或控制台应用程序中:
MsOnlineClaimsHelper claimsHelper = new MsOnlineClaimsHelper("https://my365site.sharepoint.com/sites/enterprise/", "admin@my365site.onmicrosoft.com", "secret");

using (var lists = new SharePointLists.Lists())
{
    lists.Url = @"https://my365site.sharepoint.com/sites/enterprise/_vti_bin/lists.asmx";
    lists.CookieContainer = claimsHelper.CookieContainer;
    var listCol = lists.GetListCollection();
    ViewBag.Message = listCol.InnerXml;
    //Console.Write(listCol.InnerXml);
}

1
@Kuldeep Shige,我该如何使用SOAP在Office 365上通过基于表单的身份验证进行身份验证?我尝试向“Authentication.asmx”发送有效的用户名/密码SOAP请求,但收到“PasswordNotMatch”的错误提示。 - surlac
1
不确定,这是一个简单的密码吗?我会查看编码,然后尝试获取文档以查看它们是否需要密码或其哈希版本。 - Francisco Aquino
1
@F.Aquino:Wictors的代码在Office 365的某些情况下无法正常工作。我遇到了这个错误:“拒绝访问。在打开此位置中的文件之前,您必须先浏览到网站并选择自动登录选项。” - Syeda

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接