SharePoint : Mise en place de la recherche hybride (Partie 8)

 
Les articles précédents présentaient l’étape 1 de la mise en place de la recherche hybride, la configuration de l’authentification des utilisateurs.
Nous sommes maintenant à l’article 3 de la deuxième étape dans la configuration de l’authentification entre SharePoint Server 2013 et SharePoint Online

Les articles précédents sont disponibles ci-dessous:

Etape 1: Configuration de l’authentification des utilisateurs

Etape 2 : Configuration de l’authentification entre SharePoint Server 2013 et SharePoint Online
Dans ce billet, nous allons aborder la configuration de l’infrastructure de management d’identité. C’est la partie qui nécessite le plus l’utilisation de script PowerShell. J’ai essayé de détailler le plus possible les différentes étapes avec un maximum de copies d’écran.

Configuration de l’infrastructure de management d’identité 

Définition des variables du script de paramétrage

Dans cette partie nous allons utiliser le script de la fiche technique : https://technet.microsoft.com/en-us/library/dn197169.aspx

Ci-dessous, la liste des variables utilisées lors du script de configuration de la relation « server-to-server ».

  • $spcn The root domain name of your public domain, such as adventureworks.com. You must supply this value in the command that populates this variable. This value should not be in the form of a URL; it should be the domain name only, with no protocol.
  • $spsite The internal URL of your on-premises primary web application, such as https://sharepoint.adventureworks.com. You must supply this value in the command that populates this variable in the form of a full URL as shown (protocol://name). Ensure that you specify the correct protocol in the URL (either https:// or https:// ).
  • $site The converted URL of your on-premises primary web application. The command that populates this variable converts the value of the $spsite variable to a format that is used by certain commands.
  • $spoappid The SharePoint Online application principal ID (00000003-0000-0ff1-ce00-000000000000). This is a generic value that identifies the SharePoint Online application principal in the global Office 365 farm.
  • $spocontextID The context ID of your SharePoint Online tenant.
  • $metadataEndpoint The URL that is used by your Windows Azure AD proxy to connect to your Windows Azure AD tenancy.
Définition des variables

$spcn="*.<public_root_domain_name>.com"

$spsite=Get-Spsite <principal_web_application_URL>

$site=Get-Spsite $spsite

$spoappid="00000003-0000-0ff1-ce00-000000000000"

$spocontextID = (Get-MsolCompanyInformation).ObjectID

$metadataEndpoint = "https://accounts.accesscontrol.windows.net/" + $spocontextID + "/metadata/json/1"

Ci-dessous une copie d’écran pour l’exemple :

clip_image001

Téléchargement du certificat STS vers SharePoint Online

Le script ci-dessous télécharge le certificat se trouvant sur site vers le SharePoint Online :

$cerPath = "<path to replacement certificate (.cer file)>"

$cer = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList $pfxPath, $pfxPass

$cer.Import($cerPath)

$binCert = $cer.GetRawCertData()

$credValue = [System.Convert]::ToBase64String($binCert);

#La date de début (StartDate) doit être la date du jour. La date de fin (EndDate) doit être la date d'expiration du certificat STS. Date au format Mois/Jour/Année

New-MsolServicePrincipalCredential -AppPrincipalId $spoappid -Type asymmetric -Usage Verify -Value $credValue -StartDate <start_date. > -EndDate <end_date>

Ci-dessous, une copie d’écran pour l’exemple :

clip_image002

Création d’un SPN pour le nom du domaine public

Le script ci-dessous va rajouter un « Service Principal Name » (SPN) dans le SharePoint Online

$msp = Get-MsolServicePrincipal -AppPrincipalId $spoappid

$spns = $msp.ServicePrincipalNames

$spns.Add("$spoappid/$spcn")

Set-MsolServicePrincipal -AppPrincipalId $spoappid -ServicePrincipalNames $spns

Ci-dessous, une copie d’écran pour l’exemple :

image

ATTENTION !!! Notez la différence par rapport à la fiche Technet. Lors de l’exécution de la commande Set-MsolServicePrincipal, j’ai eu une « Unknown error » (pratique pour débugger !! J). J’ai corrigé le problème avec la commande suivante (en fait j’ai tout simplement passer en dur le « Service Principal Name »)

Set-MsolServicePrincipal -ServicePrincipalNames 00000003-0000-0ff1-ce00-000000000000/*.sharepoint.com -AppPrincipalId $spoappid

Pour vérification, vous pouvez exécuter les commandes suivantes :

$msp = Get-MsolServicePrincipal -AppPrincipalId $spoappid

$spns = $msp.ServicePrincipalNames

$spns

En résultat, vous devez avoir un SPN de la forme :

00000003-0000-0ff1-ce00-000000000000/*.<public domain name>.com

Ci dessous, une copie d’écran pour l’exemple :

clip_image005

Définition de l’application Principale de SharePoint Online

Cette étape va permettre la liaison entre L’ID de l’application principale de SharePoint Online avec le Service « Application Management » de SharePoint Server 2013.

$spoappprincipalID = (Get-MsolServicePrincipal -ServicePrincipalName $spoappid).ObjectID

$sponameidentifier = "$spoappprincipalID@$spocontextID"

$appPrincipal = Register-SPAppPrincipal -site $site.rootweb -nameIdentifier $sponameidentifier -displayName "SharePoint Online"

Ci-dessous, une copie d’écran pour l’exemple :

clip_image006

Définition du “realm” de SharePoint

La commande PowerShell ci-dessous va permettre la définition du « Realm » de SharePoint :

Set-SPAuthenticationRealm -realm $spocontextID

Ci-dessous, une copie d’écran pour l’exemple :

clip_image007

Configuration d’un proxy d’application pour Azure AD

Enfin, nous allons créer un « Service Application Proxy » pour Windows Azure AD.

New-SPAzureAccessControlServiceApplicationProxy -Name "ACS" -MetadataServiceEndpointUri $metadataEndpoint -DefaultProxyGroup

New-SPTrustedSecurityTokenIssuer -MetadataEndpoint $metadataEndpoint -IsTrustBroker:$true -Name "ACS"

Ci-dessous, une copie d’écran pour l’exemple :

clip_image008

Validation de la création du proxy :

· Dans l’administration centrale de SharePoint, cloquez sur “Security”

· Dans la section « General Security » cliquez sur « Manage Trust »

· Vérifiez qu’une entrée « ACS », ou le nom que vous lui avez donné, existe

image

 

Voici le script complet dans mon environnement :

#region Replace STS Certificate

Add-PSSnapin Microsoft.SharePoint.Powershell

$pfxPath = "C:\Temp\franmerPFX.pfx"

$pfxPass = "Pass@word1"

$stsCertificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $pfxPath, $pfxPass, 20

Set-SPSecurityTokenServiceConfig -ImportSigningCertificate $stsCertificate

certutil -addstore -enterprise -f -v root $stsCertificate

iisreset

net stop SPTimerV4

net start SPTimerV4

#endregion

#region Load Modules

Add-PSSnapin Microsoft.SharePoint.PowerShell

Import-Module Microsoft.PowerShell.Utility

Import-Module MSOnline –force

Import-Module MSOnlineExtended –force

Import-Module Microsoft.Online.SharePoint.PowerShell -force

#endregion

#region log to SharePoint Online

$cred=Get-Credential

Connect-MsolService –Credential $cred

#endregion

#region Définition des variables

$spcn="*.SharePoint.com"

$spsite=Get-Spsite https://ITCampSP1

$site=Get-Spsite $spsite

$spoappid="00000003-0000-0ff1-ce00-000000000000"

$spocontextID = (Get-MsolCompanyInformation).ObjectID

$metadataEndpoint = "https://accounts.accesscontrol.windows.net/" + $spocontextID + "/metadata/json/1"

#endregion

#region Upload STS certificate to SP Online

$cerPath = "C:\Temp\Export_IIS_Franmer.cer"

$cer = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList $pfxPath, $pfxPass

$cer.Import($cerPath)

$binCert = $cer.GetRawCertData()

$credValue = [System.Convert]::ToBase64String($binCert);

#La date de début (StartDate) doit être la date du jour. La date de fin (EndDate) doit être la date d'expiration du certificat STS. Date au format Mois/Jour/Année

New-MsolServicePrincipalCredential -AppPrincipalId $spoappid -Type asymmetric -Usage Verify -Value $credValue -StartDate 10/23/2013 -EndDate 9/27/2014

#endregion

#region Add SPN for the public domain name

$msp = Get-MsolServicePrincipal -AppPrincipalId $spoappid

$spns = $msp.ServicePrincipalNames

$spns.Add("$spoappid/$spcn")

#Modification par rapport à la fiche technet

Set-MsolServicePrincipal -ServicePrincipalNames 00000003-0000-0ff1-ce00-000000000000/*.sharepoint.com -AppPrincipalId $spoappid

#endregion

#region Register the SharePoint Online application principal

$spoappprincipalID = (Get-MsolServicePrincipal -ServicePrincipalName $spoappid).ObjectID

$sponameidentifier = "$spoappprincipalID@$spocontextID"

$appPrincipal = Register-SPAppPrincipal -site $site.rootweb -nameIdentifier $sponameidentifier -displayName "SharePoint Online"

#endregion

#region Set the SharePoint authentication Realm

Set-SPAuthenticationRealm -realm $spocontextID

#endregion

#region Configure On-premises proxy for Azure AD

New-SPAzureAccessControlServiceApplicationProxy -Name "ACS" -MetadataServiceEndpointUri $metadataEndpoint -DefaultProxyGroup

New-SPTrustedSecurityTokenIssuer -MetadataEndpoint $metadataEndpoint -IsTrustBroker:$true -Name "ACS"

#endregion

Au plaisir de vous voir lors d’un IT Camp SQL 2014/Power BI.

Franck Mercier

Pour tester Windows Server 2012, Windows 8, SQL Server 2012, SQL Server 2014 CTP2 et Power BI, vous pouvez télécharger gratuitement la version d’évaluation disponible sous la forme :

Windows Server 2012 :

SQL Server 2012 :

Evaluation SQL Server 2014 CTP2 :

Evaluation Power BI :

Testez Azure gratuitement pendant un mois :

Jeu : Tentez de gagner votre livre numérique !

Tentez de gagner votre livre numérique !

Téléchargez une version d’évaluation gratuite et tentez de gagner votre e-book !

Un gagnants tous les 10 téléchargements.

Windows 8, déploiement et migration
Décelez tout ce qu’il faut savoir sur le déploiement et la migration vers Windows 8.

clip_image003

Il est offert en partenariat avec les éditions EYROLLES, tous les 10 téléchargements d’une version d’évaluation gratuite de Windows Server 2012 R2, ou System Center 2012 R2.