# LDAP

> Find, create and update users and groups in a directory you run yourself, such as on-premises Active Directory, OpenLDAP or FreeIPA: onboard people with an account, password and groups, and offboard them by disabling and moving their account. For Microsoft Entra ID, Okta or JumpCloud's own users, use their integrations.

App · 10 actions. Web page: https://docs.lodol.com/docs/integrations/ldap

## Actions

### Add to a group

Make a user (or a group) a member of a group. Someone already in it is left as they are, and the step carries on.

**Inputs**

- Group (`group`, text, required): The group's DN, such as CN=Sales,OU=Groups,DC=example,DC=com.
- Member (`member`, text, required): The DN of the user (or group) to add, such as CN=Ada Lovelace,OU=Staff,DC=example,DC=com. For a posixGroup, which lists user names, a user name such as alovelace works too.

**Outputs**: The membership.

- `added` (true/false): True when the member was added; false when they were already in the group.
- `attribute` (text): Which attribute holds the group's members: member, uniqueMember or memberUid
- `group` (text): The group's DN
- `member` (text): The member as written to the group: a DN, or a user name for a posixGroup

**Example output**

```json
{
  "added": true,
  "attribute": "member",
  "group": "CN=Sales,OU=Groups,DC=example,DC=com",
  "member": "CN=Ada Lovelace,OU=Staff,DC=example,DC=com"
}
```

### Create an entry

Add a user, group, OU or any other entry to the directory. In Active Directory a new user starts disabled with no password: follow with Set a password and Enable or disable an account.

**Inputs**

- DN (`dn`, text, required): The new entry's DN: its name, then where it goes, such as CN=Ada Lovelace,OU=Staff,DC=example,DC=com. The OU it goes in must exist.
- Object classes (`object_classes`, list, required): What kind of entry it is. For Active Directory: user, group or organizationalUnit. For OpenLDAP and FreeIPA people: inetOrgPerson; groups: groupOfNames.
- Attributes (`attributes`, object): The entry's attributes and their values, such as sAMAccountName: alovelace, userPrincipalName: alovelace@example.com, givenName: Ada and sn: Lovelace. A list gives several values. The name in the DN is filled in for you. Passwords go in Set a password.
- If it already exists (`if_exists`, text): What to do when there is already an entry at that DN: stop the workflow, or carry on without changing it, which suits a workflow that may run twice for the same person. One of: `fail` (Stop the workflow), `ignore` (Carry on). Default: `fail`.

**Outputs**: The entry created.

- `created` (true/false): True when it was created; false when one was already there and the step carried on.
- `dn` (text): The new entry's DN.

**Example output**

```json
{
  "created": true,
  "dn": "CN=Ada Lovelace,OU=Staff,DC=example,DC=com"
}
```

### Delete an entry

Delete one entry, such as a leaver's account once it has been disabled for a while. An entry with others under it, such as an OU that isn't empty, is never deleted.

**Inputs**

- DN (`dn`, text, required): The entry's DN (distinguished name): its full place in the directory, from itself up, such as CN=Ada Lovelace,OU=Staff,DC=example,DC=com. Find entries returns it as dn.
- If there is no such entry (`if_missing`, text): What to do when nothing is at that DN: stop the workflow, or carry on, which suits a cleanup step that may run more than once. One of: `fail` (Stop the workflow), `ignore` (Carry on). Default: `fail`.

**Outputs**: Whether the entry was deleted.

- `deleted` (true/false): True when it was deleted; false when there was nothing there and the step carried on.
- `dn` (text): The DN that was deleted.

**Example output**

```json
{
  "deleted": true,
  "dn": "CN=Ada Lovelace,OU=Staff,DC=example,DC=com"
}
```

### Enable or disable an account

Turn an account's sign-in off when someone leaves, or on once a new starter's account is ready. Works with Active Directory, FreeIPA and 389 Directory Server; nothing else about the account changes.

**Inputs**

- DN (`dn`, text, required): The account's DN, such as CN=Ada Lovelace,OU=Staff,DC=example,DC=com.
- State (`state`, text, required): Whether the account can sign in afterwards. One of: `disable` (Disable the account), `enable` (Enable the account).

**Outputs**: The account's state now.

- `changed` (true/false): False when it was already in that state and nothing was changed.
- `dn` (text): The account's DN.
- `enabled` (true/false): Whether the account can sign in now.

**Example output**

```json
{
  "changed": true,
  "dn": "CN=Ada Lovelace,OU=Staff,DC=example,DC=com",
  "enabled": false
}
```

### Find entries

Search the directory for users, groups or anything else, by attribute values or an LDAP filter, such as everyone in Sales or the account with a given email address. Returns each entry with its DN and attributes, ready for a Repeat for each.

**Inputs**

- Matching (`match`, object): Find entries whose attributes have these values, such as sAMAccountName: alovelace or mail: an address from an earlier step. Every pair must match. Values are taken literally, so * is just a character, and case usually doesn't matter.
- Filter (`search_filter`, text): An LDAP filter, for searches Matching can't express, such as (&(objectClass=user)(department=Sales)) or (sAMAccountName=a*). Sent as written, so a value from an earlier step should go in Matching instead. With both, an entry must match both.
- Start at (`search_base`, text): The DN to search from, such as OU=Staff,DC=example,DC=com. Leave empty to search from the connection's base DN.
- Search (`scope`, text): How far below Start at to look. One of: `subtree` (That entry and everything under it), `one` (Only the entries directly under it), `base` (Only that entry itself). Default: `subtree`.
- Attributes (`attributes`, list): Which attributes to return, such as sAMAccountName, mail and memberOf. Leave empty for all of them. Add + for the directory's operational ones too (OpenLDAP keeps memberOf there).
- Limit (`limit`, number): The most entries to return, up to 1,000. From 1 to 1000. Default: `100`.

**Outputs**: The entries found, in the order the directory gave them.

- `count` (number): How many entries were found.
- `entries` (list): Each entry found, with its dn and attributes.
- `filter` (text): The filter that was sent, Matching included.
- `searched_from` (text): The DN the search started at.
- `truncated` (true/false): True when there were more entries than Limit and only the first were returned.

**Example output**

```json
{
  "count": 1,
  "entries": [
    {
      "attributes": {
        "displayName": "Ada Lovelace",
        "mail": "ada.lovelace@example.com",
        "memberOf": [
          "CN=Sales,OU=Groups,DC=example,DC=com",
          "CN=All Staff,OU=Groups,DC=example,DC=com"
        ],
        "objectGUID": "5b2a3f9c-8d41-4e0b-9a77-2c1d0e6f4b13",
        "objectSid": "S-1-5-21-3623811015-3361044348-30300820-1013",
        "sAMAccountName": "alovelace"
      },
      "dn": "CN=Ada Lovelace,OU=Staff,DC=example,DC=com"
    }
  ],
  "filter": "(sAMAccountName=alovelace)",
  "searched_from": "DC=example,DC=com",
  "truncated": false
}
```

### Get an entry

Read one entry by its DN, such as a user's email address, groups and manager. Stops the workflow when there is no such entry; use Find entries to check whether one exists.

**Inputs**

- DN (`dn`, text, required): The entry's DN (distinguished name): its full place in the directory, from itself up, such as CN=Ada Lovelace,OU=Staff,DC=example,DC=com. Find entries returns it as dn.
- Attributes (`attributes`, list): Which attributes to return, such as sAMAccountName, mail and memberOf. Leave empty for all of them. Add + for the directory's operational ones too (OpenLDAP keeps memberOf there).

**Outputs**: The entry.

- `attributes` (object): The entry's attributes by name. One value is text; several are a list, and attributes that hold lists (objectClass, member, memberOf, proxyAddresses) are always lists. objectGUID reads as a GUID, objectSid as S-1-5-..., other binary values as base64. An attribute asked for by name that the entry lacks is null (or an empty list).
- `dn` (text): The entry's DN.

**Example output**

```json
{
  "attributes": {
    "displayName": "Ada Lovelace",
    "mail": "ada.lovelace@example.com",
    "memberOf": [
      "CN=Sales,OU=Groups,DC=example,DC=com",
      "CN=All Staff,OU=Groups,DC=example,DC=com"
    ],
    "objectGUID": "5b2a3f9c-8d41-4e0b-9a77-2c1d0e6f4b13",
    "objectSid": "S-1-5-21-3623811015-3361044348-30300820-1013",
    "sAMAccountName": "alovelace"
  },
  "dn": "CN=Ada Lovelace,OU=Staff,DC=example,DC=com"
}
```

### Remove from a group

Take a user (or a group) out of a group. Someone who isn't in it is left as they are, and the step carries on.

**Inputs**

- Group (`group`, text, required): The group's DN, such as CN=Sales,OU=Groups,DC=example,DC=com.
- Member (`member`, text, required): The DN of the user (or group) to remove, such as CN=Ada Lovelace,OU=Staff,DC=example,DC=com. For a posixGroup, a user name such as alovelace works too.

**Outputs**: The membership that was ended.

- `attribute` (text): Which attribute holds the group's members: member, uniqueMember or memberUid
- `group` (text): The group's DN
- `member` (text): The member as written to the group: a DN, or a user name for a posixGroup
- `removed` (true/false): True when the member was removed; false when they weren't in the group.

**Example output**

```json
{
  "attribute": "member",
  "group": "CN=Sales,OU=Groups,DC=example,DC=com",
  "member": "CN=Ada Lovelace,OU=Staff,DC=example,DC=com",
  "removed": true
}
```

### Rename or move an entry

Give an entry a new name, move it to another OU, or both, such as moving a leaver's account to a Leavers OU. In Active Directory this changes the CN only, not the user's sign-in name.

**Inputs**

- DN (`dn`, text, required): The entry's DN (distinguished name): its full place in the directory, from itself up, such as CN=Ada Lovelace,OU=Staff,DC=example,DC=com. Find entries returns it as dn.
- New name (`new_name`, text): The entry's new name, such as Ada King, or with its attribute, such as CN=Ada King. Leave empty to keep it.
- Move to (`new_parent`, text): The DN of the OU (or other entry) to move it under, such as OU=Leavers,DC=example,DC=com. Leave empty to keep it where it is.

**Outputs**: Where the entry is now.

- `dn` (text): The entry's DN now.
- `previous_dn` (text): Its DN before.

**Example output**

```json
{
  "dn": "CN=Ada Lovelace,OU=Leavers,DC=example,DC=com",
  "previous_dn": "CN=Ada Lovelace,OU=Staff,DC=example,DC=com"
}
```

### Set a password

Set an account's password, such as a new starter's first one or a reset. Works over an encrypted connection only. The new password must meet the directory's password policy.

**Inputs**

- DN (`dn`, text, required): The account's DN, such as CN=Ada Lovelace,OU=Staff,DC=example,DC=com.
- New password (`password`, text, required): The password to set. It isn't kept in the run's output.
- Ask for a new password at next sign-in (`must_change_at_next_sign_in`, true/false): Make the person choose their own password when they next sign in, so only they know it. On unless you turn it off, as in Active Directory's own Reset Password box. Active Directory only: other directories set the password without asking. Off, a pending request to change it is cleared. Default: `true`.

**Outputs**: The account whose password was set (never the password).

- `dn` (text): The account's DN.
- `method` (text): How it was set: Active Directory's unicodePwd, or the standard password modify operation.
- `must_change_at_next_sign_in` (true/false): Whether they'll be asked for a new password at their next sign-in.

**Example output**

```json
{
  "dn": "CN=Ada Lovelace,OU=Staff,DC=example,DC=com",
  "method": "active_directory",
  "must_change_at_next_sign_in": true
}
```

### Update an entry

Change an entry's attributes in one go, such as a user's title, department and manager. Values can also be added to or removed from a list, such as one of a user's proxyAddresses, and attributes cleared.

**Inputs**

- DN (`dn`, text, required): The entry's DN (distinguished name): its full place in the directory, from itself up, such as CN=Ada Lovelace,OU=Staff,DC=example,DC=com. Find entries returns it as dn.
- Set these (`changes`, object): Each attribute with its new value, replacing what is there, such as title: Engineer or manager: a manager's DN. A list gives several values; an empty value clears the attribute.
- Add these values (`add_values`, object): Values to add, keeping those already there, such as proxyAddresses: smtp:ada@example.com. One already there is skipped.
- Remove these values (`remove_values`, object): Values to take away, keeping the rest. One that isn't there is skipped.
- Clear these (`clear`, list): Attributes to empty completely, such as telephoneNumber.

**Outputs**: What was changed.

- `changed` (list): The attributes that were changed.
- `dn` (text): The entry's DN.
- `skipped` (list): Values left alone because they were already there (to add) or not there (to remove), each with its attribute, value and reason.

**Example output**

```json
{
  "changed": [
    "proxyAddresses",
    "title"
  ],
  "dn": "CN=Ada Lovelace,OU=Staff,DC=example,DC=com",
  "skipped": []
}
```
