This feature is in and subject to change. To share feedback and/or issues, contact Support.
Overview
LDAP authentication in CockroachDB works with LDAP-compatible directory services, including Microsoft Entra ID, Active Directory, and OpenLDAP. Secure LDAPS connectivity over TLS is required. While LDAP configuration is cluster-specific, each request to authenticate a user in CockroachDB is handled by the node that receives it. When LDAP is enabled, the node handles each authentication request using a “search and bind” approach:- Find the user record
- The node connects to the LDAP server using a dedicated directory access account.
- The node searches the directory for a record that matches the authenticating user, using configurable search criteria.
- Authenticate the user
- If a matching record was found, the cluster attempts to verify the user’s identity through another LDAP request, this time using the credentials (username and password) provided by that user.
- If this LDAP bind operation succeeds, the user is authenticated to the CockroachDB cluster.
- Authorize the user (optional)
- If is also enabled, the cluster sends an additional request to retrieve the groups to which the user is assigned, using configurable criteria.
- If group memberships are found, any existing CockroachDB roles that match these group names are assigned to the user.
n nodes, you can expect up to n concurrent LDAP connections.
LDAP authentication cannot be used for the
root user or other . You must manage credentials for root separately using password authentication to ensure continuous administrative access regardless of LDAP availability.Configuration
Prerequisites
- An LDAP-compatible directory service, such as Microsoft Entra ID or Active Directory.
- Network connectivity on port 636 for LDAPS.
- A service account (bind DN) with permissions to search the directory for basic information about users and groups. For example, in Microsoft Entra ID, a service principal with the Directory Readers role.
- The LDAP server’s CA certificate, if using a custom CA not already trusted by the CockroachDB host.
Step 1: Enable redaction of sensitive cluster settings
You will set LDAP bind credentials for the service account that enables this integration using the cluster settingserver.host_based_authentication.configuration. You will also configure the mapping of external identities to CockroachDB SQL users using the cluster settings server.identity_map.configuration.
To redact these two settings, refer to .
Step 2: Configure Host-Based Authentication (HBA)
To enable LDAP, you will need to update the configuration specified in the cluster settingserver.host_based_authentication.configuration.
Set the authentication method for all users and databases to ldap and include the LDAP-specific option parameters:
ldapserver: LDAP server hostnameldapport: LDAP server port (typically 636 for LDAPS)ldapbasedn: Base DN for user searchesldapbinddn: Service account DN for directory searchesldapbindpasswd: Service account passwordldapsearchattribute: Attribute to match against SQL usernamesldapsearchfilter: LDAP filter to restrict valid users
ldapgrouplistfilter. For details, refer to .
Step 3: Configure TLS (Optional)
If, for LDAPS, you are using a certificate signed by a custom Certificate Authority (CA) that is not in the system’s trusted CA store, you will need to configure the CA certificate. This step is only necessary when using certificates signed by your organization’s private CA or other untrusted CA. Set the custom CA certificate:Step 4: Sync database users
Before LDAP authentication can be enabled for a user, you must create the username directly in CockroachDB. You will need to establish an automated method for keeping users in sync with the directory server, creating and dropping them as needed.As of v25.3, CockroachDB can automatically provision users during their first successful LDAP authentication. Refer to the of this page.
sAMAccountName field from the user object. This field name would need to be specified in the HBA configuration using ldapsearchattribute=sAMAccountName.
SQL usernames must comply with CockroachDB’s . Ensure that the values in the field you are using for ldapsearchattribute meet these requirements.
To create a single user:
- Export usernames from the directory server.
-
Produce a
.sqlfile with a statement per user, each on a separate line.If you are not also enabling LDAP Authorization to manage roles and privileges, you can also include one or moreGRANTlines for each user. For example,GRANT developer TO username1orGRANT SELECT ON DATABASE orders TO username2;. -
Run the SQL statements in the :
Connect to a cluster using LDAP
SQL shell connection with LDAP authentication
To connect using LDAP credentials, use your LDAP password:DB Console connection with LDAP authentication
If LDAP authentication is configured, DB Console access will also use this configuration, allowing users to log in with their SQL username and LDAP password. During a login attempt, the system checks if LDAP authentication is configured for the user in the HBA configuration. If so, it validates the credentials against the LDAP server. If LDAP authentication fails or is not configured, the system falls back to password authentication.Authorization (role-based access control) is not applied when logging in to DB Console.
Troubleshooting
Enable to preserve data that will help troubleshoot LDAP issues.Once all functionality is configured and tested successfully, we recommend disabling session logging to conserve system resources.
cockroach-session.log from your .
Potential issues to investigate may pertain to:
- Network connectivity to the LDAP server.
- Incorrect bind DN or password.
- Search filter not matching the intended users.
- TLS certificates.
- Missing or mismatched role names.
Security Considerations
- Always keep a backup authentication method (like password) for administrative users.
- Use LDAPS (LDAP over TLS) in production environments.
- Use a restricted service account for directory searches.
- Regularly audit LDAP group memberships.
- Monitor authentication logs for unusual patterns.

