Error Details
| Fact | Value | Source | Note |
|---|
| Exact error string | AADSTS500021 | Authentication logs | -> Tenant restriction policy |
| OS build range | Windows 11 22H2 | System information | -> Affected OS version |
| Relevant registry key or OMA-URI | None applicable | Registry editor | -> Not relevant here |
| Service/endpoint URL | https://login.microsoftonline.com | Network logs | -> Azure AD endpoint |
| Log line signature | AADSTS500021 - Tenant restriction policy | AzureADConnect logs | -> Log file reference |
Log Files to Check
C:\Program Files\Microsoft Azure AD Sync\Logs\AzureADConnect.loghttps://portal.azure.com/en-us/signin-logs
What This Error Actually Means
The error code AADSTS500021 indicates that a tenant restriction policy has blocked authentication to external tenant resources. This specific error is generated by Azure Active Directory (Azure AD) during the authentication process when attempting to access resources in another tenant. The error occurs because the tenant's configured policies prevent cross-tenant authentication, either due to an overly restrictive configuration or a misconfigured application registration.
The component responsible for raising this error is the Azure AD authentication service, specifically when it evaluates tenant restriction policies during token issuance. These policies are designed to control access between tenants and ensure compliance with organizational security standards.
Affected Versions and Scope
This issue affects Windows 11 22H2 systems enrolled in Entra ID (formerly Azure AD) where tenant restriction policies have been configured. It impacts users attempting to authenticate to external tenant resources, such as accessing a SharePoint site or an application hosted in another tenant. The error does not affect internal tenant resources or scenarios where cross-tenant access is explicitly allowed.
The scope of this issue depends on the tenant's configuration and the specific restrictions applied. Tenants with strict cross-tenant policies are more likely to encounter this error, while those with permissive configurations may not experience it at all.
Where To Look First: Logs and Event IDs
To diagnose this issue, examine the following log files:
1. **Azure AD Connect Log**: Located at
C:\Program Files\Microsoft Azure AD Sync\Logs\AzureADConnect.log. Search for the exact log line containing "AADSTS500021 - Tenant restriction policy".
2. **Azure Portal Sign-In Logs**: Accessible via
https://portal.azure.com/en-us/signin-logs. Look for failed sign-in attempts with the error code AADSTS500021.
Additionally, review Windows Event Viewer logs on affected devices:
- Open Event Viewer and navigate to
Windows Logs > Application.
- Search for events with ID 4738 (Audit Logon) and 4769 (Special Logon).
These logs will help identify the specific resource or application causing the authentication failure.
Root Causes
1. Tenant Restriction Policy Misconfiguration
The most common cause is an overly restrictive tenant restriction policy configured in Entra ID. These policies control cross-tenant access and may inadvertently block legitimate authentication attempts. To identify this issue, check the tenant's policy settings in the Azure portal.
2. Application Registration Issues
Another possible cause is a misconfigured application registration in Azure AD. Applications requiring cross-tenant access must be properly registered and granted the necessary permissions. Verify that the application's manifest includes the correct
allowedTenants setting.
3. Token Issuance Errors
In some cases, token issuance may fail due to issues with the Azure AD token service. This can occur if the tenant's configuration prevents token generation for external resources. Review the Azure AD Connect logs for additional details.
Fix Procedure
To resolve this issue, follow these steps:
- Check Tenant Restriction Policies:
Open the Azure portal and navigate to
Entra admin center > Identity > Enterprise applications > Tenant restriction policies. Review each policy to ensure they do not inadvertently block legitimate cross-tenant access.
- Modify Application Registration:
If an application is misconfigured, update its registration. Use the following PowerShell cmdlet to retrieve and modify the application's manifest:
Get-AzADApplication -ObjectId [application-object-id] | Edit-AzADApplication
- Verify Token Issuance:
Ensure that token issuance is not being blocked by tenant policies. Use the following cmdlet to check the current tenant configuration:
Get-MgOrganization -Property crossTenantAccessPolicy
- Test Authentication:
After making changes, test authentication to external resources. Monitor logs for successful sign-in attempts and ensure no further errors occur.
**Warning:** Modifying tenant restriction policies can affect enrolled devices. Always test changes in a controlled environment before applying them broadly.
- Review Event Logs:
Use the following PowerShell cmdlet to review relevant event logs:
Get-WinEvent -LogName "Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin" -MaxEvents 50
Error Code Variants
| Error Code |
Description |
Distinctive Feature |
| AADSTS500021 |
Tenant restriction policy prevents authentication to external tenant resources. |
Mentions "Tenant restriction policy" in the error message. |
| AADSTS500022 |
Insufficient privileges to access the resource. |
Indicates a permission issue rather than a tenant restriction. |
| AADSTS500023 |
Resource not found or unauthorized access. |
Mentions "Resource not found" in the error message. |
Verification
To verify the fix, check for successful authentication attempts in the Azure portal sign-in logs. Look for entries with a status of "Success" and ensure that no further AADSTS500021 errors occur. Additionally, review the Azure AD Connect logs for confirmation that cross-tenant access is now permitted.
Prevention
To prevent recurrence, implement the following measures:
1. Regularly audit tenant restriction policies to ensure they align with organizational security requirements.
2. Monitor application registrations and update them as needed to reflect changes in cross-tenant access requirements.
3. Use the following PowerShell cmdlet to set up monitoring for policy changes:
Set-MgSubscription -NotificationSettings @{"Enabled" = $true; "EventTypes" = @("PolicyChange")}
By following these steps, you can resolve the AADSTS500021 error and ensure smooth cross-tenant authentication in your Entra ID environment.
**Tip:** Use the dsregcmd /status command to quickly check device enrollment status and identify potential issues before they escalate.