StraliSolutions.CSOMSAML 1.2.0

StraliSolutions.CSOMSAML.Auth

The purporse of this library is to create an Authenticated ClientContext in a Claim-based SharePoint environment using Active Directoy Federation Services authentication via SAML.

Install-Package StraliSolutions.CSOMSAML -Version 1.2.0
dotnet add package StraliSolutions.CSOMSAML --version 1.2.0
<PackageReference Include="StraliSolutions.CSOMSAML" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StraliSolutions.CSOMSAML --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

StraliSolutions.CSOMSAML.Auth

The purporse of this library is to create an Authenticated ClientContext in a Claim-based SharePoint environment using Active Directoy Federation Services authentication via SAML.

The approach works in the following way:

  1. on calling ClaimClientContext.GetAuthenticatedContext the target teamsite will be opened in a web-browser component
  2. the security token will be cached getting the authentication information from the auth cookies
  3. the ClientContext returned from ClaimClientContext will ensure that the security token is added on each http request

Note: The library works by using the current user context. So, the user has to be logged on to a domain where ADFS SSO is configured. In case you need to switch the user's context or you don't have an ADFS SSO configuration in place, I recommend to use https://github.com/SharePoint/PnP-Sites-Core/blob/master/Core/SAML%20authentication.md.

Edit: Additional functionality was added in order to read out the cookie data by using ClaimClientContext.GetAuthenticatedCookies("https://mysharepointsite"). By using the cookies in e.g. an HTTPWebRequest object, it is possible to call SharePoint API's.

Testing the component

using Microsoft.SharePoint.Client;
using StraliSolutions.CSOMSAML.Auth;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Testapp
{
   	class Program
   	{
    	static void Main(string[] args)
       	{
           	try
           	{
            	 using (ClientContext cxt = 
               	 ClaimClientContext.GetAuthenticatedContext("https://mywebapp.onmydomain.com/sites/teamsite"))
                     { 

                   	 Web web = cxt.Web;
                   	 cxt.Load(web);

                   	 cxt.ExecuteQuery();//here the exception is thrown, when team site does not exist
                   	 Console.WriteLine("Teamsite accessible");
                	}
           	}
           	catch 
           	{
               	Console.WriteLine("Teamsite not accessible");
           	}

       	}
   	}
}

StraliSolutions.CSOMSAML.Auth

The purporse of this library is to create an Authenticated ClientContext in a Claim-based SharePoint environment using Active Directoy Federation Services authentication via SAML.

The approach works in the following way:

  1. on calling ClaimClientContext.GetAuthenticatedContext the target teamsite will be opened in a web-browser component
  2. the security token will be cached getting the authentication information from the auth cookies
  3. the ClientContext returned from ClaimClientContext will ensure that the security token is added on each http request

Note: The library works by using the current user context. So, the user has to be logged on to a domain where ADFS SSO is configured. In case you need to switch the user's context or you don't have an ADFS SSO configuration in place, I recommend to use https://github.com/SharePoint/PnP-Sites-Core/blob/master/Core/SAML%20authentication.md.

Edit: Additional functionality was added in order to read out the cookie data by using ClaimClientContext.GetAuthenticatedCookies("https://mysharepointsite"). By using the cookies in e.g. an HTTPWebRequest object, it is possible to call SharePoint API's.

Testing the component

using Microsoft.SharePoint.Client;
using StraliSolutions.CSOMSAML.Auth;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Testapp
{
   	class Program
   	{
    	static void Main(string[] args)
       	{
           	try
           	{
            	 using (ClientContext cxt = 
               	 ClaimClientContext.GetAuthenticatedContext("https://mywebapp.onmydomain.com/sites/teamsite"))
                     { 

                   	 Web web = cxt.Web;
                   	 cxt.Load(web);

                   	 cxt.ExecuteQuery();//here the exception is thrown, when team site does not exist
                   	 Console.WriteLine("Teamsite accessible");
                	}
           	}
           	catch 
           	{
               	Console.WriteLine("Teamsite not accessible");
           	}

       	}
   	}
}

Release Notes

added support SharePoint Client library dependency. Added okieCollection GetAuthenticatedCookies(string targetSiteUrl). Added icon.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.2.0 261 2/2/2018
1.1.0 237 2/1/2018
1.0.0 232 1/27/2018