Share via

"An unexpected error occurred while trying to validate user" while creating role in PostgreSQL Single Server with a service account

Frédéric Poliquin 0 Reputation points
2023-09-21T19:17:45.9333333+00:00

I'm trying to write a batch that will synchronize Azure Postgresql users with an external source. The batch fails when calling:

create role "${username}" with login in role azure_ad_user

The error is :

An unexpected error occurred while trying to validate user.

Everything works if I use my own personal account. It only fails when I try to use a service account.

The service account is a member of the AAD Admin group and has been granted the "Directory.Read.All" permission.

The service account is able to drop users so it clearly has admin rights. I can confirm that the token contains the object id of the AAD Admin group.

I've tried with :

SET aad_validate_oids_in_tenant = off;

But it doesn't work.

Any help is appreciated !

Thank you

Azure Database for PostgreSQL

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.