Spanish Total.js
English
Documentation For AI agents
Contents

LDAP

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

.md GitHub

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.

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);
});
OptionMeaning
ldap{ host, port }, the port defaults to 389
user, passwordThe account used to bind
typeperson, group or profile
dnThe base DN of the search
loginThe sAMAccountName searched by the profile type
noauthtrue 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:

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.

Made in Europe