CFanのBlog

A good day for snow-viewing

Exchange Hybrid on-premises OWA/ECP fails OAuth authentication after enabling HMA: The token should have valid permissions or linked account associated with partner application

Translated from the Chinese original by Claude.

The problem

Today I followed How to configure Exchange Server on-premises to use Hybrid Modern Authentication to turn on HMA for OWA, a feature introduced in Exchange Server 2019 CU14. With OAuth configured, the OWA page duly redirected to Microsoft’s sign-in, but I couldn’t actually log in to on-premises OWA: it just kept redirecting back to the sign-in page, endlessly.



The F12 developer tools showed that the token was coming back from Azure AD just fine:

Once that’s POSTed back to OWA, OWA sets an OpenIdConnect.token.v1 cookie:

On the next redirect to OWA, it goes wrong:

which sends it straight back to Microsoft’s sign-in again.

 


Checking the logs

Open Exchange’s logs in

C:\Program Files\Microsoft\Exchange Server\V15\Logging\HttpProxy\Owa

C:\Program Files\Microsoft\Exchange Server\V15\Logging\HttpProxy\Ecp

and you can see the OAuthExtension entries for the two OWA requests above (these are taken from the ECP log):

You can see that after the first, successful V1OpenId authentication it switches to ExchangeSelfIssuedSession, but authenticating the ExchangeSelfIssuedSession fails with the following error

So the crux of the problem is:

  • The on-premises Exchange Partner Application for Exchange Online doesn’t have its LinkedAccount set correctly.

The solution

Check the Partner Application configuration

Run the following command to check the configuration:

Exchange Online’s LinkedAccount turned out to be empty

Set the correct LinkedAccount

What this step does:

  • Binds the Partner Application to the correct on-premises Exchange Online-ApplicationAccount account.
  • Lets Exchange Server handle OAuth authentication properly.

Leave a comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.