Ajouter un serveur AD FS 2.0 à SharePoint

Le but de cet article est d’ajouter un serveur AD FS 2.0 à SharePoint. Afin que SharePoint reconnaisse ce serveur comme fournisseur d’identité, il faut passer par la console d’administration de SharePoint (utilisant PowerShell). Nous allons avons besoin de deux certificats, que nous plaçons à la racine du disque :

  • root.cer : le certificat racine de l’autorité de certification
  • adfs.cer : le certificat dit de ‘token signing’ du serveur AD FS 2.0.

Procédure

Le script PowerShell à utiliser est le suivant, détaillé ligne par ligne.

$root = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:root.cer")

On crée tout d’abord une variable root à partir du certificat racine de l’autorité de certification.

New-SPTrustedRootAuthority -Name "Token Signing Cert Root" -Certificate $root

Cette commande ajoute l’autorité racine de confiance à SharePoint. Elle prend en paramètre le nom de l’autorité racine de confiance à créer et le certificat qui est ici $root.

$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:adfs.cer")
New-SPTrustedRootAuthority -Name "Token Signing Cert" -Certificate $cert

On refait les deux mêmes étapes pour le certificat de token signing utilisé par le serveur AD FS 2.0.

$map = New-SPClaimTypeMapping -IncomingClaimType "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" -IncomingClaimTypeDisplayName "EmailAddress" -SameAsIncoming
$map2 = New-SPClaimTypeMapping -IncomingClaimType "http://schemas.microsoft.com/ws/2008/06/identity/claims/role" -IncomingClaimTypeDisplayName "Role" -SameAsIncoming

Avec ces deux commandes, on va créer deux mappages. Le premier est sur l’adresse mail et le second sur les revendications de rôles.

$realm = "urn:" + $env:ComputerName + ":adfs"

On crée ensuite une variable realm qui va permettre de définir le domaine utilisé par SharePoint.

$ap = New-SPTrustedIdentityTokenIssuer -Name "Identification partenaire" -Description "SharePoint secured by SAML" -realm $realm -ImportTrustCertificate $cert -ClaimsMappings $map,$map2 -SignInUrl "https://adfsresource.treysearch.com/adfs/ls" -IdentifierClaim “http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress

Enfin on exécute la commande “New-SPTrustedIdentityTokenIssuer” qui configure SharePoint afin qu’il puisse se connecter au service d’émission de jeton de l’ « Identity Provider ». On va maintenant définir chaque attribut, pour mieux comprendre ce que fait cette fonction :

  • « Name» : Indique le nom qui apparaitra dans l’application Web lorsque l’utilisateur choisira son fournisseur d’authentification pour se connecter ;
  • « realm » : Défini le domaine que SharePoint doit utiliser pour se connecter à l’ « Identity Provider » ;
  • « ImportTrustCertificate » : Importe le certificat de token signing ;
  • « ClaimMapping » : Représente l’endroit où nous indiquons à l’ « Identity Provider » les Claims nécessaires pour s’authentifier ;
  • « SignInUrl » : Défini l’URL où les utilisateurs sont redirigés pour s’authentifier auprès de l’ « Identity Provider ». Il faut renseigner le nom du serveur AD FS suivi de /adfs/ls (dans notre cas, par exemple : https://adfsresource.treysearch.com/adfs/ls ;
  • « IdentifierClaim » : Indique à SharePoint le Claim qui permettra d’identifier l’utilisateur. Dans notre cas, nous désirons que l’utilisateur soit identifié par l’adresse mail ;

Une fois le serveur ADFS reconnu comme « Identity Provider » par SharePoint. Vous verrez apparaitre votre ADFS dans la catégorie « Trusted Identity Provider » des paramètres des applications SharePoint.

The goal of this article is to add an AD FS 2.0 as an authentication provider in SharePoint 2010. The only way to do it is using the SharePoint administration console (using PowerShell).

We will need two certificates (placed at the root of the C: drive in our case):

  • root.cer: the certifications authority’s root certificate.
  • adfs.cer: the ‘token signing’ certificate from the AD FS server.

We will explain every step of the script used here:

$root = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 ("C:root.cer")

Here we load the root certificate in the root variable.

New-SPTrustedRootAuthority -Name "Token Signing Cert Root" -Certificate $root

We add the certificate to the list of trusted authorities in SharePoint.

$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:adfs.cer")
New-SPTrustedRootAuthority -Name "Token Signing Cert" -Certificate $cert

And we do the same for the token signing certificate used by AD FS 2.0.

$map = New-SPClaimTypeMapping -IncomingClaimType "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" -IncomingClaimTypeDisplayName "EmailAddress" -SameAsIncoming
$map2 = New-SPClaimTypeMapping -IncomingClaimType "http://schemas.microsoft.com/ws/2008/06/identity/claims/role" -IncomingClaimTypeDisplayName "Role" -SameAsIncoming

We create two mapping for the incoming claims, one for the email address and one for the role. They will be used later.

$realm = "urn:" + $env:ComputerName + ":adfs"

It is the identifier of your server. The name has to be the same as the one in the AD FS configuration when adding a relying party trust, under relying party identifier.

$ap = New-SPTrustedIdentityTokenIssuer -Name "Remote connection" -Description "SharePoint secured by SAML" -realm $realm -ImportTrustCertificate $cert -ClaimsMappings $map,$map2 -SignInUrl "https://adfsresource.treysearch.com/adfs/ls" -IdentifierClaim “http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress

This is the command actually adding AD FS as trusted identity provider to SharePoint, with all the parameters set on the previous lines. Here are some explanations:

  •  « Name»: the name you want to give to your identity provider. It will also appear for users connecting to SharePoint, so choose wisely ;
  • « realm »: the SharePoint realm you want to add this provider to (we only have on realm here), the one defined before ;
  • « ImportTrustCertificate »: the certificate that will be used by AD FS to sign the tokens (it is the token signing certificate) ;
  • « ClaimMapping » : mapps the claims used for authentication ;
  • « SignInUrl »: the address the users are redirected to for signing in using AD FS. In our case, the AD FS server is adfsresource on Treysearch.com, so the url is https://adfsresource.treysearch.com/adfs/ls (server address appended by /adfs/ls/);
  • « IdentifierClaim » : defines which claim will be used for identifying the user ;

Once you have added AD FS as claims provider in SharePoint, you will be able to select it in SharePoint for your applications.