> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/documentation/use-octoxlabs/settings/third-party-services-settings/ldap-settings.md).

# LDAP Settings

Let users sign in with Active Directory credentials, test the connection, and map directory groups to OctoXLabs groups.

**LDAP Settings** connects OctoXLabs to a directory so that people can sign in with their directory username and password instead of a local password. You can add more than one configuration, for example one per domain. Each configuration appears as a **Domain** choice on the sign-in page.

An LDAP user is a normal OctoXLabs user marked as an LDAP user. The directory only checks the password. What the user can do is decided by the OctoXLabs groups they belong to.

### Before you begin

* Required permission to open the page: `configurations.view_ldapconfiguration`.
* Required permission to create, edit, delete and test a configuration: `configurations.change_ldapconfiguration`.
* The LDAP permissions can be held only by administrators. They cannot be added to a custom group.
* Required permission to change **Group Check** or **Auto Register**, and to use **Sync Groups**: `auth.add_group`.
* The address of a domain controller, the domain name, and a directory account to test with.
* For LDAPS: the CA certificate of the directory as a `.pem` file.
* Group Check and Sync Groups read groups from Active Directory. Use them only against an Active Directory domain controller.

### Add an LDAP configuration

{% stepper %}
{% step %}

#### Open the list

Go to **Settings** > **3rd Party Services Settings** > **LDAP Settings** and click **Create LDAP**.
{% endstep %}

{% step %}

#### Enter the connection details

Fill in **IP Address** and **Domain**. Pick the **Authentication Type**. If the type is not **Auto**, pick the **Port**.
{% endstep %}

{% step %}

#### Turn on SSL if you use LDAPS

Select **Use SSL**. To validate the server certificate with your CA, upload it in **Certificate**.
{% endstep %}

{% step %}

#### Choose the user name format

Select **Use UPN** to bind as `username@domain`. Leave it cleared to bind as `domain\username`.
{% endstep %}

{% step %}

#### Decide how new users are handled

Set **Group Check** and **Auto Register** as described in How new LDAP users are created. Leave both off if you want an administrator to approve every new user.
{% endstep %}

{% step %}

#### Create

Click **Create**. The console shows **LDAP configuration created**. Then open the configuration again to test it.
{% endstep %}
{% endstepper %}

IMAGEHERE: LDAP Settings create form with all fields visible and the Send Test and Sync Groups buttons.

### Settings

| Setting                 | Type                                   | Default  | Description                                                                                                                         |
| ----------------------- | -------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| **IP Address**          | Text                                   | Empty    | Address of the directory server. If it is empty, the **Domain** value is used as the server address.                                |
| **Domain**              | Text                                   | Empty    | Directory domain. It is part of the bind name and is the label users pick on the sign-in page.                                      |
| **Authentication Type** | Choice: **Auto**, **NTLM**, **Simple** | **Auto** | **Auto** uses NTLM on port 389 without SSL, and Simple on port 636 with SSL. **NTLM** and **Simple** use the port you pick.         |
| **Port**                | Choice: `389`, `636`                   | `389`    | Disabled while **Authentication Type** is **Auto**.                                                                                 |
| **Use SSL**             | Checkbox                               | Off      | Opens the connection with SSL and starts TLS.                                                                                       |
| **Certificate**         | File upload (`.pem`)                   | None     | CA certificate used when **Use SSL** is on. Other file types and invalid files are rejected.                                        |
| **Use UPN**             | Checkbox                               | Off      | Bind as `username@domain` instead of `domain\username`.                                                                             |
| **Group Check**         | Checkbox                               | Off      | Synchronise Active Directory groups with OctoXLabs permission groups. Users get permissions from their directory group memberships. |
| **Auto Register**       | Checkbox                               | Off      | Activates a new user at first sign-in when **Group Check** found a matching group.                                                  |
| **Username**            | Text                                   | Empty    | Directory account used only by **Send Test** and **Sync Groups**. It is not saved.                                                  |
| **Password**            | Password                               | Empty    | Password for that account. It is not saved.                                                                                         |

The list page shows **IP Address**, **Port**, **Domain**, **Authentication Type** and **Use SSL** for every configuration, with edit and delete actions.

{% hint style="info" %}
OctoXLabs validates the server certificate against the uploaded CA only when the backend runs with `LDAP_CA_CERT_REQUIRED=true`. The default is `false`: the connection is encrypted but the certificate is not validated.
{% endhint %}

### Verify the result

Open the saved configuration, enter a directory **Username** and **Password**, and click **Send Test**. The console shows **LDAP test successful** when the bind works. The button appears only after the configuration is saved, and only with `configurations.change_ldapconfiguration`.

Then sign out and sign in again: tick **Use LDAP** on the sign-in page, choose the **Domain**, and enter the directory credentials.

### How new LDAP users are created

An existing active LDAP user signs in as soon as the directory accepts the password. For a username OctoXLabs has not seen before, the result depends on the two group options.

| Group Check | Auto Register | A directory group matches an OctoXLabs group | Result                                                                                                          |
| ----------- | ------------- | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| Off         | Any           | Not checked                                  | The user is created inactive and is not signed in. An administrator must activate the user in Users.            |
| On          | Off           | Yes                                          | The user is created with the matching groups, inactive, and not signed in. An administrator activates the user. |
| On          | On            | Yes                                          | The user is created with the matching groups, active, and signed in at once.                                    |
| On          | Any           | No                                           | The user is created inactive, without groups, as in the first row.                                              |

A directory group matches an OctoXLabs group when the names are equal, ignoring case. Only groups the user is a direct member of are read. Protected built-in groups are never assigned from the directory. The user's creation is recorded in the User Activities log.

#### Sync Groups

**Sync Groups** reads every group from the directory and creates the missing ones as OctoXLabs groups, so you can then give them permissions. It skips protected groups and any name that already exists, ignoring case. Enter **Username** and **Password** first. The console shows **Group Sync Successful**. This button appears only on a saved configuration.

### Troubleshooting

| Symptom or error message                                                                                                   | Cause                                                                                                                                                                       | Fix                                                                                                           |
| -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `Invalid credentials.` on the sign-in page                                                                                 | The password is wrong, the **Domain** or **Use UPN** setting does not match the account, or the connection or TLS failed. The page shows the same message for all of these. | Run **Send Test** to see the real error, then check the backend log line `LDAP login failed for username=`.   |
| LDAPS test fails with `EE certificate key too weak`                                                                        | The LDAP server certificate uses an RSA key shorter than 2048 bits. OctoXLabs does not lower the OpenSSL security level.                                                    | Ask the directory team to reissue the LDAPS certificate with a stronger key. Adding the CA does not fix this. |
| LDAPS fails because the CA is not trusted                                                                                  | The server certificate was issued by an internal CA and validation is on.                                                                                                   | Upload the CA in **Certificate**, or add it to the server as described in Add an SSL Certificate.             |
| `Not found LDAP configuration. You should be saved new configurations before test.`                                        | **IP Address** or **Domain** is empty in the saved configuration.                                                                                                           | Fill in both, save, and test again.                                                                           |
| `Only .pem certificate files can be uploaded.` or `This file is not a valid certificate. Please upload a valid .pem file.` | The **Certificate** file is not a PEM certificate.                                                                                                                          | Export the CA in PEM format and upload it again.                                                              |
| `User created with given credentials without being logged in.`                                                             | The user was created inactive and waits for approval.                                                                                                                       | Activate the user in Users, or set up **Group Check** and **Auto Register**.                                  |
| `Your account has been deactivated. Please contact your administrator.`                                                    | The LDAP user exists in OctoXLabs but is inactive.                                                                                                                          | Activate the user in Users.                                                                                   |
| `This username is already exists in Octoxlabs Platform without LDAP`                                                       | A local user with the same username exists. LDAP will not take it over.                                                                                                     | Sign in with the local password, or use a different username.                                                 |
| `You need group create permission to change group_check_enabled.` (or `auto_register`)                                     | Your role lacks `auth.add_group`.                                                                                                                                           | Ask an administrator who can create groups to change these options.                                           |
| `LDAP server did not return defaultNamingContext (RootDSE). Verify the host is an Active Directory domain controller.`     | **Sync Groups** or **Group Check** ran against a server that is not an Active Directory domain controller.                                                                  | Point the configuration at a domain controller, or turn **Group Check** off.                                  |
| The LDAP user is not asked to change an expired password                                                                   | Password expiry applies to local users only.                                                                                                                                | Change the password in the directory.                                                                         |
| The login page opens by domain name but `/sso/sso/providers` or `/configurations/company` return 404                       | The domain was not added to a company.                                                                                                                                      | See Custom Domains.                                                                                           |

### What's next?

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Groups</strong></td><td>Give directory groups their permissions.</td><td></td></tr><tr><td><strong>Users</strong></td><td>Activate and manage LDAP users.</td><td></td></tr><tr><td><strong>SSO</strong></td><td>Offer single sign-on as well.</td><td></td></tr><tr><td><strong>Add an SSL Certificate</strong></td><td>Trust an internal CA.</td><td></td></tr></tbody></table>
