> 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/adapters/m/microsoft-active-directory.md).

# Microsoft Active Directory

Microsoft Active Directory is the directory service of a Windows domain. OctoXLabs reads the computer and person objects over LDAP and adds them as devices and users.

## Use cases

* **Find domain computers that your EDR does not cover.**

```
Adapters = active-directory AND NOT Adapters = falcon-crowdstrike
```

* **Find domain computers that have not logged on recently.**

```
Adapters = active-directory AND NOT LastSeen last now-90d/d
```

* **Find directory users that have no account in another system.** How accounts are matched depends on your user merge settings.

```
Adapters = active-directory AND NOT Adapters = azure-entra
```

## Before you begin

### Network

| Source              | Destination                                              | Port          | Protocol |
| ------------------- | -------------------------------------------------------- | ------------- | -------- |
| OctoXLabs connector | Active Directory host (IP Address or Hostname parameter) | 389 (default) | LDAP     |
| OctoXLabs connector | Active Directory host                                    | 636           | LDAPS    |

The baseline lists TCP/UDP 389 for LDAP and TCP/UDP 636 for LDAPS. The code uses the Port parameter, default 389, and does not switch to 636 by itself when SSL is on. Enter 636 yourself for LDAPS.

### Required permissions

| Scope or role  | Permission                        | Needed for                          |
| -------------- | --------------------------------- | ----------------------------------- |
| Domain account | Read-only access to the directory | Reading computer and person objects |

## Create credentials in Active Directory

{% stepper %}
{% step %}

### Create a read-only account

Create a domain account for OctoXLabs. It only needs read access to the directory. It must not be locked, disabled or have an expired password.
{% endstep %}

{% step %}

### Collect the domain information

Note the FQDN of the domain (for example `octoxlabs.local.com`) and the IP address or host name of a domain controller.
{% endstep %}

{% step %}

### Export the CA certificate (LDAPS only)

If you use LDAPS with a certificate, export the root CA certificate. See the [Microsoft guide](https://learn.microsoft.com/en-us/troubleshoot/windows-server/certificates-and-public-key-infrastructure-pki/export-root-certification-authority-certificate).
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter                               | Required | Type          | Default | Description                                                                                       |
| --------------------------------------- | -------- | ------------- | ------- | ------------------------------------------------------------------------------------------------- |
| Domain                                  | Yes      | String        | None    | FQDN of the domain. The search base is built from it as `dc=...` parts.                           |
| IP Address or Hostname                  | Yes      | String        | None    | Address of the Active Directory host. The code names this field `ip`.                             |
| Port                                    | No       | Integer       | 389     | LDAP port. Use 636 for LDAPS.                                                                     |
| Username                                | Yes      | String        | None    | Plain user name, for example `jdoe`, without a domain prefix. The connector builds the bind name. |
| Password                                | Yes      | String        | None    | Password of the account.                                                                          |
| Timeout                                 | No       | Integer       | 30      | Connect timeout in seconds.                                                                       |
| SSL                                     | No       | Boolean       | False   | Opens the connection with SSL and runs StartTLS.                                                  |
| Certificate File                        | No       | File (base64) | None    | CA root certificate. When set, the connector uses simple authentication.                          |
| Use Only Domain Name for Authentication | No       | Boolean       | False   | Uses the first label of the FQDN in upper case, for example `OCTOXLABS`.                          |
| Use Simple Authentication               | No       | Boolean       | False   | Uses simple bind instead of NTLM.                                                                 |
| Fetch Users                             | No       | Boolean       | True    | Also reads user objects.                                                                          |
| Use UPN                                 | No       | Boolean       | False   | Binds as `username@domain` instead of `domain\username`.                                          |

Use Only Domain Name and Use UPN cannot both be on. The connection is rejected with "use\_domain\_for\_auth and use\_upn cannot be enabled at the same time."

## Troubleshooting

| Error message                                                           | Cause                                                 | Fix                                                                                        |
| ----------------------------------------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| use\_domain\_for\_auth and use\_upn cannot be enabled at the same time. | Both options are on.                                  | Turn one of them off.                                                                      |
| Invalid credentials (LDAP error text from the bind)                     | The bind failed.                                      | Enter only the plain user name. Check that the account is not locked, disabled or expired. |
| Computers not found.                                                    | The test raises this when the probe finds no entries. | Check the domain value and the account rights.                                             |

## Change history
