Skip to content

fix(ldap): case-insensitive attribute lookup, request login attribute in search#296

Open
allamiro wants to merge 1 commit into
lixmal:masterfrom
allamiro:fix/ldap-attr-case
Open

fix(ldap): case-insensitive attribute lookup, request login attribute in search#296
allamiro wants to merge 1 commit into
lixmal:masterfrom
allamiro:fix/ldap-attr-case

Conversation

@allamiro

@allamiro allamiro commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #292.

Problem

Two related bugs broke LDAP login against OpenLDAP even with correct credentials:

  1. Attribute lookups in the search result were case-sensitive. LDAP attribute names are case-insensitive (RFC 4512 §2.5) and servers return their own canonical casing — OpenLDAP returns cn for a requested CN, so login failed with 'CN attribute not found'.
  2. The user search only requested the CN attribute, so the login attribute (e.g. uid) was never in the result and its lookup failed next ('login attribute uid not found').

Changes

  • get_attr_ci() helper for case-insensitive attribute lookup, used for CN, login attribute, database/keyfile attributes
  • the search now requests the login attribute alongside CN
  • unit test for the case-insensitive lookup

Testing

  • cargo test: 10/10 pass
  • End-to-end against a seeded OpenLDAP 2.6 container (from the compose setup in PR Bump clipboard-polyfill from 2.8.6 to 4.0.1 #4): valid credentials → 200 + session, wrong password → 401 (invalidCredentials from user bind), empty password → rejected

Summary by cubic

Fix LDAP login failures by using case-insensitive attribute lookup and requesting the login attribute in the search. Restores compatibility with OpenLDAP and other servers that return canonical-cased attributes.

  • Bug Fixes
    • Added get_attr_ci() and used it for CN, login, database, and keyfile attributes.
    • Search now requests CN plus the configured login attribute (e.g., uid).
    • Added a unit test for the case-insensitive lookup.

Written for commit 8743667. Summary will update on new commits.

Review in cubic

… in search

LDAP attribute names are case-insensitive (RFC 4512), but servers return
them in their own canonical casing: openldap returns 'cn' for a requested
'CN', so the case-sensitive HashMap lookup failed with 'CN attribute not
found' after successful credential verification.

The search also only requested the CN attribute, so the login attribute
(e.g. uid) was never returned and its lookup failed next.

Verified end-to-end against openldap 2.6: valid credentials log in,
wrong/empty passwords are rejected.
@allamiro allamiro force-pushed the fix/ldap-attr-case branch from 8743667 to a9c9daa Compare June 13, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LDAP login fails against OpenLDAP: attribute lookup is case-sensitive (CN vs cn)

1 participant