# LDAP temporary access

Create temporary `inetOrgPerson` entries and grant membership in selected directory
groups. Use the existing [customer provisioner](/docs/guides/provisioner), in push
or pull mode, with its single connection token. Configure directory settings,
credentials and member/service-token access in Seekrit.

## Configure the directory

Select **LDAP** when adding a target. Choose the registered provisioner and enter:

- An LDAPS origin, such as `ldaps://directory.internal:636`.
- The existing parent DN for temporary users, such as `ou=people,dc=example,dc=com`.
- Existing group DNs as a JSON array, and `member` or `uniqueMember` as the group attribute.
- The directory's CA certificate in PEM format if it uses a private CA.

Supply the management credential as JSON with `bindDn` and `password`. The browser
encrypts both the credential and configuration to the provisioner. It requires
permission to create/read/delete users under the parent DN, modify their passwords,
read `entryUUID`, and update membership of the selected groups.

This adapter targets LDAP directories supporting `inetOrgPerson`, RFC 3062 Password
Modify, RFC 4530 `entryUUID`, and the RFC 4528 assertion control, including OpenLDAP.
It does not implement Active Directory's `unicodePwd` account workflow. Plain LDAP,
unverified TLS and LDAP URLs containing search filters or credentials are rejected.
No directory configuration files need to be mounted into the provisioner.

## Lifecycle and permissions

The provisioner creates a unique `uid=sk_…` entry without a password, grants the
configured groups, then installs a generated password through Password Modify so
the directory applies its password-storage policy. Reserve the `sk_` prefix for
Seekrit-created entries. Group permissions and directory ACLs determine access.

Cleanup verifies the user marker and entry UUID, removes its password, removes its
group memberships, and deletes the entry. Critical assertion controls prevent
changing or deleting a replacement entry after the ownership lookup. Servers that
do not support the control fail closed. Existing groups are retained.

LDAP users do not have a standard automatic expiry. Cleanup requires the provisioner
to remain connected and receive Seekrit's jobs. Already-authenticated connections
may survive password removal or entry deletion; configure directory/session limits
for workloads requiring immediate termination.

## CLI and API

Use `seekrit dynamic target add --name directory-reader --config target.json`,
piping the management login JSON on stdin:

```json
{
  "provider": "ldap",
  "executor": "remote",
  "provisionerId": "prv_REPLACE_WITH_REGISTERED_ID",
  "settings": {
    "endpoint": "ldaps://directory.internal:636",
    "usersDn": "ou=people,dc=example,dc=com",
    "groups": ["cn=readers,ou=groups,dc=example,dc=com"],
    "memberAttribute": "member"
  },
  "maxTtlSeconds": 3600
}
```

Request with `seekrit dynamic lease <target-id> --ttl 1h`. The decrypted result
includes the bind DN, username, password, endpoint and lease expiry. Existing lease
API routes accept `provider: "ldap"`. Member and service-token signatures use the
same existing keys and access grants.
