Skip to content

Commit 90fb064

Browse files
Merge pull request #218242 from Yvand/yvand/update-sps-aad-saml11
Add a chapter to article SharePoint - AAD to customize token lifetime
2 parents 32a26df + 24746fa commit 90fb064

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

articles/active-directory/saas-apps/sharepoint-on-premises-tutorial.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.service: active-directory
99
ms.subservice: saas-app-tutorial
1010
ms.workload: identity
1111
ms.topic: tutorial
12-
ms.date: 03/31/2021
12+
ms.date: 11/14/2022
1313
ms.author: jeedes
1414
---
1515
# Tutorial: Implement federated authentication between Azure Active Directory and SharePoint on-premises
@@ -343,4 +343,38 @@ $t.Update()
343343

344344
1. In the section **Reply URL (Assertion Consumer Service URL)**, add the URL (for example, `https://otherwebapp.contoso.local/`) of all additional web applications that need to sign in users with Azure Active Directory and click **Save**.
345345

346-
![Specify additional web applications](./media/sharepoint-on-premises-tutorial/azure-active-directory-app-reply-urls.png)
346+
![Specify additional web applications](./media/sharepoint-on-premises-tutorial/azure-active-directory-app-reply-urls.png)
347+
348+
### Configure the lifetime of the security token
349+
350+
By default, Azure AD creates a SAML token that is valid for 1 hour.
351+
This lifetime cannot be customized in the Azure portal, or using a conditional access policy, but it can be done by creating a [custom token lifetime policy](../develop/active-directory-configurable-token-lifetimes.md) and apply it to the enterprise application created for SharePoint.
352+
To do this, complete the steps below using Windows PowerShell (at the time of this writing, AzureADPreview v2.0.2.149 does not work with PowerShell Core):
353+
354+
1. Install the module [AzureADPreview](https://www.powershellgallery.com/packages/AzureADPreview/):
355+
356+
```powershell
357+
Install-Module -Name AzureADPreview -Scope CurrentUser
358+
```
359+
360+
1. Run `Connect-AzureAD` to sign-in as a tenant administrator.
361+
362+
1. Run the sample script below to update the application `SharePoint corporate farm` to issue a SAML token valid for 6h (value `06:00:00` of property `AccessTokenLifetime`):
363+
364+
```powershell
365+
$appDisplayName = "SharePoint corporate farm"
366+
367+
$sp = Get-AzureADServicePrincipal -Filter "DisplayName eq '$appDisplayName'"
368+
$oldPolicy = Get-AzureADServicePrincipalPolicy -Id $sp.ObjectId | ?{$_.Type -eq "TokenLifetimePolicy"}
369+
if ($null -ne $oldPolicy) {
370+
# There can be only 1 TokenLifetimePolicy associated to the service principal (or 0, as by default)
371+
Remove-AzureADServicePrincipalPolicy -Id $sp.ObjectId -PolicyId $oldPolicy.Id
372+
}
373+
374+
# Create a custom TokenLifetimePolicy in Azure AD and add it to the service principal
375+
$policy = New-AzureADPolicy -Definition @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"06:00:00"}}') -DisplayName "Custom token lifetime policy" -IsOrganizationDefault $false -Type "TokenLifetimePolicy"
376+
Add-AzureADServicePrincipalPolicy -Id $sp.ObjectId -RefObjectId $policy.Id
377+
```
378+
379+
After the script completed, all users who successfully sign-in to the enterprise application will get a SAML 1.1 token valid for 6h in SharePoint.
380+
To revert the change, simply remove the custom `TokenLifetimePolicy` object from the service principal, as done at the beginning of the script.

0 commit comments

Comments
 (0)