---
title: LDAP
project: Total.js V4
version: 0.0.99
section: guides
language: en
license: MIT
url: https://totaljs.es/docs/total-js-v4/0-0-99/guides/ldap/
updated: 2026-11-16T15:41:10.817Z
---

# LDAP

> Read entries from an LDAP server such as Active Directory with LDAP().

`LDAP(opt, [callback])` reads entries from an LDAP server such as Active Directory. It binds with a user and a password, then searches a base DN for entries of one `objectClass`.

```js
LDAP({
	ldap: { host: '10.0.0.5', port: 389 },
	user: 'CN=reader,OU=Services,DC=company,DC=local',
	password: CONF.ldap_password,
	type: 'person',
	dn: 'OU=Users,DC=company,DC=local'
}, function(err, users) {
	if (err)
		return;
	for (var user of users)
		console.log(user.sAMAccountName, user.mail);
});
```

| Option | Meaning |
| --- | --- |
| `ldap` | `{ host, port }`, the port defaults to `389` |
| `user`, `password` | The account used to bind |
| `type` | `person`, `group` or `profile` |
| `dn` | The base DN of the search |
| `login` | The `sAMAccountName` searched by the `profile` type |
| `noauth` | `true` searches without binding |

Each entry is a plain object with attribute names as keys. When an attribute has more values (for example `memberOf`), its value is an array. The `profile` type returns one object or `null`. Without a callback the function returns a Promise:

```js
var user = await LDAP({ ldap: { host: '10.0.0.5' }, user: 'reader@company.local', password: CONF.ldap_password, type: 'profile', dn: 'DC=company,DC=local', login: 'peter' });
```

The connection is not encrypted (plain LDAP), so use it in a trusted network.
