Keycloak-获取所有映射到角色的用户 [英] Keycloak - Get all Users mapped to roles

查看:560
本文介绍了Keycloak-获取所有映射到角色的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道keycloak在api下面已经暴露了,

I know keycloak has exposed below api,

<dependency>
    <groupId>org.keycloak</groupId>
    <artifactId>keycloak-services</artifactId>
    <version>2.0.0.Final</version>
</dependency>

此处.我在这里找不到所需的api,以获取具有映射到他们的特定角色的所有用户.

With complete documentation here. I cannot find the required api here to fetch all users with specific role mapped to them.

问题说明-我需要从keycloak服务器中挑选所有具有特定角色的用户.我需要向角色映射到所有用户的所有用户发送电子邮件.

Problem Statement - I need to pick all users from keycloak server who have a specific role. I need to send email to all users with role mapped to them.

推荐答案

有一个出色的功能请求通过API来请求此功能.

There is an outstanding feature request asking for this function via the API.

同时,如果您的要求是一次性的,则可以通过查询将KEYCLOAK_ROLE和USER_ROLE_MAPPING连接到USER_ENTITY的数据库来查询用户名(或电子邮件地址)

In the meantime if your requirement is once-off you could obtain the user names (or email addresses) by interrogating the database joining KEYCLOAK_ROLE to USER_ROLE_MAPPING to USER_ENTITY

类似的东西:

SELECT username
FROM keycloak_role kr 
   JOIN user_role_mapping rm ON kr.id = rm.role_id
   JOIN user_entity ue ON rm.user_id = ue.id
WHERE kr.name = 'your_role_name';

这篇关于Keycloak-获取所有映射到角色的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆