Configure MongoDB with Kerberos Authentication and Active Directory Authorization
New in version 3.4: MongoDB Enterprise supports querying an LDAP server for the LDAP groups to which an authenticated user belongs. MongoDB maps the LDAP distinguished names (DN) of each returned group to roles on the
admin database. MongoDB authorizes the user based on the mapped roles and their associated privileges. See LDAP Authorization for more information.
MongoDB Enterprise supports authentication using a Kerberos service. Kerberos is an industry standard authentication protocol for large client/server systems.
This tutorial describes how to configuring MongoDB to perform authentication through a Kerberos server and authorization through an Active Directory (AD) server via the platform libraries.
Thoroughly familiarize yourself with the following subjects before proceeding:
A full description of AD is beyond the scope of this tutorial. This tutorial assumes prior knowledge of AD.
MongoDB supports using SASL mechanisms for binding between the MongoDB server and AD. A full description of SASL, SASL mechanisms, or the specific AD configuration requirements for a given SASL mechanism are beyond the scope of this tutorial. This tutorial assumes prior knowledge of SASL and its related subject matter.
Setting up and configuring a Kerberos deployment is beyond the scope of this document. This tutorial assumes you have configured a Kerberos service principal for each
mongos instance in your MongoDB deployment, and you have a valid keytab file for for each
For replica sets and sharded clusters, ensure that your configuration uses fully qualified domain names (FQDN) rather than IP addresses or unqualified hostnames. You must use the FQDN for GSSAPI to correctly resolve the Kerberos realms and allow you to connect.
In the output from this command, look for the string
modules: subscription or
modules: enterprise to confirm your system has MongoDB Enterprise.
This tutorial explains configuring MongoDB for Kerberos authentication and AD authorization.
To perform this procedure on your own MongoDB server, you must modify the given procedures with respect to your own specific infrastructure, especially Kerberos configurations, constructing AD queries, or managing users.
By default, MongoDB creates a TLS/SSL connection when binding to the AD server. This requires configuring the host of the MongoDB server to have access to the AD server’s Certificate Authority (CA) certificates.
This tutorial provides instructions for the required host configurations.
This tutorial assumes you have access to the AD server’s CA certificates and can create a copy of the certificates on the MongoDB server.
This tutorial uses the following example AD objects as the basis for the provided queries, configurations, and output. Each object shows only a subset of the possible attributes.
This tutorial uses a username and password for performing queries on the AD server. The credentials provided must have sufficient privileges on the AD server for supporting queries related to
MongoDB LDAP authorization requires every
mongod in the replica set to be on at least MongoDB 3.4.0 or later.
On Linux, specify the AD server’s CA certificates via the
TLS_CACERTDIR option in the
Your platform’s package manager creates the
ldap.conf file while installing MongoDB Enterprise’s
libldap dependency. For complete documentation on the configuration file or the referenced options, see ldap.conf .
On Microsoft Windows, load the AD server’s Certificate Authority (CA) certificates with the platform’s credential management tool. The exact credential management tool is Windows version dependent. To use the tool, refer to its documentation for your version of Windows.
none to disable TLS/SSL.
none transmits plaintext information, including user credentials, between MongoDB and the AD server.
For MongoDB servers running on the Windows operating system, you must use setspn.exe to assign the service principal name (SPN) to the account running the MongoDB service.
Windows Server 2003 does not support
setspn.exe -S. For complete documentation on
setspn.exe, see setspn.exe .
For MongoDB servers running on the Linux platform, you must ensure the server has a copy of the keytab file specific to the MongoDB instance running on that server.
You must grant the Linux user running the MongoDB service read permissions on the keytab file. Take note of the full path of the keytab file location.
If your MongoDB server currently enforces authentication, you must authenticate to the
admin database as a user with role management privileges, such as those provided by
userAdminAnyDatabase. Include the appropriate