Skip to content

Keycloak “Can't reset password as account is read only” with LDAP

Identitytested on Keycloak 26.8.1 mit OpenLDAP

For users from LDAP federation, the provider's edit mode decides whether Keycloak writes changes to the directory. With READ_ONLY, password resets and attribute changes fail – that protects the directory.

Symptom

kcadm set-password -r lab --username carla --new-password lab-user-pw-123
kcadm update users/$(uid carla) -r lab -s firstName=Karla
Can't reset password as account is read only
error-user-attribute-read-only

Setting the password and changing the first name fail for a user from LDAP.

Diagnosis

Query the provider's edit mode (shown here after the fix).

kcadm get components/$LID -r lab | jq -r '.config.editMode[0]'
WRITABLE

Causes

READ_ONLYThe provider may not write

With editMode READ_ONLY Keycloak changes nothing in the directory, neither the password nor attributes.

ACLBind user without write rights

Even with WRITABLE, Keycloak's bind user (cn=keycloak in the course) needs write rights in the LDAP ACL.

Fix

Set the edit mode to WRITABLE, set the password and check in the directory: the new password works, the old one no longer does (gesetzt = “set”).
kcadm update components/$LID -r lab -s 'config.editMode=["WRITABLE"]'
kcadm set-password -r lab --username carla --new-password lab-user-pw-123 \
  && echo gesetzt
ldapwhoami -x -H ldap://localhost -D uid=carla,ou=people,dc=notes,dc=lab \
  -w lab-user-pw-123
ldapwhoami -x -H ldap://localhost -D uid=carla,ou=people,dc=notes,dc=lab \
  -w lab-user-pw-789
gesetzt
dn:uid=carla,ou=people,dc=notes,dc=lab
ldap_bind: Invalid credentials (49)

Don't: Do not set WRITABLE for convenience if another system maintains the directory – changes belong there.

▶
Break it yourself and find it – free
Keycloak hands-on, Day 7: LDAP federation – provider, login against the directory, attributes, sync and edit mode.
Go to day 7 →

FAQ

Does a password changed in LDAP take effect immediately?

Yes. Keycloak asks LDAP on every login, without any sync.

What is UNSYNCED?

A third edit mode: changes stay only in Keycloak and are not written to the directory.

Related error patterns

More