Login Error in Sitecore CMS via Identity Server with Azure AD Integration

 


Error Message
=========================================================================

You may encounter one of the following two error messages in the browser. Although the messages differ, the root cause is the same.



1. Request Header Too Long error being displayed in the browser.
2.Site Can’t Be Reached


===============================================================================

This error occurs when attempting to log in to Sitecore CMS using the Sitecore Identity Server that is integrated with Azure Active Directory (Azure AD).

===============================================================================

Cause of the error:

The root cause of this issue arises when logging into Sitecore CMS using Azure AD integration via the Sitecore Identity Server.

When you enter your Azure credentials, authentication is successfully completed by Azure AD, and an ID token is returned to Sitecore. This ID token contains claims, including the list of Azure AD groups that the user is associated with.

For most users, the login process works without issues. However, for some users—specifically those who are members of a large number of Azure AD groups—the ID token becomes excessively large due to the inclusion of all group memberships.

As a result, the request header becomes too large, leading to login failures.



Solution:

1. Update the web.config in Sitecore Identity Server

  • Navigate to the Sitecore Identity Server root directory.

  • Open the web.config file.

  • Locate the <system.web> section and add or update the following setting:

<system.web> <httpRuntime maxRequestLength="2097152" /> </system.web>
  • After saving the file, restart the Identity Server application pool and site in IIS.


2. Modify Windows Registry Settings

  • Open the Run window (Win + R), type regedit, and press Enter to open the Registry Editor.

  • Navigate to the following path:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters
  • Select the Parameters folder.

  • Right-click in the right panel and create the following two DWORD (32-bit) Values:

    • MaxFieldLength → set the value to 32768 (Decimal)

    • MaxRequestBytes → set the value to 32768 (Decimal)

💡 These values increase the allowed size for HTTP request headers, which prevents the token size issue for users with many Azure AD group memberships.


3. Restart the Identity Server

  • After completing the above steps, restart the Identity Server to apply the new registry settings.

  • If you skip this step, the new registry keys will not take effect.


⚠️ Important Note

You may find some documentation or solutions suggesting only updating the web.config file, but that alone will not resolve the issue. All three steps above must be completed for the fix to be effective.


Comments

Popular posts from this blog

Solrcloud With Zookeeper -Single server setup

Render Sitecore Experience Forms Using Sitecore XP 10.4 with a Headless Approach (Next.js + JSS SDK)

Next.js with XM Cloud EDGE and GraphQL