## LDAP configuration

By default, accessing the Controller user interface is restricted to people that have a user account defined through the MediaKind system center. You can also configure the user access by retrieving user credentials from an existing LDAP server directory.

1. Log in as a user with Administrative privileges.
2. Click `Gear` icon in the upper right corner of the window.
3. Select **Settings**.
4. In the **LDAP** tab, configure the LDAP settings to integrate with the local LDAP server.

<blockquote data-callout="caution"><p>Restart the authentication service after changing the LDAP settings. Either restart the Controller, or consult MediaKind Services for guidance on restarting the correct services for your deployment.</p></blockquote>

## Loading LDAP certificates

If LDAP certificates are being loaded, configure LDAP on the settings page, then load the certificates.

<blockquote data-callout="note"><p>For HA deployment, the following procedures must be done on both controller servers.</p></blockquote>

1. On the controller server, place the LDAPS certificates in /etc/pki/ca-trust/source/anchors/

2. Run the following command:

   ```bash
   update-ca-trust extract
   ```

   This will extract it to the standard OS trust store location (default path used in the controller UI):

   ```text
   /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
   ```

3. Edit the config file to set the right values:

   ```text
   /opt/mediakind/utility/bin/controller/ldaps.conf
   ```

   The conf file must contain the fully qualified domain name for the LDAP server (same as in the certificate) and the IP address of that server.

   ```ini
   ###############################################################################
   #                                                                             #
   # Config file used by add-ldaps-certs.sh                                      #
   # Needs to be populated by the customer specific parameters                   #
   #                                                                             #
   ###############################################################################

   # newLDAPServerName must be fully resolvable
   # FQDN that matches the provided root CA
   newLDAPServerName=ldap.example.org
   newLDAPServerIP=192.0.2.10
   deployment=unified-ui
   ```

   Replace `<BIND_PASSWORD>` with the password for your bind account if protected binding is configured.

   <table>
     <thead>
       <tr>
         <th>LDAP Field</th>
         <th>Description</th>
         <th>Example value</th>
       </tr>
     </thead>
     <tbody>
       <tr>
         <td><code>server</code></td>
         <td>Address of the LDAP server to communicate with.</td>
         <td><code>ldap://ldap.example.org:389</code></td>
       </tr>
       <tr>
         <td><code>Bind DN</code></td>
         <td>Distinguished name to use when binding to the LDAP server; leave empty (default) for an anonymous bind.</td>
         <td><code>CN=apache, OU=COM, OU=Sites, DC=example, DC=org</code></td>
       </tr>
       <tr>
         <td><code>Bind password</code></td>
         <td>Password to use for binding with protected binding; leave empty (default) for anonymous binding.</td>
         <td><code>&lt;BIND_PASSWORD&gt;</code></td>
       </tr>
       <tr>
         <td><code>Search base DN</code></td>
         <td>DN to use when binding to the server in order to perform searches. Leave empty for anonymous binding.</td>
         <td><code>OU=COM, OU=Sites, DC=example, DC=org</code></td>
       </tr>
       <tr>
         <td><code>Username field</code></td>
         <td>Name of the field to use in the LDAP search, for username matching (against LDAP attributes).</td>
         <td><code>sAMAccountName</code></td>
       </tr>
       <tr>
         <td><code>Firstname field</code></td>
         <td>Name of the field (from LDAP attributes) holding the user’s first name.</td>
         <td><code>givenName</code></td>
       </tr>
       <tr>
         <td><code>Lastname field</code></td>
         <td>Name of the field (from LDAP attributes) holding the user’s last name.  <code>firstname_field</code> &amp; <code>lastname_field</code> shall be used together, or they will be ignored. <code>firstname_field</code> &amp; <code>lastname_field</code> can be used to retrieve the user’s full name. This will then be displayed instead of the username once the user is logged in.</td>
         <td><code>sn</code></td>
       </tr>
       <tr>
         <td><code>CA certificate file</code></td>
         <td>Location of the CA certificate file used to verify the LDAP server’s certificate when using TLS or LDAPS.</td>
         <td><code>/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem</code></td>
       </tr>
       <tr>
         <td><code>Cipher suite</code></td>
         <td>Open SSL-format string defining the list of ciphers to use for TLS communication.</td>
         <td><code>kEECDH+aECDSA+AES:kEECDH+AES+aRSA:kEDH+aRSA+AES:-SSLv2:-SSLv3:-TLSv1:-TLSv1.1</code></td>
       </tr>
       <tr>
         <td><code>Required group</code></td>
         <td>The LDAP group required for a user to be able to log in.</td>
         <td><code>cn=controller-users,ou=groups,dc=example,dc=org</code></td>
       </tr>
       <tr>
         <td><code>Group search</code></td>
         <td>The filter used to search for required group.</td>
         <td><code>dc=example, dc=org</code></td>
       </tr>
       <tr>
         <td><code>Default group</code></td>
         <td>A Controller group assigned to a user that has logged in via LDAP. Mutually exclusive with <code>ldap_group_mappings</code> section.</td>
         <td><code>Monitoring</code></td>
       </tr>
       <tr>
         <td><code>Group type</code></td>
         <td>The type of group used to search through LDAP. <code>NestedActiveDirectoryGroupType</code> and <code>GroupOfNames</code> are supported if anything other than <code>NestedActiveDirectoryGroupType</code> it will default to <code>GroupOfNames</code></td>
         <td><code>NestedActiveDirectoryGroupType</code></td>
       </tr>
       <tr>
         <td><code>LDAP group mappings</code></td>
         <td>A section that can be used to control authorisation through LDAP groups. Configure <code>group_search</code> (and don’t use <code>default group</code>). In the example, any user that belongs to the LDAP group <code>MK_Configuration</code> will be given the privileges for the Controller group <code>Configuration</code>.</td>
         <td>See the group mappings below.</td>
       </tr>
     </tbody>
   </table>

   <table>
     <thead>
       <tr>
         <th style="text-align: left">LDAP group</th>
         <th style="text-align: left">Controller group</th>
       </tr>
     </thead>
     <tbody>
       <tr>
         <td style="text-align: left"><code>MK_Admin</code></td>
         <td style="text-align: left"><code>Admin</code></td>
       </tr>
       <tr>
         <td style="text-align: left"><code>MK_Configuration</code></td>
         <td style="text-align: left"><code>Configuration</code></td>
       </tr>
       <tr>
         <td style="text-align: left"><code>MK_Monitoring</code></td>
         <td style="text-align: left"><code>Monitoring</code></td>
       </tr>
     </tbody>
   </table>

4. Run the script:

   ```bash
   /opt/mediakind/utility/bin/controller/add-ldaps-server.sh
   ```

Running the script will restart the required containers.
