By default, the session lifetime is 24 hours for all Dynamics 365 Customer Engagement (on-premises) clients. You can change the session lifetime by setting the SessionSecurityTokenLifetimeInHours setting to a different value.
Requirements
- To set up the Dynamics 365 Customer Engagement (on-premises) PowerShell cmdlets, see Get started using the Dynamics 365 Customer Engagement Management (on-premises) PowerShell cmdlets.
- To change the session lifetime the deployment must be enabled for claims-based authentication.
Demonstrates
You can use the following script to increase the session lifetime timeout to 48 hours.
Example
$RemoveSnapInWhenDone = $False
if (-not (Get-PSSnapin -Name Microsoft.Crm.PowerShell -ErrorAction SilentlyContinue))
{
Add-PSSnapin Microsoft.Crm.PowerShell
$RemoveSnapInWhenDone = $True
}
$OathClaimsSettings = Get-CrmSetting -SettingType OAuthClaimsSettings
#display current setting
$OathClaimsSettings
$OathClaimsSettings.SessionSecurityTokenLifetimeInHours = 48
Set-CrmSetting $OathClaimsSettings
#display new setting
$OathClaimsSettings
if($RemoveSnapInWhenDone)
{
Remove-PSSnapin Microsoft.Crm.PowerShell
}
Important
- After you run the script run IISRESET on the Dynamics 365 Server running the Web Application server role. Additionally, clients must sign out and then sign in for the new setting to take effect.