Java 如何在KeyClope中搜索组内的用户?

Java 如何在KeyClope中搜索组内的用户?,java,keycloak,keycloak-rest-api,Java,Keycloak,Keycloak Rest Api,使用KeyClope 11.0.3。 我正在尝试使用KeyClope API搜索组内的用户: List<UserRepresentation> users = realmResource.users().search(username, firstname, lastname, email, 0, 100); List users=realmResource.users().search(用户名、姓氏、姓氏、电子邮件、, 0, 100); 但当我尝试获取已找到用户的组时

使用KeyClope 11.0.3。 我正在尝试使用KeyClope API搜索组内的用户:

List<UserRepresentation>  users = realmResource.users().search(username, firstname, lastname, email,
    0, 100);
List users=realmResource.users().search(用户名、姓氏、姓氏、电子邮件、,
0, 100);
但当我尝试获取已找到用户的组时,即使用户有组,我也会得到null:

List<String> groups = users.get(0).getGroups(); //It's null
List groups=users.get(0.getGroups()//它是空的

那么如何在组内搜索用户?

要获取用户所属的组,请尝试以下操作:

realm.users().get(userId).groups();
realm.groups().group(groupId).members();
改用用户ID

要获取给定组的用户,请执行以下操作:

realm.users().get(userId).groups();
realm.groups().group(groupId).members();