node-ldapjs/docs/index.md

98 lines
2.7 KiB
Markdown
Raw Normal View History

2011-08-24 19:38:23 +00:00
---
title: ldapjs
---
2011-08-25 04:36:48 +00:00
<div id="indextagline">
Reimagining <a href="http://tools.ietf.org/html/rfc4510" id="indextaglink">LDAP</a> for <a id="indextaglink" href="http://nodejs.org">Node.js</a>
</div>
2011-08-24 19:38:23 +00:00
# Overview
2020-12-13 08:06:45 +00:00
<div class="intro">
2011-08-24 19:38:23 +00:00
ldapjs is a pure JavaScript, from-scratch framework for implementing
[LDAP](http://tools.ietf.org/html/rfc4510) clients and servers in
2011-08-25 04:36:48 +00:00
[Node.js](http://nodejs.org). It is intended for developers used to interacting
2015-10-16 05:25:49 +00:00
with HTTP services in node and [restify](http://restify.com).
2011-08-24 19:38:23 +00:00
2020-12-13 08:06:45 +00:00
</div>
2021-02-24 22:03:35 +00:00
```js
const ldap = require('ldapjs');
2011-08-25 04:46:31 +00:00
2021-02-24 22:03:35 +00:00
const server = ldap.createServer();
2011-08-24 19:38:23 +00:00
2021-02-24 22:03:35 +00:00
server.search('o=example', (req, res, next) => {
const obj = {
dn: req.dn.toString(),
attributes: {
objectclass: ['organization', 'top'],
o: 'example'
}
};
2011-08-25 04:46:31 +00:00
2021-02-24 22:03:35 +00:00
if (req.filter.matches(obj.attributes))
res.send(obj);
2011-08-24 19:38:23 +00:00
2021-02-24 22:03:35 +00:00
res.end();
});
2011-08-24 19:38:23 +00:00
2021-02-24 22:03:35 +00:00
server.listen(1389, () => {
console.log('LDAP server listening at %s', server.url);
});
```
2011-08-24 19:38:23 +00:00
Try hitting that with:
2021-02-24 22:03:35 +00:00
```sh
$ ldapsearch -H ldap://localhost:1389 -x -b o=example objectclass=*
```
2011-08-24 19:38:23 +00:00
# Features
ldapjs 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](http://openldap.org) and any other
LDAPv3-compliant implementation. ldapjs gives you a powerful routing and
2011-08-25 19:19:17 +00:00
"intercepting filter" pattern for implementing server(s). It is intended
2011-08-24 19:38:23 +00:00
that you can build LDAP over anything you want, not just traditional databases.
# Getting started
2021-02-24 22:03:35 +00:00
```sh
$ npm install ldapjs
```
2011-08-24 19:38:23 +00:00
2015-10-16 05:25:49 +00:00
If you're new to LDAP, check out the [guide](guide.html). Otherwise, the
2011-08-24 19:38:23 +00:00
API documentation is:
2015-10-16 05:25:49 +00:00
|Section |Content |
|---------------------------|-------------------------------------------|
|[Server API](server.html) |Reference for implementing LDAP servers. |
|[Client API](client.html) |Reference for implementing LDAP clients. |
|[DN API](dn.html) |API reference for the DN class. |
|[Filter API](filters.html) |API reference for LDAP search filters. |
|[Error API](errors.html) |Listing of all ldapjs Error objects. |
|[Examples](examples.html) |Collection of sample/getting started code. |
2011-08-24 19:38:23 +00:00
# More information
2015-10-16 05:25:49 +00:00
- License:[MIT](http://opensource.org/licenses/mit-license.php)
- Code: [mcavage/node-ldapjs](https://github.com/mcavage/node-ldapjs)
- node.js version: >=0.8
- Twitter: [@pfmooney](http://twitter.com/pfmooney)
2011-08-24 19:38:23 +00:00
# What's 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.