docs/main/administration-guide/onboard/ad-ldap.mdx
Mattermost offers “Same Sign-On” with Microsoft AD/LDAP (formerly known as Active Directory/LDAP). Enable the same credentials used in on-prem AD/LDAP deployments to be reused in Mattermost, with optional multi-factor authentication.
AD/LDAP is a service that stores authentication and authorization details of users on your organization's network. When you integrate your AD/LDAP system with Mattermost, users can log into Mattermost without having to create new credentials. User accounts are managed in AD/LDAP, and changes are synchronized with Mattermost.
Mattermost provides a step-by-step AD/LDAP setup wizard in the System Console that guides you through the configuration process with sections and incremental testing to ensure each part of your setup works correctly before proceeding to the next step.
Benefits of integrating AD/LDAP with Mattermost include:
If you're using AD/LDAP with nested security groups you need to write a PowerShell script, or similar, to flatten and aggregate the tree into a single security group to map into Mattermost.
We strongly recommend the following as you prepare to set up AD/LDAP:
Attribute Naming and Case Sensitivity:
Essential attributes:
NameID element is required for user identification in SAML assertions.Email, Username, FirstName, and LastName) must be included and correctly mapped.How to choose a stable unique identifier for NameID:
EmployeeID or ObjectGUID) for the NameID helps prevent issues in cases where user details could change over time (e.g., LastName or Email).There are two ways to set up AD/LDAP:
- Log in to your workspace and create a new account using email and password. This is assigned the system admin role as the first user created.
- Next, use the AD/LDAP setup wizard to configure AD/LDAP step-by-step, testing each section as you go, and then convert your system admin account to use the AD/LDAP login method.
- Edit
config.jsonto enable AD/LDAP based on the AD/LDAP settings documentation. When you log in to Mattermost the first user to log in with valid AD/LDAP credentials will be assigned the system admin role.
- Create a new workspace and create an account using email and password, which is automatically assigned the system admin role since it is the first account created. You may also assign the role to another account.
- Go to System Console > Authentication > AD/LDAP to open the AD/LDAP setup wizard. The wizard is organized into sections that you can navigate through using the sidebar:
- Connection Settings: Configure server connection details
- User Filters: Set up user identification and filtering
- Account sync: Map AD/LDAP attributes to Mattermost user fields
- Group Synchronization: Configure group settings and group attributes (if using LDAP groups)
- Sync Performance: Adjust synchronization timing and performance settings
- Sync History: View synchronization status and manually trigger syncs
- Each section includes a test button that allows you to verify your configuration before proceeding to the next step. This incremental testing helps identify and resolve issues early in the setup process.
- After configuring AD/LDAP through the wizard, confirm that users can log in using AD/LDAP credentials.
- Navigate to your profile, and select Security > Sign-in Method > Switch to AD/LDAP and log in with your AD/LDAP credentials to complete the switch.
- Go to System Console > Authentication > Email and set Enable sign-in with email to false and Enable sign-in with username to false.
- Then choose Save to save the changes. This should leave AD/LDAP as the only login option.
<Note>
- Navigate to System Console > Site Configuration > Users and Teams and set Teammate Name Display to Show first and last name. This is recommended for a better user experience.
If you've made a mistake and lock yourself out of the system somehow, you can set an existing account to system admin using the mmctl roles command.
</Note>In addition to configuring AD/LDAP sign-in, you can also configure AD/LDAP synchronization. When synchronizing, Mattermost queries AD/LDAP for relevant account information and updates Mattermost accounts based on changes to attributes (first name, last name, and nickname). When accounts are disabled in AD/LDAP users are deactivated in Mattermost, and their active sessions are revoked once Mattermost synchronizes the updated attributes.
The AD/LDAP synchronization depends on email. Make sure all users on your AD/LDAP server have an email address, or ensure their account is deactivated in Mattermost.
When Mattermost is configured to use AD/LDAP for user authentication, the following user attribute changes can't be made through the API: first name, last name, position, nickname, email, profile picture, or username. LDAP must be the authoritative source for these user attributes.
To configure AD/LDAP synchronization with AD/LDAP sign-in:
<div class="note"> <div class="title">Note
</div>The mmctl ldap sync command takes precedence over this server configuration setting. If you have this setting disabled, and run the mmctl command with the
</div>--include-removed-membersflag, removed members will be re-added during LDAP synchronization.
Using filters assigns roles to specified users on login. To access AD/LDAP filter settings, navigate to System Console > Authentication > AD/LDAP to open the AD/LDAP wizard and go to the User Filters section.
(Optional) Enter an AD/LDAP filter to use when searching for user objects. Only the users selected by the query will be able to access Mattermost. For AD/LDAP, the query to filter out disabled users is (&(objectCategory=Person)(!(UserAccountControl:1.2.840.113556.1.4.803:=2))).
When the user accesses Mattermost, they log in with same username and password that they use for organizational logins.
Filters can also be used for excluding users who belong to certain groups. For AD/LDAP, the query to filter out groups is (&(memberof=cn=ACME_ALL,ou=Users,dc=sademo,dc=com)(!(memberof=cn=DEV_OPS,ou=Users,dc=sademo,dc=com))).
(Optional) When enabled, the Guest Filter in Mattermost identifies external users whose AD/LDAP role is guest and who are invited to join your Mattermost workspace. These users will have the Guest role applied immediately upon first login instead of the default member user role. This eliminates having to manually assign the role in the System Console.
If this filter is removed/changed, active guests will not be promoted to a member and will retain their Guest role. Guests can be promoted in System Console > User Management.
true.When a guest logs in for the first time they are presented with a default landing page until they are added to channels.
See the Guest Accounts documentation for more information about this feature.
(Optional) Enter an AD/LDAP filter to use for designating system admins. The users selected by the query will have access to your Mattermost workspace as system admins. By default, system admins have complete access to the Mattermost System Console. Existing members that are identified by this attribute will be promoted from member to system admin upon next login.
The next login is based upon Session lengths set in System Console > Session Lengths. It is recommended that users are demoted to members manually in System Console > User Management to ensure access is restricted immediately.
If the Admin Filter is set to false, the member's role as system admin is retained. However if this filter is removed/changed, system admins that were promoted via this filter will be demoted to members and won't retain access to the System Console.
When this filter isn't in use, members can be manually promoted/demoted via System Console > User Management.
Organizations using multiple domains can integrate with Mattermost using a "Forest" configuration to bring together multiple domains. Please see Forests as Collections of Domain Controllers that Trust Each Other for more information.
For forest configurations that contain multiple domains which do NOT share a common root, you can search across all of the domains using the Global Catalog. To do so, update your config.json as follows:
See Global Catalog and LDAP Searches for additional details.
The following are frequently asked questions and troubleshooting suggestions on common error messages and issues. It is recommended that you check your logs for errors as they can provide an idea of what the issue is.
Check that your AD/LDAP connection settings are correct by running an AD/LDAP user query in an external system. See LDAP Connection Test Example. If the AD/LDAP connection is verified to be working outside of Mattermost, try the following:
Bind Username format.None. AD/LDAP Port set to 636 typically ties to Connection Security set to TLS).x509: certificate signed by unknown authority in your logs, try installing an intermediate SSL certificate or have your LDAP server send the complete certificate chain.If these options don't work, please contact our support team.
No, each user is created on their first login.
Pending and not complete?Go to System Console > Authentication > AD/LDAP to open the AD/LDAP wizard, navigate to the Connection Settings section, and make sure that the Enable Synchronization with AD/LDAP setting is set to true.
If the issue persists, try selecting the Test Filters button to test that the User Filter is correctly formatted. Refer to this document for guidance on setting a correct syntax format.
Make sure that you also have at least one AD/LDAP user in Mattermost or the synchronization will not complete.
There are three AD/LDAP attributes that apear to be similar but serve a different purpose:
john.smith, a user typing @john will see @john.smith in their autocomplete options and posting a message with @john.smith will send a notification to that user that they’ve been mentioned.ObjectGUID. If a user's ID attribute changes, it will create a new Mattermost account unassociated with their old one. If you need to change this field after users have already logged in, use the mattermost ldap idmigrate mmctl tool.If a user has logged into Mattermost through AD/LDAP or SAML, you can choose how they are deactivated, whether manually or automatically.
There are three main ways to do this:
For AD/LDAP, to filter out deactivated users you must set the user filter to:
(&(objectCategory=Person)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))
Filters can also be used for excluding users who belong to certain groups. For AD/LDAP, the query to filter out groups is:
(&(memberof=cn=ACME_ALL,ou=Users,dc=sademo,dc=com)
(!(memberof=cn=DEV_OPS,ou=Users,dc=sademo,dc=com)))
When a user is deactivated in Mattermost via options one or two above, all the user's current sessions are revoked and they will be unable to log in or access Mattermost.
There is currently no built-in way to connect to multiple AD/LDAP servers. You will need to connect the instances in a forest before connecting to Mattermost. Consider upvoting the feature request on our forum.
AD/LDAP not available on this serverThis indicates that there is a problem somewhere with your configuration. We recommend that you check your Mattermost configuration settings to ensure that AD/LDAP is enabled, and the settings are correct.
If you're still having issues, you can contact support for additional troubleshooting.
User not registered on AD/LDAP serverThis means the query sent back to the AD/LDAP server returned no results. We recommend that you:
If you're still having issues, you can contact Mattermost Support for additional troubleshooting.
If the user can no longer log in to Mattermost with their AD/LDAP credentials - for example, they get an error message An account with that email already exists, or a new Mattermost account is created when they try to log in - this means the ID Attribute for their account has changed.
The issue can be fixed by changing the value of the field used for the ID Attribute back to the old value. If you're currently using a field that sometimes changes for an ID Attribute (e.g. username, email that changes when someone gets married), we recommend you switch to using a non-changing field such as a GUID.
To do this, you can set the Login ID Attribute to whatever you would like users to log in with (e.g. username or email).
<Note>Currently the value is case sensitive. If the ID Attribute is set to the username and the username changes from John.Smith to john.smith, the user will experience problems logging in.
LDAP Result Code 4 "Size Limit Exceeded"This indicates that your AD/LDAP server configuration has a maximum page size set and the query coming from Mattermost is returning a result set in excess of that limit.
To address this issue you can set the max page size in your Mattermost configuration to match the limit on your AD/LDAP server. This will return a sequence of result sets that do not exceed the max page size, rather than returning all results in a single query. A max page size setting of 1500 is recommended.
If the error is still occurring, it is likely that no AD/LDAP users have logged into Mattermost yet. Ensure that at least one AD/LDAP user has logged into Mattermost and re-run the synchronization. The error should disappear at that point.
Missing NameID ElementThis indicates that the AD/LDAP server configuration doesn't include the NameID element in the SAML assertion. The NameID element is required for user identification in SAML assertions. Ensure the NameID is mapped to a unique user identifier, such as the user's email address or another stable attribute that isn't subject to change over time.
Username Attribute is MissingThe Username attribute in the SAML assertion was either missing or is incorrectly named. Verify that all required attributes are included in the SAML assertion. Attribute names are case-sensitive and must match exactly what Mattermost expects. Update the claim rules in AD/LDAP to correctly map LDAP attributes to the expected outgoing claim types, ensuring proper casing (e.g., Username instead of UserName).
Yes it can, but make sure that:
Mattermost provides the status of each AD/LDAP sync job in the Sync History section of the AD/LDAP wizard (System Console > Authentication > AD/LDAP). Here you can see the number of users updated and if the job succeeded or failed.