[keycloak-user] Listing users with a specific role and group through the admin client on springboot

Vikram vikram.eswar at fleetroute.com
Mon Mar 18 08:19:27 EDT 2019


Does someone have anything on this ?

Regards,

Vikram

On 3/15/2019 3:02 PM, Vikram wrote:
> Hi all,
>
> Versions in use:
>        
>        Springboot version : 2.1.3 FINAL
>
>        Keycloak version : 4.8.2
>
>        Springboot adapter version: 4.8.3 FINAL
>
>        Keycloak admin client 4.8.2 FINAL
>
> So I am trying to get all the users that have a role "customer" and
> belong to a group "group1".
>
> I am using the following code.
>
> RoleResource roleResource = realmResource.roles().get("customer");
> Set<UserRepresentation> customers= roleResource.getRoleUserMembers();
> ArrayList<UserRepresentation> groupCustomers = new ArrayList<UserRepresentation>();
>
> for (UserRepresentation user: customers) {
>           if (user.getGroups().contains("group1") { //error
>               System.out.println("group customer: " + user.getUsername());
>               groupCustomers.add(user);
>            }
> }
>
> However, I get an error when I loop through the user representations to
> read the group names. I do not get the group and roles information. I
> get the username, first name and last name though.. Is it a permission
> issue ? How can I get around it ?
>
> Regards,
> Vikram
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>
>


More information about the keycloak-user mailing list