Switching Mattermost users to a new authentication method with mmctl
Use mmctl user migrate-auth when a self-hosted Mattermost already has accounts that sign in with email and the organization now needs SAML, LDAP or another provider. The command changes how existing accounts sign in. The work that decides whether it goes well happens before anything changes: each existing Mattermost user has to be matched to the correct identity in the new provider, so the account keeps its username, profile and message history. Teams usually need this when they move from email login to single sign-on, switch from one identity provider to another, or consolidate accounts after a directory change such as a merger or a domain rename.
What stays the same depends on identity matching. When the user's identity is preserved, channels, posts, files and team memberships stay attached to the same Mattermost account, so history remains readable after the switch. When matching fails, the risk is a duplicate account for the same person, with history left on the old account and the new one starting empty. Before the live run, confirm with your identity provider which attribute will act as the stable identifier, since email addresses and usernames can change and that change affects the match. Also confirm the exact syntax, flags and mapping file format for your Mattermost version in the Mattermost server releases documentation and the mmctl reference for that release.
Plan the migration as a sequence of checks rather than a single command. Export the current user list, build the mapping file from the identifiers the new provider will send, and run the migration in dry run mode first to review which accounts match, which do not and which would collide. Resolve every unmatched or duplicate account with an explicit decision, then rehearse the change on a copy of the production database, with a tested backup in place. Tell users when their next sign-in will use the new provider, and keep the email login path available until you have confirmed that sign-in works for every group. Each of these steps is work your own team or a partner has to schedule and staff, so estimate it against the size of your user base and the number of exceptions you expect.
Migration paths and when each fits
This table compares the three ways to move existing accounts: email to SAML, email to LDAP, and one identity provider to another. Read each row for the identifier that must match, the plan and configuration prerequisites, and the main failure mode, since a wrong mapping usually shows up as duplicate accounts or users who can no longer sign in. Check the plan column against your own contract before you choose a path.
| Migration path | Identifier that must match | Prerequisites | Main risk |
|---|---|---|---|
| Email to SAML | The email or username value the identity provider sends in its assertion must match the existing Mattermost account, so the mapping file pairs each old login with the same identifier | SSO is included from the Professional plan according to the Mattermost pricing page; the SAML provider must be configured and tested in the System Console before any account is switched | Users whose identity provider sends a different email or username end up with a second account, and their message history stays on the old one |
| Email to LDAP | The LDAP ID attribute, which does not change, must be mapped to each account; email alone is not a safe key if addresses changed | AD/LDAP user sync is included from the Professional plan according to the Mattermost pricing page; the directory connection and search filters must work in the System Console | A wrong ID mapping can lock out a user or create a duplicate, and the admin filter may leave some accounts outside the sync scope |
| SAML to LDAP, or LDAP to SAML | The stable identifier in the source provider must be carried into the target provider, typically the immutable directory ID rather than a display name | The target provider must be licensed on your plan and configured in the System Console; test sign-in with a pilot account first | Accounts that were deactivated or are missing from the target directory can be orphaned, and sign-in can silently stop working for those users |
| Provider to provider within SSO | The subject or username claim from the new provider must equal the value previously stored for each user | The new provider must be configured and tested alongside the old one; confirm the plan covers each SSO type you use | Claim changes such as a different username format produce duplicate accounts that split message history |
Running the migration safely in sequence
This sequence moves existing accounts to a new sign-in method in a controlled order, so each change is checked before it reaches every user. The end result is a documented, reviewed migration with a record of what changed and proof that sign-in and message history still work.
Confirm the target provider with a test account
Before touching any production account, sign a test user in through the new provider (SAML, LDAP or the other target) on a staging or test instance of your Mattermost server. Confirm the identity provider returns the attribute you plan to use as the stable identifier, and that the user lands on the expected account. Done means the test user signs in through the new method and the account matches the existing record you expect to keep. Confirm the exact provider setup steps for your version in the Mattermost SAML single sign-on documentation.
Export the current user list with identifiers
Using the Mattermost command line tool, export the active accounts with their usernames, email addresses and internal user IDs, and store the file where the migration owner can edit it. Your identity team should also export the matching list from the new provider, so both sides can be compared. Done means you have one file per source with a row for every account you plan to migrate, and you have counted those rows against your admin console user count to catch gaps.
Build and review the mapping file
Create the mapping file that pairs each existing account with the identifier the new provider will send, such as the email address or the directory ID. Check for duplicates, mismatched case, retired addresses, shared mailboxes and service accounts that should be excluded. Have a second person review the file against the identity provider export. Done means every row has one unique target identifier, the exceptions are listed with a reason, and the reviewer has signed off in your change record.
Run a dry run if your version supports it
Run the migration command in dry run mode if your Mattermost version documents that option for the migrate-auth subcommand. Confirm dry run availability in the docs for your exact version before you rely on it. Review the output for every account it would change and for any account it would skip or fail. Done means the dry run reports no unexpected changes, and every failure has a recorded fix. If your version has no dry run option, use a test instance restored from a recent backup for the same check.
Pilot the change with a small group
Migrate a small pilot group of volunteers or internal staff using the same mapping file and procedure. Ask each pilot user to sign in through the new method, post a message, open an older channel and confirm that their previous messages and files still appear under their name. Done means every pilot user has confirmed sign-in and history, and any problem found has been corrected in the mapping file or in the provider settings before the full run.
Run the live migration in a maintenance window
Schedule the full migration inside an agreed maintenance window, announce it to users with clear instructions on how to sign in afterward, and take a verified backup of the database before starting. Run the migration with the reviewed mapping file and keep the command output as a log. Done means the command finishes with a count of migrated accounts that matches your mapping file, and the log contains no unresolved errors.
Verify sign-in and message history for sample users
After the live run, sign in as a sample of users from each team, department and role, including at least one system administrator, and confirm each one can sign in through the new method. For each sample user, check that prior posts, channel membership and attachments are still attached to the account. Done means the sample passes, the results are recorded in the change ticket, and any user who cannot sign in has been resolved or routed to the support path you defined.
Keeping message history attached to migrated users
The critical requirement for this change is that each migrated account keeps its existing internal user ID. Posts, reactions, channel memberships and direct message threads all reference that internal record, not the email address or the login name people type. If the migration leaves the record intact and only changes how the user authenticates, the history stays attached. If a new account is created instead, the history stays with the old one, and that old account is no longer reachable by its owner.
The failure mode usually appears at first sign-in. A user whose email matches an existing account but whose login method has not been switched can sign in through the new provider and receive a fresh account, because the identity from SAML or LDAP does not match the stored login. The user then sees an empty workspace, while their past messages appear under an orphaned user that nobody can sign in to. Confirm with your identity provider which attribute will serve as the stable identifier, and confirm that the value you map in the migration file matches what that provider sends at login, since a mismatch is the most common cause of duplicate accounts.
Take a full database backup before running any change, and record the state you can verify afterward. Run the migration against a staging copy first and check a sample of users from different teams: their recent posts should still show their name, they should still be members of their channels, and direct messages should still open. Repeat those checks on production after the change, and keep the backup until a sign-in through the new method has been confirmed for every migrated group. Review the exact mmctl syntax and the dry run output in the Mattermost SAML single sign-on documentation and your own version's command reference before you begin.
Security and operational risks during an authentication change
Moving accounts to a new sign-in method changes who can log in, how identities are matched, and what evidence exists afterward. The cards below cover the risks that most often turn a planned switch into an incident, and each one names the check to run before users are moved.
Admin lockout if the new provider fails
If the SAML or LDAP provider rejects logins, the only system administrators who can recover Mattermost may be locked out with it. Before any migration, keep at least one local system admin account with a password that works independently of the new provider, and confirm that you can sign in with it. Test this on a staging server first, and record where the break-glass credentials are stored and who may use them.
SAML SSO docsDuplicate accounts from mismatched identifiers
The migration matches each existing account to an identity in the new provider, usually by email or username. If the values differ in case, use a different domain, or belong to a shared or reassigned address, users can end up with a second account and lose access to their channels and history, or an account can be attached to the wrong person. Compare the mapping file against the provider's directory before the live run and review every unmatched or multiple-match record.
Old passwords and sessions still active
Accounts moved off email login may still hold a password hash, active sessions and personal access tokens. A user or attacker who still has one of these can keep signing in or calling the API after the provider change, and the sign-in path you audit may not be the one that is open. Confirm how the migration treats existing sessions and tokens in your version, revoke them as part of the cutover, and check that deactivated leavers cannot authenticate through any remaining path.
MFA settings that differ by method
Multi-factor authentication is configured for email and LDAP accounts in different ways, and SSO users rely on the identity provider for their second factor. Moving a user from email login to SAML can therefore remove a TOTP requirement that you assumed would continue, or add one that users were not told about. List the MFA policy for each source method, decide which applies after the move, and test a sample account from each group before enforcing it.
Audit records of the change
A change of sign-in method should leave a trail that shows which accounts moved, when, under which administrator, and from which method to which. Without that record, later questions about a suspicious login or a disputed account are hard to answer. Export the Mattermost audit and server logs for the migration window, store them outside the server, and confirm that the log retention you have set covers the period your compliance team needs.
Rollback plan for the cutover
A migration that cannot be reversed turns a failed provider test into a permanent change of identity for every affected user. Write down the state before the change, including a database backup, the list of user IDs and their original auth methods, and the steps to return them, then name who may approve a rollback. Run the rollback on staging so that the procedure is known to work before production depends on it.
Migration flow from export to verified sign-in
The migration starts with an export of current users from the existing server and moves through a mapping file, a dry run that reviewers check, and a small pilot group before the live cutover. Each hand-off is a gate: if sign-in or message history fails verification for the pilot, the flow returns the affected accounts to their previous login method rather than pushing forward. Check the mapping file and dry run output before anyone changes a live account, because the mapping decides which existing user each new identity attaches to.
Phases from user export through pilot, cutover and verification, with rollback on failure.
Questions teams ask before switching authentication methods
What drives the effort of switching Mattermost users to SAML or LDAP?
The effort rises with four things: the number of users, the quality of the identifiers you can match on, how many authentication methods are already in use, and how much testing the change needs. A small group of email-login accounts with clean work emails is a simple match. Thousands of accounts spread across email, GitLab or Google sign-in, with duplicate or changed addresses, need a mapping file that someone must build, check and sign off. Testing adds time because each method needs a dry run against a copy of the data before any live change. Ask your team to count accounts per current method and to check how many email addresses differ from the directory.
Can an internal team switch authentication methods on its own?
An internal team can usually do it if it has administrator access to the Mattermost System Console, a Linux shell with the mmctl command line tool on the server, a directory export it trusts, and a test environment that holds a copy of the user list. The work also needs someone who owns the identity provider settings, because SAML and LDAP values must be correct before any account moves. Plan for a rehearsal on the test tenant, a written rollback plan and a communication to users about the new sign-in screen. If one of these pieces is missing, the gap is usually the identity provider side rather than Mattermost itself.
How long does an authentication method switch take?
Duration depends on scope, not on a fixed rule. The main variables are the number of authentication methods being moved, the number of accounts, whether identifiers need cleaning, how many identity provider configurations must be built, and how long your change approval and user communication take. A single method for a small, clean user base is a short exercise once the identity provider is working. Several providers, duplicate accounts and a formal change window take longer. Ask any partner to show the phases and which of them depend on your own approvals, so the schedule reflects your process.
What should a fixed-scope quote for this work include?
A written quote should list the inputs, the outputs and the responsibilities. Ask for the list of authentication methods in scope, the number of accounts assumed, the identity provider configurations to be built or reviewed, and whether the work covers the mapping file, dry runs, the live migration and a rollback plan. Confirm who supplies the directory export and who approves changes. Also ask for the acceptance criteria, such as which accounts must sign in and which message history must stay attached, and whether a retest or post-change check is included. DeployOpen plans and delivers most engagements as fixed scope with these items agreed in writing before work starts.
Does Mattermost message history survive an authentication method change?
Message history is kept when the same user account is moved to a new sign-in method, because posts belong to the user record rather than to the login. The risk comes when a change creates a new account for the same person, since the old posts stay with the old account. The mmctl user migrate-auth command moves an account between methods using a mapping file, so the key is a correct match between the old and new identifiers. Run a dry run first, check a sample of users who have history, and keep a database backup before the live run. Confirm the exact behavior for your Mattermost version in the official documentation before you rely on it.
Which Mattermost plan do we need for SSO or LDAP sign-in?
According to the Mattermost pricing page, SSO through SAML, OIDC or OAuth and AD/LDAP user sync are included from the Professional plan. High availability clustering and FIPS 140-3 compliance start at the Enterprise plan, and air-gapped deployment is in Enterprise Advanced. Mattermost sells these as prepaid annual subscriptions based on seat licenses and does not publish prices on its pricing page, so ask Mattermost sales for the current figure. Confirm the plan level against your required features before you start, because a switch that depends on a feature your plan lacks will stall.
What is the first technical check before moving accounts?
The first check is whether each identity provider returns a stable, unique identifier for every user, and whether the value in Mattermost matches it. LDAP setups depend on an attribute that does not change, and SAML setups depend on the username and email attributes the provider sends. Export the current Mattermost user list, compare it with the directory, and list every mismatch before you write the mapping file. Mismatches in case, spelling or domain are common causes of failed matches. Keep the export and the mapping file under change control so the dry run and the live run can be compared.
What a fixed-scope authentication migration covers
A fixed-scope migration starts with a current state inventory of every account on the Mattermost server: which users sign in with email, which are already on LDAP or SAML, how many are deactivated, and which have a bot or integration dependency that a login change could affect. The inventory also records the server version, the plan level and whether AD/LDAP sync or SSO is already configured in the System Console, because those settings determine which target methods are available. Ask the partner to name the exact fields it will export and to state how it will handle accounts that share an email address or have inconsistent usernames.
The core technical work is the identity matching analysis and the mapping file design. The analysis decides which attribute will link each existing account to its new identity, usually the email address for email-to-SAML moves and the stable directory identifier for LDAP, and it flags accounts that cannot be matched without manual review. The mapping file, consumed by mmctl user migrate-auth, must be checked against the actual identity provider output before anything runs. Deliverables should include the mapping file, the list of unmatched accounts with a disposition for each, and a dry run report reviewed with your team.
Rehearsal, cutover and handover complete the scope. Rehearsal runs on a non-production Mattermost server restored from a recent copy of the database, so message history attachment can be confirmed before production is touched. The cutover runbook sets the order of steps, the rollback point, the communication to users and who approves each step. Verification checks sign-in through the new method, message history under the migrated accounts and deactivated accounts left untouched, followed by a handover of the runbook and evidence. Engagements are fixed-scope, so scope, deliverables and timelines are agreed in writing before work starts. DeployOpen does not publish a price list, and a quote follows from that written scope. Ask for the named deliverables, the number of rehearsal cycles included and the acceptance criteria for each.
How DeployOpen scopes and delivers this migration
DeployOpen is a Chainscore Labs company that deploys and supports self-hosted open-source platforms inside your own cloud accounts, data centers or air-gapped networks. Auth method switches touch every account, so the scope, the rehearsal and the support model need to be agreed before any user is moved.
Fixed scope agreed in writing
Most engagements are fixed-scope, so the written scope fixes which auth transitions are in play, such as email login to SAML, LDAP, or one SAML provider to another. It should name the Mattermost server version, the number of accounts in each group, and who signs off the mapping file. Ask the quote to separate the mapping work from the cutover window and from any identity provider changes that sit outside Mattermost, because those are often the longest items.
Matching and mapping file review
Before a dry run, DeployOpen reviews how existing accounts will be matched to the new identity and checks the mapping file for duplicates, missing emails and accounts that should not move. Inactive, bot and shared accounts are the usual exceptions. The output is a reviewed list of exact matches, exceptions and decisions owned by your team, so no account is migrated on guesswork.
Dry runs in a rehearsal environment
Each migration is rehearsed on a copy of your production database in an environment you control. Dry runs confirm which accounts would change, that message history stays attached to the same user records, and that login works through the new provider for a sample of pilot users. Failed or unmatched rows are fixed in the mapping and the dry run is repeated until the results match what was agreed.
Backup and rollback planning
Before cutover, you should have a verified database backup and a written rollback path that returns affected users to email login if the new method fails. DeployOpen plans the backup, the rollback steps and the point at which rollback is no longer practical. Confirm with your database team how long a restore takes in your environment, since that sets the window in which rollback is still a real option.
Cutover runbook and communication
The cutover runbook lists each command, the order of batches, the check after each batch and the person who approves the next one. Users receive a notice explaining the new sign-in step, and the help desk gets the same script. Changes to the System Console settings, and any enforced multi-factor authentication, are sequenced so users are not locked out during the switch.
Retainer support after cutover
Ongoing support, upgrades and continuous testing are available as retainers. After cutover, a retainer can cover identity provider changes, Mattermost upgrades that touch authentication, and re-running the matching checks when new accounts arrive from a directory. Ask for the response expectations and the upgrade process in writing, since these determine how quickly a broken login gets fixed.

