LDAP js client
node >= 8.0
No ldapjs
(https://www.npmjs.com/package/ldapjs) as dependency.
Why: because ldapjs
is not maintained for more than two years.
Installation
npm install ldapjs-client
Usage
To create a new client:
var LdapClient = ;var client = url: 'ldap://127.0.0.1:389' ;
Attribute | Type | Description |
---|---|---|
url | String | A valid LDAP URL (proto/host/port only) |
timeout | Number | Milliseconds client should let operations live for before timing out (Default: Infinity) |
tlsOptions | Object | Additional options passed to TLS connection layer when connecting via ldaps:// (See: The TLS docs for node.js) |
add
try const entry = cn: 'foo' sn: 'bar' email: 'foo@bar.com' 'foo1@bar.com' objectclass: 'fooPerson' ; await client; catch e console;
bind
try await client; catch e console;
del
try await client; catch e console;
modify
try const change = operation: 'add' // add, delete, replace modification: pets: 'cat' 'dog' ; await client; catch e console;
modifyDN
try await client; catch e console;
search
try const options = filter: '(&(l=Seattle)(email=*@foo.com))' scope: 'sub' attributes: 'dn' 'sn' 'cn' ; const entries = await client; catch e console;
Attribute | Type | Description |
---|---|---|
scope | String | One of base, one, or sub. Defaults to base |
filter | String | A string version of an LDAP filter. Defaults to (objectclass=*) |
attributes | Array of String | attributes to select and return. Defaults to the empty set, which means all attributes |
sizeLimit | Number | the maximum number of entries to return. Defaults to 0 (unlimited) |
timeLimit | Number | the maximum amount of time the server should take in responding, in seconds. Defaults to 10. Lots of servers will ignore this |
typesOnly | Boolean | on whether you want the server to only return the names of the attributes, and not their values. Borderline useless. Defaults to false |
unbind
try await client; catch e console;
destroy
try await client; catch e console;
Close connection if exists and destroy current client
Pull requests and suggestions are welcome!
License
MIT.