User Provisioning
Getting the sample data into Keycloak
Prerequisites
- Serendipity installed and running (the backend including the identity service / Keycloak, and the PWA).
- OpenLDAP running with the
serendipitybackend and theshane-longman.ldifloaded (see the User Provisioning doc's OpenLDAP setup section). - Keycloak's LDAP User Federation configured to connect to the OpenLDAP directory and import/sync the
shane-longmanou=peoplebranch into the Serendipity realm.
Steps
-
Load the LDIF into OpenLDAP. Using the OpenLDAP container from the User Provisioning doc:
docker exec -i serendipity-openldap ldapmodify -x \-H ldap://localhost:389 \-D "cn=admin,dc=shane-longman,dc=org" \-w admin \-a -f backend/services/openldap/ldif/shane-longman.ldifThis loads the
ou=peopleandou=groupsentries and all the sample users (the Shane Longman sample organisation). -
Verify the directory has the users. You can browse with
ldapsearch:ldapsearch -x -H ldap://localhost:389 \-D "cn=admin,dc=shane-longman,dc=org" -w admin \-b "ou=people,dc=shane-longman,dc=org" "(objectClass=inetOrgPerson)" dn cn mail title departmentNumber manager l st descriptionYou should see the sample users with their
manager(LDAP DN),l/st(geographic attributes — alll: Canberra,st: ACT),title,departmentNumber,description(the pre-computed KC sub), and DN. -
In Keycloak's Admin Console, open the Serendipity realm → User Federation → select the LDAP federation provider → Synchronize all users (or Sync changes / Test all users depending on the version) to import the sample users into the realm. The federation mapper maps the LDAP attributes (including
manager,l,st,title,departmentNumber) into Keycloak's user model. -
At import time, the
managerattribute in Keycloak is set to the manager's Keycloaksub(not the LDAP DN). The sample LDIF pre-computes each user's Keycloaksubin the per-userdescriptionattribute, and the import customizes the mapping so that each direct report'smanagerattribute receives the manager'ssub. (See the User Provisioning doc for the resolution approach — Option A: resolve at import time via thedescription-as-sub lookup: read the direct report'smanagerDN, look up the user whose LDAP DN matches that DN, read that user'sdescriptionvalue, and write that UUID into the direct report's Keycloakmanagerattribute.) -
Assign the realm roles (
analyst,consultant,manager,senior-manager,partner,system-administrator) and group memberships (e.g. the Shane Longman dealing-room groups) to the imported users — either via the federation mapper (if configured to map group membership or a custom LDAP attribute into Keycloak roles) or manually in the Admin Console for the sample. -
Export the realm (with the imported users, roles, groups and attributes) to the dev import file so the sample persists across container restarts:
# From the Serendipity backend directory, or via the Keycloak Admin Console's Realm settings → Action → Partial export
Removing sample data
To remove the sample data:
- In Keycloak's Admin Console, delete the sample users from the Serendipity realm (or de-activate them).
- Remove the sample users from the OpenLDAP directory (e.g.
ldapdeletetheuidentries). - If you exported the realm with the sample users, re-export without them (or edit the import file to remove the sample user entries) and re-import.
Extending the sample
To add your own sample users or organisations:
- Add entries to
backend/services/openldap/ldif/shane-longman.ldif(or a new LDIF file) following the same conventions —uid,cn,givenName,sn,mail,title,departmentNumber(theinetOrgPersondepartment attribute — mapped to Keycloak'sdepartmentcustom attribute at federation time),manager(the manager's LDAP DN), thedescriptionattribute carrying the user's pre-computed KCsub(for import-time resolution — the samedescription-as-sub lookup: read the direct report'smanagerDN, look up the manager's entry by DN, read thedescriptionvalue, and write that UUID into the direct report'smanagerattribute), and the geographic attributesl,st(withcnot used on user entries — see the geographic attributes note above), plus the Keycloak role that reflects the user's seniority tier in the firm. - Re-load the LDIF into OpenLDAP and re-synchronize Keycloak's LDAP User Federation.
- Add the corresponding roles and groups.
- Export the realm so the sample persists.
For a production deployment, replace the LDIF / OpenLDAP approach with federation to the enterprise directory (e.g. Microsoft
Entra ID) — see the User Provisioning doc's Enterprise deployment section.
The model stays the same (the manager attribute still holds the manager's Keycloak sub); what changes is where the users
come from and how the manager value is populated.
References
- User Provisioning — the LDIF approach, OpenLDAP setup, Keycloak federation
configuration, and the
manager-as-subattribute model. - Keycloak administration guide — realm and client configuration, realm export/import.
- Access Control design document — the model that drives the
manager-as-subrule, roles, groups, and the geographic-attributes-are-reporting-only stance. - Capital City — TV series (ITV / Euston Films, 1989–1990). The sample organisation's cast names are taken from the series' characters. Wikipedia — Capital City (TV series).