8000 LDAP failover regression since 26.6.0 · Issue #55322 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

LDAP failover regression since 26.6.0 #55322

Done

Description

@NedimPopovac

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

ldap

Bug Description

Problem
Since Keycloak 26.6.0 (#15253, forced password change for LDAP federated users), LDAP user login no longer fails over to the next server of a multi-URL Connection URL (e.g. ldap://ldap1:389 ldap://ldap2:389) when the primary accepts TCP but hangs or fails on the bind (degraded AD, docker pause, …). Login fails with LDAP response read timed out instead of using the replica. 26.5 failed over correctly.

Root cause
LDAPOperationManager.authenticate() creates the InitialLdapContext without credentials and binds afterwards via addToEnvironment(SECURITY_*) + reconnect(getControls()).

JDK JNDI (LdapCtxFactory.getUsingURLs) only iterates over the URL list during initial context creation: it tries the next URL for any NamingException (incl. read timeouts) and only rethrows AuthenticationException immediately. With LDAPv3 and no credentials no bind is sent during creation, so the first host that accepts TCP is selected; reconnect() then re-binds on that already-selected host and never tries other URLs.

The admin/bind-account connection (LDAPContextManager) already binds via the initial environment when StartTLS is off, so only the user-authentication path is affected. No configuration option works around it (Enable LDAP password policy only toggles the request control).

Version

26.7.5

Regression

  • The issue is a regression

Expected behavior

When the LDAP federation provider is configured with multiple space-separated URLs in Connection URL (e.g. ldap://ldap1:389 ldap://ldap2:389) and the first server accepts TCP connections but hangs or fails on the bind (e.g. a degraded server), LDAP user login should fail over to the next URL and succeed against the replica. This is how Keycloak 26.5 and earlier behaved.

Authentication should only fail if all configured servers fail. Invalid credentials on any server should still return an authentication failure, and the password policy / forced password change flow (changeAfterReset) should keep working after failover.

Actual behavior

Since 26.6.0 (forced password change for LDAP users, #keycloak/keycloak#15253), login fails with LDAP response read timed out and the second URL is never tried. LDAPOperationManager.authenticate() creates the InitialLdapContext without credentials and binds afterwards via reconnect(). JNDI only iterates over the URL list during initial context creation, so the first host that accepts TCP is selected and the bind never fails over.

How to Reproduce?

  1. Configure an LDAP provider with ldap://ldap1:389 ldap://ldap2:389.
  2. Make ldap1 accept TCP but not respond (e.g. docker pause ldap1).
  3. Log in as an LDAP user.
  4. Result: login fails with LDAP response read timed out. On 26.5 it succeeds via ldap2

Anything else?

No response

Activity

  1. added theissue type on Nov 18, 2026
  2. added
    kind/bug
    on Nov 18, 2026
  3. added
    area/ldap
    on Nov 18, 2026
  4. added a commit that references this issue on Nov 18, 2026
    1d266e0
  5. self-assigned this
    on Nov 19, 2026
  6. added
    priority/blocker
    and removed on Nov 19, 2026
  7. tkyjovsk commented on Nov 20, 2026

    @tkyjovsk
    Contributor

    Confirmed on Keycloak 26.8.2 with JDK 21, StartTLS disabled, 3000 ms connect/read timeouts, and two OpenLDAP servers populated through syncrepl with matching user UUIDs. With the primary paused, service-account lookup succeeds through the replica, but LDAP traces show the user bind going only to the primary and timing out; login returns invalid_grant. The same test succeeds on 26.5.0, where the trace shows the user bind falling back to the replica. On 26.8.2, listing the replica first or refusing the primary TCP connection restores successful login, invalid passwords remain rejected, and enabling LDAP password policy does not change the stalled-bind failure.

  8. removed their assignment
    on Nov 20, 2026
  9. added 4 commits that reference this issue on Nov 30, 2026
    d47094f
    3f3952d
    ba73b3f
    3db6720
  10. added a commit that references this issue on Dec 4, 2026
    4329882
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/ldapbackport/26.6backport/26.8kind/bugpriority/blockerrelease/27.0.0team/core-iam

Type

Fields

No fields configured for bug.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

0