StraliSolutions.CSOMSAML
1.2.0
dotnet add package StraliSolutions.CSOMSAML --version 1.2.0
NuGet\Install-Package StraliSolutions.CSOMSAML -Version 1.2.0
<PackageReference Include="StraliSolutions.CSOMSAML" Version="1.2.0" />
paket add StraliSolutions.CSOMSAML --version 1.2.0
#r "nuget: StraliSolutions.CSOMSAML, 1.2.0"
// 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:
- on calling ClaimClientContext.GetAuthenticatedContext the target teamsite will be opened in a web-browser component
- the security token will be cached getting the authentication information from the auth cookies
- 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 | Versions 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. |
-
- Microsoft.SharePoint.Client (>= 14.0.4762.1000)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
added support SharePoint Client library dependency. Added okieCollection GetAuthenticatedCookies(string targetSiteUrl). Added icon.