StraliSolutions.CSOMSAML 1.2.0

dotnet add package StraliSolutions.CSOMSAML --version 1.2.0                
NuGet\Install-Package StraliSolutions.CSOMSAML -Version 1.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<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                
#r "nuget: StraliSolutions.CSOMSAML, 1.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install StraliSolutions.CSOMSAML as a Cake Addin
#addin nuget:?package=StraliSolutions.CSOMSAML&version=1.2.0

// Install StraliSolutions.CSOMSAML as a Cake Tool
#tool nuget:?package=StraliSolutions.CSOMSAML&version=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.

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

       	}
   	}
}
Product Compatible and additional computed target framework versions.
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 1,114 2/2/2018
1.1.0 1,017 2/1/2018
1.0.0 979 1/27/2018

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