.. _ldap-setup: ***************************************************************** Setting up LDAP authentication and authorization using NativeLDAP ***************************************************************** This document describes an example configuration of LDAP authentication and authorization using direct binding to an LDAP server (Native LDAP). We recommend testing this setup in a non-production environment first, before applying it in production. Assumptions =========== 1. The setup of an LDAP server is out of scope of this document. We assume that you are familiar with the LDAP server schema. 2. You have the LDAP server up and running and it is accessible to the servers with Percona Server for MongoDB installed. 3. This document primarily focuses on OpenLDAP used as the LDAP server and the examples are given based on the OpenLDAP format. If you are using Active Directory, refer to the :ref:`active-directory` section. 4. You must place both |PSMDB| and the LDAP servers behind the firewall as the communications between them will be in plain text. 5. You have the ``sudo`` privilege to the server with the Percona Server for MongoDB installed. Prerequisites ============= * In this setup we use anonymous binds to the LDAP server. If your LDAP server disallows anonymous binds, create the user that |PSMDB| will use to connect to and query the LDAP server. Define this user's credentials for the ``security.ldap.bind.queryUser`` and ``security.ldap.bind.queryPassword`` parameters in the ``mongod.conf`` configuration file. * In this setup, we use the following OpenLDAP groups: .. code-block:: text dn: cn=testusers,dc=percona,dc=com objectClass: groupOfNames cn: testusers member: cn=alice,dc=percona,dc=com dn: cn=otherusers,dc=percona,dc=com objectClass: groupOfNames cn: otherusers member: cn=bob,dc=percona,dc=com Setup procedure =================== Configure TLS/SSL connection for |PSMDB| ----------------------------------------- By default, |PSMDB| establishes the TLS connection when binding to the LDAP server and thus, it requires access to the LDAP :abbr:`CA (Certified Authority)` certificates. To make |PSMDB| aware of the certificates, do the following: 1. Place the certificate in the ``certs`` directory. The path to the ``certs`` directory is: - On Debian / Ubuntu: ``/etc/ssl/certs/`` - On RHEL / CentOS: ``/etc/openldap/certs/`` 2. Specify the path to the certificates in the ``ldap.conf`` file: .. tabs:: .. tab:: Debian / Ubuntu .. code-block:: bash tee -a /etc/openldap/ldap.conf <`_ by Igor Solodovnikov - `Authenticate Percona Server for MongoDB Users via Native LDAP `_ by Ivan Groenewold .. include:: .res/replace.txt