Skip to content

LDAP sign-in links accounts by email: directory emails must be unique and admin-controlled #15959

Open

Description

@ChiragAgg5k

Summary

LDAP sign-in (POST /v1/account/sessions/ldap) links a directory entry to an existing account when the entry's email attribute (mail by default) matches that account's email, the same way OAuth2 sign-in trusts a provider's verified email. This is by design: LDAP is configured per project by its owner, who already controls every user in that project.

The trust only holds if the directory's email values are unique and only changeable by directory administrators. Directories don't enforce either by default:

Directory Users can edit their own mail? mail unique?
Active Directory / Samba AD / Entra DS No by default Not enforced
OpenLDAP Only if the ACLs grant broad self-write (common in tutorials) Only with the optional slapo-unique overlay
389 DS / FreeIPA Depends on the ACIs Uniqueness plugin usually covers uid, not mail
Okta / JumpCloud / Google LDAP No (read-only LDAP) Usually, since email is the login

When either assumption breaks, one directory entry can sign in to another person's account:

  • LDAP and Appwrite auth together: an entry whose mail equals an existing email/password user's address is linked to that user's account. If that account's email was unverified, the existing claim path first signs it out everywhere and removes its password, MFA and other identities, as it does for OAuth2.
  • LDAP only: two entries sharing an address. The first sign-in creates the account, and the second entry (no matching identity) is linked to it by email.

Raised by Strix as code scanning alert #4956, dismissed as won't fix because the behaviour is intended.

Direction we are thinking about

No change for now. Options under discussion:

  1. Document the requirement. Email addresses in the directory must be unique and only changeable by administrators.
  2. Make the email attribute optional. Today the LDAP client requires emailAttribute, which defaults to mail. Allowing it to be empty would let a project skip reading emails: accounts are created without one and are never linked by email. The code already handles empty emails: entries without one sign in, and the account's existing email is left alone. The phone attribute is already optional. The change would touch Client.php, the emailAttribute description on PATCH /v1/project/ldap, the console LDAP form (?? instead of || so an empty value sticks), the docs, and the tests that currently expect a blank email attribute to be rejected.
  3. Per-project opt-out of linking by email. Keep reading emails but never use them to link to an existing account. More surface area than (2).

Open question: whether this matters enough for projects that use only LDAP, where the risk is limited to duplicate or self-editable email values in the directory.

🤖 Generated with Claude Code

Activity

  1. added
    product / messaging
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    product / messaging

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions