Authenticating Office 365 SharePoint Online OOTB services

假装没事ソ 提交于 2019-12-09 12:41:18

问题


I want to consume SharePoint data into a non .Net platform. I already use the SharePoint OOTB services like Lists.asmx, Webs.asmx and search.asmx for this purpose. I have successfully added support for forms based authentication using Authentication.asmx. Now, I want to provide support for Office 365 SharePoint online. For that purpose I have a demo SharePoint Online site that I am working on. Problem, I am facing is when I use Mode method of Authentication.asmx I get ‘Forms’ in response:

<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>

However when I use Login.asmx and pass correct username and password, I get ‘PasswordNotMatch’ error, the same credentials are working fine in browser.

<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>

Note:- This works perfect for a FBA non Office 365 SharePoint site.

Could somebody please help me in implementing the support for Office 365 SharePoint Online OOTB services?


回答1:


I've been looking into a similar idea and this thread has been extremely helpful. They actually have a webservice sample using the PInvoke, it might help you get there.

Edit: my search led me to this other post by Wictor Wilen, but trying to avoid the ClientOM for now.

Edit2: alright, got this working. Using the code from Wictor above, I downloaded his sample solution and moved "MsOnlineClaimsHelper.cs" and "WcfClientContracts.cs" to my project, I will be fiddling with what is really used from these files later. I only changed them to remove the ClientOM references including the clientContext_ExecutingWebRequest method.

In a sample MVC3 app or Console app:

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);
}


来源:https://stackoverflow.com/questions/8093358/authenticating-office-365-sharepoint-online-ootb-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!