Working of SAML based SharePoint federated server

Sanjay Kumar 1 Reputation point
2021-02-12T06:07:23.28+00:00

Could someone explain or share the link of how SAML based federated SharePoint server works internally? I am trying to upload file to federated SharePoint server using CURL.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. JoyZ 18,056 Reputation points
    2021-02-15T01:46:17.637+00:00

    Hi @Sanjay Kumar ,

    As a supplement, here is an article about modern authentication from CURL into SharePoint Online for your reference:

    https://williamvanstrien.blogspot.com/2018/05/authenticate-from-curl-into-sharepoint.html

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  2. Trevor Seward 11,696 Reputation points
    2021-02-12T22:13:45.603+00:00

    It works no differently than any other SAML application; SharePoint is irrelevant, here.

    https://stackoverflow.com/questions/48950092/authenticating-to-saml-server-with-curl

    0 comments No comments

  3. Sanjay Kumar R 81 Reputation points
    2021-02-22T08:34:15.057+00:00

    Hi Julie,

    I have got the rtFa and FedAuthcookies & requestDigest and I am able to successfully authenticate. But while uploading the file to SharePoint I am getting the below error,

    "<?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>-2130575251, System.Runtime.InteropServices.COMException</m:code><m:message xml:lang="en-US">The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.</m:message></m:error>"

    My sharepoint link : https://<name>.sharepoint.com/teams/SharePointTest2/Shared%20Documents/Forms/AllItems.aspx

    I am using libcurl to post the request.

    *int main()
    {
    CURL *c = curl_easy_init();
    struct curl_slist list = NULL;
    struct response res;
    init_response(&res);
    list = curl_slist_append(list, "Content-Type:text/plain");
    list = curl_slist_append(list, "X-RequestDigest:value");
    list = curl_slist_append(list, "Cookie:rtFa=value;FedAuth=value");
    curl_easy_setopt(c, CURLOPT_HTTPHEADER, list);
    curl_easy_setopt(c, CURLOPT_URL,"https://<name>.sharepoint.com/teams/SharePointTest2/_api/web/GetFolderByServerRelativeUrl('/Shared%20Documents')/Files/Add(url='DSsanjay.txt',%20overwrite=true)";);
    curl_easy_setopt(c, CURLOPT_POSTFIELDS, "THis is file data.. Writing...");
    curl_easy_setopt(c, CURLOPT_WRITEFUNCTION, writefunc);
    curl_easy_setopt(c, CURLOPT_WRITEDATA,&res);
    curl_easy_setopt(c, CURLOPT_VERBOSE, 1L);
    curl_easy_perform(c);
    }

    output:

    POST /teams/SharePointTest2/_api/web/GetFolderByServerRelativeUrl('/Shared%20Documents')/Files/Add(url='DSsanjay.txt',%20overwrite=true) HTTP/2

    Host: <name>.sharepoint.com
    accept: /
    content-type:text/plain
    x-requestdigest:value
    cookie:rtFa=value;FedAuth=value
    content-length: 30
    Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
    We are completely uploaded and fine
    < HTTP/2 403
    < cache-control: private, max-age=0
    < content-type: application/xml;charset=utf-8
    < expires: Thu, 04 Feb 2021 09:37:01 GMT
    < last-modified: Fri, 19 Feb 2021 09:37:01 GMT
    < vary: Origin
    < server: Microsoft-IIS/10.0
    < set-cookie: rtFa=value; path=/; secure; HttpOnly
    < set-cookie: FedAuth=value; path=/; secure; HttpOnly
    < x-sharepointhealthscore: 1
    < dataserviceversion: 3.0
    < x-aspnet-version: 4.0.30319
    < sprequestguid: 32tetc9f-f0cd-b000-de6a-c7515b894761
    < request-id: 32tetc9f-f0cd-b000-de6a-c7515b894761
    < ms-cv: n6y9Ms3tALDeasdRW4lHYQ.0
    < x-requestdigest: value
    < strict-transport-security: max-age=31536000
    < x-frame-options: SAMEORIGIN
    < content-security-policy: frame-ancestors 'self' teams.microsoft.com .teams.microsoft.com .skype.com .teams.microsoft.us local.teams.office.com .powerapps.com .yammer.com .officeapps.live.com .stream.azure-test.net .microsoftstream.com;
    < x-powered-by: ASP.NET
    < microsoftsharepointteamservices: 16.0.0.21003
    < x-content-type-options: nosniff
    < x-ms-invokeapp: 1; RequireReadOnly
    < p3p: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
    < date: Fri, 19 Feb 2021 09:37:01 GMT
    <
    Connection #0 to host <name>.sharepoint.com left intact
    Output = <?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>-2130575251, System.Runtime.InteropServices.COMException</m:code><m:message xml:lang="en-US">The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.</m:message></m:error>*

    Am I doing something wrong here?
    Please help me out.

    Regards,
    Sanjay

    0 comments No comments