Matrix LDAP and Active Directory authentication

How to let Matrix users sign in with directory credentials, why the matrix-synapse-ldap3 module is in maintenance and does not work with MAS, and the Dex route the projects recommend.

On this page

Matrix LDAP and Active Directory authentication for your homeserver

If your organization runs or plans a Synapse homeserver and wants staff to sign in with their directory password, the older route is the matrix-synapse-ldap3 password provider, and current Matrix Authentication Service (MAS) deployments use Dex as an LDAP bridge to MAS instead. The matrix-synapse-ldap3 project is a LDAP3 auth provider that lets users log in to Synapse with their LDAP username and password. Its repository says it is in maintenance mode: it receives bug and security fixes but no new features. That makes it a reasonable choice only for an existing Synapse deployment that already depends on it, and it is a poor starting point for a new build.

The reason is the authentication architecture. Synapse's password provider functionality is not compatible with MAS, and MAS does not load Synapse password provider modules. The MAS migration guide states that MAS has no built-in SAML or LDAP upstream providers. So an LDAP or Active Directory backend has to be reached through an OpenID Connect layer. The projects recommend Dex, which sits between MAS and the directory and presents it as an OIDC provider. Before you commit, confirm with your directory team which bind account, search base and group attributes Dex will need, and confirm which of your users are in scope for Matrix access.

Ask your team to answer three questions before any build work begins: whether the homeserver will move to MAS or stay on Synapse with the legacy module, who owns the directory service account and its password rotation, and how long the existing Synapse deployment will keep running the maintenance-mode module. The migration guide is the natural next read on the MAS side, because the account and identifier mapping decisions made here carry into the migration plan.

What you need before connecting Matrix to LDAP or Active Directory

Directory login for Matrix depends on a few prerequisites that are easy to skip and expensive to retrofit. Confirm each one against the current upstream notes for your chosen route, whether that is the matrix-synapse-ldap3 module or Dex in front of Matrix Authentication Service. Treat the version floors below as items to verify, not as settled facts.

Synapse and platform version floors

Confirm the Synapse release you will run and its platform floors before anything else. Upstream notes set minimum PostgreSQL and Python versions for recent releases, and the module must be checked against the Synapse release it targets. Read the upgrade notes for every release between your current version and the target, because rollback can be difficult after schema changes. Do not assume these floors. Confirm them against the current upstream notes.

Synapse upgrade notes

Decide the authentication route first

The LDAP module is in maintenance mode and is not compatible with Matrix Authentication Service. Decide whether you stay on Synapse's password provider or move to MAS with Dex as the LDAP bridge before you build anything. This choice sets the configuration, the migration plan and the user ID handling, so it should be recorded in writing.

MAS migration guide

Read-only directory service account

Create a dedicated bind account in the directory with read access to the user subtree and only the attributes needed for login, such as the username, mail and group membership. Avoid reusing a personal or administrative account. Confirm with the directory team how the password is stored and rotated, and who can see it in the homeserver configuration.

LDAPS or StartTLS certificate trust

Decide between LDAPS and StartTLS and confirm that the homeserver, or Dex, trusts the certificate chain presented by the domain controllers. Certificate mismatches are a common cause of failed binds that look like wrong passwords. Ask the directory team which CA issued the certificates, whether intermediates are included, and how renewal will be handled.

Network paths to the domain controllers

Map the firewall rules from the Synapse host, or the Dex host if you use MAS, to every domain controller that may answer. Confirm the LDAP or LDAPS port is open in both directions where required and that DNS names resolve from the container or VM network. Test from the exact host that will run the service, not from an administrator workstation.

Agreed user ID mapping

Agree in writing how directory attributes become Matrix user IDs, for example which attribute supplies the localpart and how display names are set. Confirm that the server_name matches your deployment and that the mapping cannot produce duplicate or reserved localparts. Changing this later can orphan accounts and rooms, so settle it with the identity owner before the first login.

How a directory login reaches Matrix through Dex and MAS

The sign-in starts in the Matrix client, which sends the user to Matrix Authentication Service (MAS). MAS redirects to Dex, which holds the LDAP or Active Directory connector. Dex sends the bind to the directory, and the password is checked only there, inside the directory network. Dex then returns the identity to MAS, which issues the Matrix user ID and hands the session to Synapse. Check that only Dex can reach the directory, and that the user ID mapping matches your naming rules.

Credentials are checked in the directory network, and the Matrix ID is issued by MAS.

Configuration sequence for Dex with MAS

This sequence moves a Synapse password provider setup to Matrix Authentication Service, with Dex bridging LDAP or Active Directory credentials into MAS. Each step closes with a check, so the team knows the directory login works before any client is switched over.

  1. Inventory the current Synapse password provider

    The Synapse administrator records which password provider modules are loaded, which LDAP settings are in homeserver.yaml, and which accounts currently sign in through the directory. The directory team confirms the attribute that will supply the username, such as uid or sAMAccountName, and the groups that should be allowed to use Matrix. This step is done when the team holds a written list of the active login paths and a sample of directory accounts mapped to their current Matrix IDs. Those IDs are the reference for the matching check in a later step.

  2. Plan the move from Synapse to MAS

    The Synapse owner reviews the migration guide for Matrix Authentication Service before changing anything. The team confirms that MAS has no built-in LDAP or SAML upstream provider and does not run custom Synapse password provider modules, so the directory login must come from Dex. The plan names the MAS and Synapse versions to be tested, the database work needed for MAS, and the owner of each cutover decision. It is done when the owners have signed off on the route in writing and the open questions about user ID mapping are assigned.

  3. Deploy Dex with an LDAP connector

    The identity team deploys Dex in an environment that can reach the domain controllers over the agreed LDAP or LDAPS path. Dex is configured with an LDAP connector that binds with a dedicated read-only service account, limited to the search base and attributes needed for login. The service account password is stored in the secrets system, not in the Dex configuration file. The step is complete when a bind test from the Dex host succeeds with that service account and a test search returns the expected pilot user.

  4. Register Dex as the upstream provider in MAS

    The Synapse administrator adds Dex as an upstream OpenID Connect provider in the MAS configuration, with the issuer, client credentials and redirect URI taken from the Dex client registration. The claim that carries the username is mapped to the localpart of the Matrix ID, following the MAS upstream provider documentation. The MAS service is restarted or reloaded according to the deployment method, and the discovery endpoint is checked from the MAS host. The step is done when MAS shows Dex as an available sign-in option and the discovery check passes.

  5. Test a login with a pilot account

    A small group of pilot users, chosen by the IT team and kept outside any sensitive room, signs in through the Dex option in MAS. The tester confirms that the directory password is accepted, that the session is created, and that the resulting Matrix ID matches the one recorded in the inventory step. Failed attempts are checked against the Dex, MAS and directory logs to find whether the fault is in the bind, the claim mapping or the redirect. The step closes when every pilot account signs in and maps to the expected Matrix ID.

  6. Verify account matching and existing users

    Before wider rollout, the administrator compares accounts that already exist on Synapse with the accounts created through MAS. The goal is to confirm that a directory user does not receive a second Matrix ID, and that rooms, devices and encryption keys tied to the old account remain reachable. Any mismatch is resolved with the migration guidance before the next group of users is added. The step is done when a written comparison shows matching IDs for the sample set and the owner accepts the result.

  7. Cut over clients in waves

    The team moves the remaining users in groups, updating the sign-in path in the client configuration or helpdesk instructions and keeping the previous login route available until the last group is confirmed. Each wave is followed by a check of failed logins in Dex and MAS and a review of support tickets. The Synapse password provider is disabled only after all active users have signed in through MAS and the team has tested rollback steps for the database. The sequence is complete when no user depends on the old password provider and the cutover record is signed by the owners.

How directory attributes map to Matrix user IDs

This table compares each directory attribute you might pass to Matrix with the field it fills, such as the localpart, display name, email or access decision. Read it before the first login test, because the localpart is the value that is hardest to change later. The main takeaway is to choose one immutable identifier and map everything else from attributes that people can edit without creating a new account.

Directory attributeMatrix field it fillsStability and riskDecision to confirm
sAMAccountName or uid (login name)Localpart of the Matrix user ID, such as @localpart:example.comOften reused or renamed when staff change roles; a change later creates a new Matrix accountWhether your directory guarantees uniqueness and how renamed or recycled logins are handled
objectGUID or entryUUID (immutable ID)Stable external identifier used for account matching, if your LDAP module or MAS upstream mapping supports itDesigned to persist for the life of the object, so it survives renamesWhether your chosen integration can key accounts on this value, and how it is stored
mail (email address)Email address on the account, used for notifications and password recovery where enabledEditable and sometimes shared or aliased; not safe as the account keyWhether email must be unique and verified in your directory before it is trusted
displayName or cnMatrix display name shown in rooms and member listsEditable by users and often changed in HR systems; safe to sync on each loginWhether profile changes should overwrite user edits in Matrix
memberOf groupsAccess decisions such as admin rights, room creation or allowed login, applied in the homeserver or upstream provider configGroup membership changes often; mapping a group to admin rights needs a documented reviewWhich group grants administrator access and who approves changes to that group
Account status (disabled or expired)Whether login is refused, enforced by the directory bind or upstream providerMust be checked on every login, or disabled staff keep access to existing sessionsWhether deprovisioning also ends active Matrix sessions and how quickly your team confirms it

Why the ldap3 password provider is a dead end for new MAS deployments

The matrix-synapse-ldap3 module is in maintenance mode. Its repository says it receives bug and security fixes but no new features, and it states that Synapse's password provider functionality is not compatible with Matrix Authentication Service (MAS). For a new deployment, that makes it a poor foundation: you would be building login on a component that the project itself says should be replaced once you move to MAS. Before committing to any LDAP login design, confirm the module's current status in its repository and check whether your Synapse version still loads it without changes.

If you plan to adopt MAS, the consequence is direct. MAS has no built-in LDAP or SAML upstream provider and does not support custom Synapse password provider modules, so a password_providers entry in homeserver.yaml will not carry your directory logins across. Users authenticated only through the ldap3 module will need a different path, normally Dex placed between the directory and MAS, which presents an OpenID Connect interface to MAS. Your migration plan should list every account type, identify which ones depend on the password provider, and test a sample of those accounts through the new flow before cutover. The MAS migration guide sets out the steps the project expects.

If you intend to stay on Synapse alone, the module still works within its maintenance window, but every future Synapse upgrade becomes a compatibility check you carry yourself. Record the module version, the Synapse version it was tested with, and the upgrade notes you reviewed for each release. Ask the team that will run the server whether they can accept an unsupported authentication path over the planned lifetime of the deployment. If the answer is no, the Dex route is the safer starting point, even on Synapse, because it avoids a later forced migration under deadline.

Securing the directory bind and the Matrix login path

The directory account, the transport between Matrix components and the directory, and the login path itself each widen or narrow who can sign in. Work through these controls together, because a read-only bind account on an unencrypted connection still exposes credentials, and a locked-down directory still fails if registration is open.

Least-privilege read-only bind account

Create a dedicated directory account for the bind, with read access only to the users and attributes the login path needs. Do not reuse an administrator account or a personal account. Confirm in your directory's documentation which attributes the account can read by default, and remove any group membership that grants write or password reset rights. Rotate its password on a schedule your directory team can support.

LDAPS or StartTLS with validation

Carry bind credentials over LDAPS or StartTLS, and configure the Matrix component to validate the directory server certificate against your internal certificate authority. Disabling validation to get a connection working hides a broken chain and lets a network attacker read the bind password. Confirm the exact TLS option names in the module and Dex documentation for the version you run, and test a failed certificate on purpose.

Narrow search base and filters

Set the search base to the organizational unit that holds people who should have Matrix accounts, not the whole forest. Pair it with a filter that requires an attribute such as an enabled account flag or a group membership, so disabled, expired and contractor accounts with no business need stay out. Test the filter with accounts from each excluded group, because a broad filter quietly creates accounts you did not plan for.

Protecting Dex and MAS secrets

Dex holds the directory bind password and the client secret it shares with MAS, and MAS holds its own signing and encryption keys. Store these in your secrets manager or as protected files readable only by the service user, not in container images or version-controlled values files. Confirm in the Dex and MAS setup documentation which keys must be generated, how they rotate, and what breaks when a client secret changes.

MAS upstream providers

Limiting who can register accounts

Directory login and open registration are separate switches. If anonymous registration stays enabled in MAS or Synapse, a directory user is not the only way in, and any visitor can create an account. Confirm how registration is disabled in your MAS version and whether directory sign-in still creates accounts for users who were never provisioned. Review the account list against the directory after the first week of go-live.

Logging failed binds and logins

Failed bind attempts, rejected logins and account creations are the first signals of password spraying or a misconfigured bind account. Ship Dex, MAS and Synapse logs to your central logging system, and alert on bursts of failures against one account or from one address. Confirm which events each component logs at its default level and whether failed binds appear in the directory's own audit log, since the two views help different investigators.

Common LDAP login failures and what fixes them

This table lists the login failures teams most often meet when connecting Synapse to a directory, with the likely cause and the fix for each. Read it top to bottom during a first test, and use the cause column to narrow down which layer (TLS, bind, search, mapping or client) is failing before changing settings.

FailureLikely causeFix
Certificate chain errors on LDAPSThe directory certificate is issued by an internal CA that the Synapse host does not trust, or the chain is incomplete, so the TLS handshake fails before any bind is attempted.Install the full internal CA chain in the host trust store, confirm the server name in the certificate matches the configured host, and test the connection from the Synapse host with an LDAP client first.
Bind failures with a service accountThe service account distinguished name (DN) is written in the wrong format, the password is stale, or the account is locked or lacks read rights on the user subtree.Copy the bind DN exactly from the directory, confirm the account can bind with an LDAP client, and grant it read access to the user search base. Check for account lockout after repeated failed attempts.
No users found from a wrong search baseThe search base points at an organizational unit that does not contain the accounts, or the user filter does not match the attribute used for login names.Browse the directory to find the OU that holds the staff accounts, set the search base to that DN, and confirm the filter returns the test user before enabling login.
Duplicate localpartsTwo directory accounts map to the same Matrix localpart after mapping, for example two users whose login names normalize to the same value, so the second account cannot be created cleanly.Decide one unique identifier (often a stable attribute rather than a display name), agree how collisions are resolved, and review the mapping rule on a sample of accounts before rollout.
Users log in but have no Matrix profileThe authentication succeeds, but the display name or profile attributes are missing or not mapped, so the account appears empty or has no usable name in clients.Map the display name attribute in the provider settings, check the attribute exists on the user object in the directory, and set a fallback value so every account has a readable name.
Clients still use the old login flowClients were configured against the previous Synapse login path, or a client cache still holds the old flow, so the password prompt does not reach the directory-backed provider.Update the homeserver address and sign-in method in each client, sign out and back in, and confirm with the project documentation which login flow each client version supports after the migration.

Questions buyers ask about Matrix directory login

Can we still use the matrix-synapse-ldap3 module for LDAP login?

Yes, it still works for existing deployments, but the module is in maintenance mode. Its repository says it receives bug and security fixes but no new features. The same repository states that Synapse's password provider functionality is not compatible with Matrix Authentication Service (MAS), and that deployments should migrate to MAS, using Dex with MAS for an LDAP backend. For a new deployment, plan on MAS and Dex rather than building on the module. Confirm the module's current release status in its repository before you commit to it for a long-lived environment.

What drives the cost of LDAP or Active Directory login for Matrix?

The main cost is the engineering time to connect the directory, the homeserver and the authentication path, and to test it. Cost rises with the number of directory sources, the complexity of group and attribute mapping to Matrix user IDs, whether you are moving from Synapse password providers to MAS, and how many environments need the same setup. Ongoing costs are upgrades to Synapse, MAS and Dex, and support for any custom code. Ask any partner for a quote that separates one-time build work, migration work, testing and recurring support, and that names the directory versions and Matrix components in scope.

How long does Matrix Active Directory integration take?

Duration depends mostly on how complex the directory is and how much of the Matrix deployment has to change. A single forest with clean user objects and one homeserver is a much smaller job than multiple domains, nested groups, disabled-account rules, and a live user base that must keep its accounts and rooms. A migration from an existing Synapse password provider to MAS adds a planned cutover and rollback window. Ask for a timeline tied to a written scope with named directory sources, the number of environments, and the test cases that define done.

Can our internal team set up Matrix LDAP login without a partner?

A team with Matrix, identity and directory experience can do it internally, and the work is well bounded when the scope is small. The team needs someone who can run Synapse and MAS, someone who understands the directory schema and bind accounts, and someone who can operate Dex and the reverse proxy. The gaps usually appear in upgrade planning, the migration of existing accounts, and security review of the bind account and TLS settings. Check those skills against the work before you decide, and consider a partner for the parts your team has not done before.

What do we need from the directory and security teams?

Both teams have to agree on the access model before build work starts. The directory team provides a read-only bind account with the narrowest permissions that work, the base distinguished names for users and groups, the attributes that map to Matrix user IDs and display names, and the rules for disabled or removed accounts. The security team reviews how that bind credential is stored, whether LDAP is protected by TLS, which networks can reach the directory, and how sessions and admin access are logged. Ask both teams to sign off on these items in writing.

Why does Dex work with MAS when the old LDAP module does not?

MAS is an OAuth 2.0 and OpenID provider that takes its upstream identities from OpenID Connect providers. It has no built-in LDAP or SAML upstream, and it does not support custom Synapse password provider modules. Dex sits between the directory and MAS and presents LDAP or SAML sign-in as an OpenID Connect provider, so MAS can use it like any other upstream. The Synapse password provider model is therefore replaced, not extended. Engineers should confirm the Dex connector and version they need against the Dex and MAS documentation before they write the configuration.

What breaks when moving existing Synapse LDAP users to MAS?

The main risk is that user identity changes shape. Accounts created through a Synapse password provider must map to the same Matrix user IDs under MAS, or users lose access to their rooms and history. Check the migration guide for the required steps, test with a copy of production data, and confirm how each account's identifier is derived from the directory. Also plan for active sessions and devices, client re-login, and rollback. Because Synapse database schema changes can make rollback difficult, take and test backups before the cutover.

Does Matrix LDAP login need a compliance review?

Yes, when the directory holds personal data or the homeserver is subject to data protection or sector rules. The review should cover who can sign in, how access is removed when staff leave, where authentication logs go, and how the bind credential is protected. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports, attestations or certifications. Independent auditors and certification bodies perform those assessments, so ask your auditor which evidence they need before the build starts.

How DeployOpen scopes and delivers directory login for Matrix

DeployOpen plans, implements, documents and supports self-hosted open-source platforms inside the client's own infrastructure, so directory login for Matrix is designed around your identity sources and your compliance evidence. We start by choosing the route that fits your Matrix server, whether that is the LDAP3 module on Synapse or Dex in front of Matrix Authentication Service.

How we scope

  • Confirm whether your homeserver runs Synapse with the LDAP3 module or will move to Matrix Authentication Service with Dex.
  • Inventory the directory (LDAP or Active Directory), the attributes used for Matrix IDs, and the groups that control access.
  • Agree deliverables, exclusions and timelines in writing; engagements are fixed-scope, with ongoing support available as a retainer.

How we build

  • Stand up the chosen identity path in a staging environment that mirrors your production Synapse or MAS configuration.
  • Test bind accounts, search filters, account lockout behavior, and how disabled directory users lose access to Matrix.
  • Review secrets handling, TLS to the directory, and admin access settings against your internal security baseline before go-live.

How we hand over

  • Deliver configuration files, a runbook for directory changes, and a record of the decisions made about the authentication route.
  • Walk your identity, platform and security teams through login, logout and account deprovisioning tests with evidence captured.
  • Document the upgrade and rollback considerations for your Synapse or MAS version so your team can plan future changes.

How we support

  • Offer retainers for ongoing maintenance, upgrades and retesting after directory or Matrix version changes.
  • Plan a migration review if the LDAP3 module, which is in maintenance mode, needs to be replaced on an existing deployment.
  • Prepare control evidence for your compliance assessment; independent auditors and certification bodies issue any reports or attestations.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.