Use the instructions in this article to connect your LDAP client to the Secure LDAP service.
Important:
- Be sure to read your vendor documentation
The details in this article for connecting your LDAP client to the Secure LDAP service are for reference only, and are subject to change. In addition to these help instructions, be sure to read your vendor documentation for the most up-to-date steps for connecting your client to the Secure LDAP service. - Before you get started
Before using these instructions, make sure you have already added the client to the Secure LDAP service, configured access permissions, downloaded a client certificate and key, and optionally created access credentials. - Connectivity testing
Optionally, before you begin with these steps, you might want to do a quick connection test using simple tools like ldapsearch, ADSI, and ldp.exe. You can also use these tools for troubleshooting if you encounter errors while trying to connect your LDAP client to the service. For instructions, see Secure LDAP connectivity testing. - How to complete your setup steps
After connecting the LDAP client by following the instructions on this page, you'll need to complete the setup of your LDAP client by switching the service status to On in the Google Admin console. For instructions, see 5. Switch LDAP clients to On.
What's included in this article
This article includes the following sections:
- Basic configuration instructions—Includes generic instructions for connecting LDAP clients that are not specified in this article.
- Configuration instructions for specific LDAP clients—Includes instructions for connecting specific LDAP clients (such as Atlassian Jira or OpenVPN) to the Secure LDAP service. The steps vary depending on the type of client.
- Configuration instructions for Java applications—Includes generic instructions for Java-based applications that offer LDAP functionality.
- Optional: Use stunnel as a proxy—This section includes instructions that specify additional considerations when connecting LDAP clients that don't support digital certificates.
These instructions assume that the client key and cert files that you download are called ldap-client.key and ldap-client.crt.
Basic configuration instructions
This section includes generic instructions for connecting your LDAP client to the Secure LDAP service. If your LDAP client is not listed in the instructions below, be sure to consult the documentation for that application.
Note: Certain LDAP clients such as Atlassian Jira and SSSD perform a user lookup to get more information about a user during user authentication. To make sure user authentication works correctly for such LDAP clients, you'll need to turn on Read user information for all organizational units where Verify user credentials is turned on. (For instructions, see Configure access permissions.)
To connect the LDAP client to the Secure LDAP service:
- Configure your LDAP client with Cloud Directory as your LDAP server.
- Upload the certificate to your LDAP client.
The Secure LDAP service uses TLS client certificates as the primary authentication mechanism. To begin the process of uploading the certificate to the LDAP client, open the LDAP client's authentication or directory settings, and enter the details from the table below.Note: For complete details about how and where to upload TLS certificates, please see your vendor documentation.
Use the following table for basic connection information:
Hostname |
ldap.google.com |
---|---|
Ports |
389 for LDAP with StartTLS enabled |
Base DN |
Your domain in DN format. For example: dc=example,dc=com for example.com |
Username and Password |
In addition to authenticating with a certificate, some LDAP clients require that you enter a username and password. If the username and password fields are not mandatory, you can skip this step. Generate a username and password in the Google Admin console. For instructions, see Generate access credentials. |
Client certificate and key files |
Use the certificate and key file downloaded from the Google Admin console. If the LDAP client doesn’t provide a way to authenticate with a client certificate, see Use stunnel as a proxy. IMPORTANT: Some LDAP clients, such as Apache Directory Studio, don't support the uploading of digital certificates. To address this scenario, see Use stunnel as a proxy. |
Configuration instructions for specific LDAP clients
Configuration instructions for Java applications
Most Java-based applications that offer LDAP functionality can be configured to authenticate with client certificates by installing your client certificates in the application’s keystore. The exact configuration files will differ among applications, but the process is generally similar. Setup requires that OpenSSL and a Java Runtime Environment are installed.
-
Convert the certificate and keys to Java keystore format. You will be prompted for passwords throughout this process. Select a secure password and use the same one through all of the prompts. Assuming your client key file is named ldap-client.key:
If you are in macOS or Linux, use the following commands:
$ openssl pkcs12 -export -out java-application-ldap.pkcs12 -in ldap-client.crt -inkey ldap-client.key
If you are in Windows, use the following commands:$ certutil -mergepfx ldap-client.crt java-application-ldap.pkcs12
Important: The two files (<CERT_FILE>.crt and <CERT_FILE>.key) must be located in the same directory. Also, make sure both key and crt have an identical name (with the two different extensions). In this example, we use the names ldap-client.crt and ldap-client.key.
- Import the certificate into keystore:
$ keytool -v -importkeystore -srckeystore java-application-ldap.pkcs12 -srcstoretype PKCS12 -destkeystore java-application-ldap.jks -deststoretype JKS
- Java properties may be configured in different ways depending on the application. Often, you can set them with the -D option on the “java” command line used to start it. Set the Java properties for your application:
javax.net.ssl.keyStore = /<path-to>/java-application-ldap.jks
javax.net.ssl.keyStorePassword = <password selected above>
- Configure the application’s LDAP connection settings, using the information in Basic configuration instructions.
Optional: Use stunnel as a proxy
For clients that don't offer a way to authenticate to LDAP with a client certificate, use stunnel as a proxy.
Configure stunnel to provide the client certificate to the LDAP server and configure your client to connect to stunnel. Ideally, you'll run stunnel on the same server(s) as your application and only listen locally so that you don't expose your LDAP directory beyond that server.
Follow these steps:
- Install stunnel. For example, on Ubuntu:
$ sudo apt-get install stunnel4
- Create a configuration file /etc/stunnel/google-ldap.conf with the following contents (assuming ldap-client.crt is the cert, and ldap-client.key is the key):
[ldap]
client = yes
accept = 127.0.0.1:1636
connect = ldap.google.com:636
cert = ldap-client.crt
key = ldap-client.key
- To enable stunnel, edit /etc/default/stunnel4 and set ENABLED=1.
- Restart stunnel.
$ sudo /etc/init.d/stunnel4 restart
- Configure your application to point to ldap://127.0.0.1:1636.
You can replace “1636” with any unused port if you also change the accept line in the configuration file above. You'll need to use plaintext LDAP without StartTLS/SSL/TLS enabled between the client and stunnel, since they are communicating locally.
Note: If you choose to run stunnel on a separate server, you must configure your firewalls so that only the necessary applications can access your stunnel server. You can also configure stunnel to listen with TLS so that data between your application and stunnel servers is encrypted. The details of both of these configurations depend on your environment.
Next steps
After you connect the LDAP client to the Secure LDAP service, you then need to switch the service status to On for the LDAP client.
For your next steps, see 5. Switch LDAP clients to On.
Note: If needed, you can use simple tools like ldapsearch, ADSI, or ldp.exe for troubleshooting if you encounter errors while trying to connect your LDAP client to the service. For instructions, see Connectivity testing and troubleshooting.