These examples favor complete control flow over long explanations. They assume the package is installed through the alias documented in Installation, so source code continues to load ldapjs.
Link to Choose an exampleChoose an example
- Authentication and bind — validate credentials with a simple bind.
- Search — bind, stream entries, handle errors, and disconnect.
- Active Directory — search by
sAMAccountNamewith a constructed equality filter. - TLS and StartTLS — connect with certificate validation using either secure transport.
- In-memory server — run a local bind-and-search LDAP server.
Link to Before running codeBefore running code
Use a test directory and least-privilege accounts. Never commit bind passwords or private CA material. Confirm base DNs, attributes, server certificates, and directory limits with the operator of the target directory.
For the method-level API, use the Client API.