Fix AD FS Event ID 364 for Office 365 UPN Sign-Ins
Question details
Users need to sign in to federated Office 365 with their user principal names in a multi-forest environment.

- Product
- Microsoft Office 365 and Active Directory Federation Services (AD FS)
- Device & OS
- not provided
- Scenario
- A federated Office 365 deployment uses multiple Active Directory forests, and users from one domain sign in with a UPN.
- Observed behavior
- Affected users receive an incorrect user ID or password error when using a UPN, while the domain\username format works. AD FS logs Event ID 364.
Confirm the affected users' UPNs and identify the actual Active Directory forest or domain names used for lookup. On the AD FS server, review the Event ID 364 details and existing AD AUTHORITY claims provider trust settings before making changes.
Correct the AD FS Alternate Login ID and Lookup Forests
Use this approach when UPN sign-ins fail in a multi-forest deployment but domain\username sign-ins work.
The verified UPN suffix may differ from the actual forest or domain name that AD FS must query. Use the names that correspond to your environment rather than assuming the UPN suffix is the lookup name.
On the AD FS server, open PowerShell with AD FS administrative privileges and run Get-AdfsClaimsProviderTrust | Where-Object { $_.Identifier -contains 'AD AUTHORITY' } | Format-List Name,Identifier,AlternateLoginID,LookupForests. Record the current values before changing them.
In the same PowerShell session, run Set-AdfsClaimsProviderTrust -TargetIdentifier "AD AUTHORITY" -AlternateLoginID userprincipalname -LookupForests domain2.com,domain1.local. Replace the example lookup names with the actual names for your environment.
Run Get-AdfsClaimsProviderTrust | Where-Object { $_.Identifier -contains 'AD AUTHORITY' } | Format-List AlternateLoginID,LookupForests and confirm that the displayed values match the intended configuration.
Open the federated Office 365 sign-in page and have an affected user sign in with their UPN. If it still fails, check the new AD FS Event ID 364 details in Event Viewer and investigate the reported error.

Work with Office Files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with Office files. Its format compatibility helps make migration straightforward, but it does not change or repair Microsoft AD FS authentication.

Frequently Asked Questions
Why can a user sign in with domain\username but not a UPN?
AD FS may be unable to resolve the UPN through its configured alternate login ID or lookup forests. Check AlternateLoginID and LookupForests on the AD AUTHORITY claims provider trust in PowerShell.
Should the lookup forest always match the user's UPN suffix?
No. A verified UPN suffix can differ from the actual forest or domain name used for lookup. Identify the relevant Active Directory names before setting LookupForests.
How do I check the existing AD FS lookup settings?
On the AD FS server, run Get-AdfsClaimsProviderTrust | Where-Object { $_.Identifier -contains 'AD AUTHORITY' } | Format-List AlternateLoginID,LookupForests in PowerShell.
What if Event ID 364 still appears after the change?
Retry the affected UPN sign-in, then open Event Viewer on the AD FS server and inspect the new Event ID 364 details. The event can have causes beyond the lookup configuration, so use its error details to guide further troubleshooting.




