Configuring LDAP connection

Configure an LDAP (Lightweight Directory Access Protocol) connection for your IBM® Cloud Private cluster.

You must connect an LDAP directory with your IBM Cloud Private cluster. You can then add users from your LDAP directory into your cluster.

The following LDAP types are supported:

Note: You can configure an account lockout policy when you set up your LDAP server. An account lockout policy provides more security by restricting access to the account if multiple login attempts fail.

Required user type or access level: Cluster administrator

Configuring LDAP over SSL

You can secure your LDAP connection by using SSL (Secure Sockets Layer). You must prepare your IBM Cloud Private cluster for connecting with your LDAP over SSL (LDAPS) directory.

Before you begin, you must import the public or private SSL certificate that you used for setting up your LDAPS directory.

Retrieving the SSL certificate

If you have the SSL certificate of your LDAP server, proceed with Encoding the SSL certificate.

If you do not have the SSL certificate of your LDAP server, complete the following steps to retrieve the SSL certificate:

Note: You need the ldapsearch program to run these commands. You can install it by running apt install ldap-utils on Ubuntu and yum install openldap-clients on Red Hat Enterprise Linux (RHEL).

  1. Ensure no SSL certificates are in the /etc/openldap/cacerts directory.

  2. Run the following ldapsearch command to retrieve the certificate name:

    ldapsearch -H <LDAP server URL> -d 1  -b <searchbase> -D "" -s base "(<filter>)"
    

    Where,

    • LDAP server URL is your LDAP directory domain name, and port. Format: ldaps://<LDAP server domain name or IP address>:<port>.
    • -d is the debugging level.
    • -b is the search base.
    • -D is the bind DN. This parameter is optional.
    • -s is the scope of search.
    • filter is the LDAP filter. Default filter: (objectClass=*).

    Following is an example command and output:

      $ ldapsearch -H ldaps://corp.example.com:636 -d 1  -b o=example.com -D "" -s base "(objectclass=*)"
      ldap_url_parse_ext(ldaps://corp.example.com:636)
      ldap_create
      ldap_url_parse_ext(ldaps://corp.example.com:636/??base)
      ldap_sasl_bind
      ldap_send_initial_request
      ldap_new_connection 1 1 0
      ldap_int_open_connection
      ldap_connect_to_host: TCP corp.example.com:636
      ldap_new_socket: 3
      ldap_prepare_socket: 3
      ldap_connect_to_host: Trying 9.17.186.253:636
      ldap_pvt_connect: fd: 3 tm: -1 async: 0
      attempting to connect:
      connect success
      TLS: certdb config: configDir='/etc/openldap' tokenDescription='ldap(0)' certPrefix='cacerts' keyPrefix='cacerts' flags=readOnly
      TLS: cannot open certdb '/etc/openldap', error -8018:Unknown PKCS #11 error.
      TLS: could not get info about the CA certificate directory /etc/openldap/cacerts - error -5950:File not found.
      TLS: certificate [CN=DigiCert Global Root G2,OU=www.digicert.com,O=DigiCert Inc,C=US] is not valid - error -8172:Peer's certificate issuer has been marked as not trusted by the user..
      TLS: error: connect - force handshake failure: errno 2 - moznss error -8172
      TLS: can't connect: TLS error -8172:Peer's certificate issuer has been marked as not trusted by the user..
      ldap_err2string
      ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
    

    The certificate information is in the TLS: certificate [CN=DigiCert Global Root G2,OU=www.digicert.com,O=DigiCert Inc,C=US] is not valid - error -8172:Peer's certificate issuer has been marked as not trusted by the user.. section of the output.

  3. Locate the certificate in your web browser, export it to a file in a PEM format, and save the PEM file with a .crt extension.
    Note: If you have multiple certificates, export each certificate to a file in a PEM format and save the PEM file with a .crt extension.

  4. Copy the .crt file to the master node of your IBM Cloud Private cluster.

Preparing for a single LDAPS connection

If you are configuring a single LDAPS connection, complete the steps in the Encoding the SSL certificate section.

Encoding the SSL certificate

Complete the following steps to encode the certificate in base64:

  1. Log on to the master node of your IBM Cloud Private cluster.

  2. Convert the certificate into PEM format.

    openssl x509 -in <cert>.cer -outform PEM -out <convertedCert>.pem
    

    If your LDAP server uses chain certificates (root CA and intermediate certificates), convert each certificate into PEM format. Then, combine them into one file. Use the following command to combine the converted certificates.

     cat <convertedFirstCert.pem> <convertedSecondCert.pem> ..<converted_n_Cert.pem> > <convertedCombinedCert>.pem
    
  3. Encode your certificate in base64.

    cat <LDAPS SSL certificate name>.pem | base64 -w 0
    

    The output resembles the following code:

    LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUdDRENDQS9DZ
    0F3SUJBZ0lRS3k1dTZ0bDFObXdVaW03Ym8zeU1CekFOQmdrcWhraUc5
    ...
    lDOHg0OU9oZ1E9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KDQo=
    

Next, proceed with Preparing your cluster.

Preparing for multiple LDAPS connections

If you are configuring multiple LDAPS connections, first check if you already have a certificate in the "data" > "certificate" section of platform-auth-ldaps-ca-cert. If you have a certificate, then complete the steps in the following sections:

If no certificate exists, then complete the steps in Encoding the SSL certificate.

Retrieve the current certificate

You can retrieve the certificate by using the management console or by using the command line interface (CLI).

If you are using the management console, follow these steps:

  1. Log on to the management console as a cluster administrator.
  2. From the navigation menu, click Configuration > Secrets.
  3. Locate platform-auth-ldaps-ca-cert and click ACTION > Edit. A Edit Secret window displays.
  4. Copy the base64 encoded certificate value from "data" > "certificate" section.

    “data”: {
    “certificate”: “LS0tLS1...ASDFASDo=”
    },
    
  5. Convert the existing encoded certificate and save to a file.

    echo "<copied_cert_value>" | base64 --decode > existing_cert.pem
    

If you are using the CLI, follow these steps:

  1. Access the CLI of your master node. You need kubectl, the Kubernetes command line tool to complete the following tasks. For more information about installing and configuring kubectl, see Accessing your cluster from the Kubernetes CLI (kubectl).
  2. Get the base64 certificate.
    kubectl -n kube-system get secret platform-auth-ldaps-ca-cert -o “jsonpath={.data[‘certificate’]}” | base64 --decode > existing_cert.pem
    

Next, proceed with Encode the SSL certificate.

Encode the SSL certificate

Complete the following steps to encode the certificate in base64:

  1. Log on to the master node of your IBM Cloud Private cluster.
  2. Convert the new certificate into PEM format.

    openssl x509 -in <cert>.cer -outform PEM -out <convertedCert>.pem
    

    If your LDAP server uses chain certificates (root CA and intermediate certificates), convert each certificate into PEM format. Then, combine them into one file. Use the following command to combine the converted certificates.

     cat <convertedFirstCert.pem> <convertedSecondCert.pem> ..<converted_n_Cert.pem> > <convertedCombinedCert>.pem
    
  3. Add the existing certificate to the new certificate, or to the combined certificate if you use chain certificates.

    cat existing_cert.pem <new_cert.pem or convertedCombinedCert.pem> > final_combined_cert.pem
    
  4. Encode your certificate in base64.

    cat <LDAPS SSL certificate name>.pem | base64 -w 0
    

    The output resembles the following code:

    LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUdDRENDQS9DZ
    0F3SUJBZ0lRS3k1dTZ0bDFObXdVaW03Ym8zeU1CekFOQmdrcWhraUc5
    ...
    lDOHg0OU9oZ1E9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KDQo=
    

Next, complete the steps in the Preparing your cluster section.

Preparing your cluster

You can prepare your cluster by using the management console or by using the CLI.

If you are using the management console, follow these steps:

  1. Log on to the management console as a cluster administrator.
  2. From the navigation menu, click Configuration > Secrets.
  3. Locate platform-auth-ldaps-ca-cert and click ACTION > Edit. A Edit Secret window displays.
  4. Paste the base64 certificate in the following section:

     "data": {
      "certificate": ""
     },
    

    The updated section resembles the following text:

     "data": {
      "certificate": "LS0tLS1<very_long_base64_string>ASDFASDo="
     },
    
  5. Click Submit.
  6. From the navigation menu, click Workloads > DaemonSets.
  7. Locate auth-idp and click ACTION > Edit. A Edit DaemonSet window displays.
  8. Click Submit without making any change. This step is to reload the auth-idp pod with the latest secrets and configmap values.
  9. Wait for a minute or two and then check whether the certificate is mounted on the pod.

    1. Get the auth-idp pods.

      kubectl -n kube-system get pods | grep auth-idp
      
    2. Check whether the certificate is mounted on the pod.

      kubectl -n kube-system exec -it auth-idp-<pod-id> -c platform-auth-service cat /opt/ibm/ldaps/ldaps-ca.crt
      

If you are using the CLI, follow these steps:

  1. Access the CLI of your master node. You need kubectl, the Kubernetes command line tool to complete the following tasks. For more information about installing and configuring kubectl, see Accessing your cluster from the Kubernetes CLI (kubectl).
  2. Copy the LDAPS CA certificate secret to a file:

    kubectl get secret platform-auth-ldaps-ca-cert -o yaml -n kube-system > platform-auth-ldaps-ca-cert-secret.yaml
    
  3. Copy and paste the base64 certificate to the platform-auth-ldaps-ca-cert-secret.yaml file.

  4. Get the security service DaemonSet YAML file:

     kubectl -n kube-system get ds auth-idp -o yaml > auth-idp.yaml
    
  5. Apply the changes:

    kubectl apply -f platform-auth-ldaps-ca-cert-secret.yaml
    
    kubectl apply -f auth-idp.yaml
    

Next, complete the steps in the Connecting to your LDAP directory section.

Connecting to your LDAP directory

Follow these steps to set up your LDAP connection.

  1. Log on as an administrator.
  2. From the navigation menu, click Manage > Identity & Access.
  3. Click Create Connection. The "LDAP connection" page is displayed.
  4. Enter the following details to set up your LDAP connection.

Note: You can configure multiple LDAP connection instances to the same LDAP server. However, both the Base DN and connection Name must be unique.

LDAP connection

Enter connection information.

  1. Click Connect.

Your IBM Cloud Private cluster is now connected with your LDAP directory.

Next, you can add your LDAP users and user groups to your IBM Cloud Private cluster. For more information about adding users, see Add users to a team and Add groups to a team.

Default LDAP filters by LDAP type

Table 1. List of default IBM Tivoli Directory Server LDAP filters
Attribute name Data type Default value
groupFilter string (&(cn=%v)(objectclass=groupOfUniqueNames))
groupIdMap string *:cn
groupMemberIdMap string groupOfUniqueNames:uniquemember
userFilter string (&(emailAddress=%v)(objectclass=person))
userIdMap string *:uid
Table 2. List of default Custom Server LDAP filters
Attribute name Data type Default value
groupFilter string (&(cn=%v)(objectclass=groupOfUniqueNames))
groupIdMap string *:cn
groupMemberIdMap string groupOfUniqueNames:uniquemember
userFilter string (&(uid=%v)(objectclass=ePerson))
userIdMap string *:uid
Table 3. List of default Microsoft Active Directory LDAP filters
Attribute name Data type Default value
groupFilter string (&(cn=%v)(objectclass=group))
groupIdMap string *:cn
groupMemberIdMap string memberOf:member
userFilter string (&(sAMAccountName=%v)(objectclass=user))
userIdMap string user:sAMAccountName
Table 4. List of default IBM Lotus Domino LDAP filters
Attribute name Data type Default value
groupFilter string (&(cn=%v)(objectclass=dominoGroup))
groupIdMap string *:cn
groupMemberIdMap string dominoGroup:member
userFilter string (&(uid=%v)(objectclass=Person))
userIdMap string person:uid
Table 5. List of default IBM SecureWay Directory Server LDAP filters
Attribute name Data type Default value
groupFilter string (&(cn=%v)((objectclass=groupOfNames)(objectclass=groupOfUniqueNames)))
groupIdMap string *:cn
groupMemberIdMap string groupOfNames:member;groupOfUniqueNames:uniqueMember
userFilter string (&(uid=%v)(objectclass=ePerson))
userIdMap string *:uid
Table 6. List of default Sun Java System Directory Server LDAP filters
Attribute name Data type Default value
groupFilter string (&(cn=%v)(objectclass=ldapsubentry))
groupIdMap string *:cn
groupMemberIdMap string nsRole:nsRole
userFilter string (&(uid=%v)(objectclass=inetOrgPerson))
userIdMap string inetOrgPerson:uid
Table 7. List of default Netscape Directory Server LDAP filters
Attribute name Data type Default value
groupFilter string (&(cn=%v)((objectclass=groupOfNames)(objectclass=groupOfUniqueNames)))
groupIdMap string *:cn
groupMemberIdMap string groupOfNames:member;groupOfUniqueNames:uniqueMember
userFilter string (&(uid=%v)(objectclass=inetOrgPerson))
userIdMap string inetOrgPerson:uid
Table 8. List of default Novell eDirectory LDAP filters
Attribute name Data type Default value
groupFilter string (&(cn=%v)(objectclass=groupOfNames))
groupIdMap string *:cn
groupMemberIdMap string groupOfNames:member
userFilter string (&(cn=%v)(objectclass=Person))
userIdMap string person:cn