[keycloak-dev] EventListener plugin: retrieving synced users

Paul Edison paul.finnedison at outlook.com
Thu Aug 15 18:24:38 EDT 2019


Hi,

I’m trying to write a plugin for Keycloak that should work (“export”) with the data of users that get freshly created or imported.
Currently writing it as a EventListerner Plugin that acts on adminEvents.

If a user is created in Keycloak itself in the local store this works fine.
With the event I get the "resourcePath=users/0958198e-7a5d-4fb3-9b1b-2481841bff3f"
and with that I can access the user:
> UserModel user = session.users().getUserById(<ID>, session.getContext().getRealm());


Thats fine – but with federation I got problems.
In the event of synchronisation I don’t get this information.

I only get the "resourcePath=user-storage/381a8a65-c425-487e-b14a-a1186fda5940/sync"
How would I get the users form that info?

Is there a way to get form the session the list of synced users form that ID? Where is the information stored with that ID?
I would need to know which users are new created an which are just updated.
A compelte list could be obtained from:
> List<UserModel> listLocalStoredUsers = session.userLocalStorage().getUsers(session.getContext().getRealm())
But that woudl always get me a big list that is always growing.

Kind regards,
Paul


More information about the keycloak-dev mailing list