Overview
ldapjs-promise is a pure JavaScript, from-scratch framework for implementing LDAP clients and servers in Node.js. It is intended for developers used to interacting with HTTP services in node and restify.
import {
createServer
} from 'ldapjs-promise';
const server = createServer();
server.search('o=example', (req, res, next) => {
const obj = {
dn: req.dn.toString(),
attributes: {
objectclass: ['organization', 'top'],
o: 'example'
}
};
if (req.filter.matches(obj.attributes))
res.send(obj);
res.end();
});
server.listen(1389, () => {
console.log('LDAP server listening at %s', server.url);
});
Try hitting that with:
$ ldapsearch -H ldap://localhost:1389 -x -b o=example objectclass=*
Features
ldapjs-promise implements most of the common operations in the LDAP v3 RFC(s), for both client and server. It is 100% wire-compatible with the LDAP protocol itself, and is interoperable with OpenLDAP and any other LDAPv3-compliant implementation. ldapjs-promise gives you a powerful routing and "intercepting filter" pattern for implementing server(s). It is intended that you can build LDAP over anything you want, not just traditional databases.
Getting started
$ npm install ldapjs-promise
If you are new to LDAP, check out the guide. Otherwise, the API documentation is:
| Section | Content |
|---|---|
| Server API | Reference for implementing LDAP servers. |
| Client API | Reference for implementing LDAP clients. |
| DN API | API reference for the DN class. |
| Filter API | API reference for LDAP search filters. |
| Error API | Listing of all ldapjs-promise Error objects. |
| Examples | Collection of sample/getting started code. |
More information
- License:ISC
- Code: wslyhbb/node-ldapjs-promise
What is not in the box?
Since most developers and system(s) adminstrators struggle with some of the esoteric features of LDAP, not all features in LDAP are implemented here. Specifically:
- LDIF
- Aliases
- Attributes by OID
- Extensible matching
There are a few others, but those are the "big" ones.