'Map groups to roles in Keycloak when using OIDC

I have Azure AD connected to Keycloak via OpenID Connect. I want to do the following:

  • If user "Romeo" is a member of the group "Montague" in AD, he should have the role "lover" in Keycloak
  • I don't want to import all AD groups and users, users are imported on first login
  • the role "lover" is defined in Keycloak
  • this should work on the realm level and work the same for different clients

All examples I could find only explain how to do this using LDAP.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source