2014-07-06 16:55:33 +00:00
|
|
|
# LDAPjs
|
2013-10-25 11:59:39 +00:00
|
|
|
|
2020-11-13 04:34:41 +00:00
|
|
|
[![Build Status](https://github.com/ldapjs/node-ldapjs/workflows/Lint%20And%20Test/badge.svg)](https://github.com/ldapjs/node-ldapjs/actions)
|
|
|
|
[![Coverage Status](https://coveralls.io/repos/github/ldapjs/node-ldapjs/badge.svg)](https://coveralls.io/github/ldapjs/node-ldapjs/)
|
2013-10-25 07:32:50 +00:00
|
|
|
|
2014-07-06 16:55:33 +00:00
|
|
|
LDAPjs makes the LDAP protocol a first class citizen in Node.js.
|
2011-08-15 20:50:15 +00:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
For full docs, head on over to <http://ldapjs.org>.
|
|
|
|
|
2014-07-06 16:55:33 +00:00
|
|
|
```javascript
|
|
|
|
var ldap = require('ldapjs');
|
2011-08-15 20:50:15 +00:00
|
|
|
|
2014-07-06 16:55:33 +00:00
|
|
|
var server = ldap.createServer();
|
2011-08-15 20:50:15 +00:00
|
|
|
|
2014-07-06 16:55:33 +00:00
|
|
|
server.search('dc=example', function(req, res, next) {
|
|
|
|
var obj = {
|
|
|
|
dn: req.dn.toString(),
|
|
|
|
attributes: {
|
|
|
|
objectclass: ['organization', 'top'],
|
|
|
|
o: 'example'
|
|
|
|
}
|
|
|
|
};
|
2011-08-15 20:50:15 +00:00
|
|
|
|
2014-07-06 16:55:33 +00:00
|
|
|
if (req.filter.matches(obj.attributes))
|
|
|
|
res.send(obj);
|
2011-08-15 20:50:15 +00:00
|
|
|
|
2014-07-06 16:55:33 +00:00
|
|
|
res.end();
|
|
|
|
});
|
2011-08-15 20:50:15 +00:00
|
|
|
|
2014-07-06 16:55:33 +00:00
|
|
|
server.listen(1389, function() {
|
|
|
|
console.log('ldapjs listening at ' + server.url);
|
|
|
|
});
|
|
|
|
```
|
2011-08-15 20:50:15 +00:00
|
|
|
|
2015-06-15 01:51:14 +00:00
|
|
|
To run that, assuming you've got the [OpenLDAP](http://www.openldap.org/)
|
|
|
|
client on your system:
|
2011-08-15 20:50:15 +00:00
|
|
|
|
2011-08-25 04:46:31 +00:00
|
|
|
ldapsearch -H ldap://localhost:1389 -x -b dc=example objectclass=*
|
2011-08-04 20:32:01 +00:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2011-08-25 04:46:31 +00:00
|
|
|
npm install ldapjs
|
2014-07-06 16:55:33 +00:00
|
|
|
|
2011-08-04 20:32:01 +00:00
|
|
|
## License
|
|
|
|
|
|
|
|
MIT.
|
|
|
|
|
|
|
|
## Bugs
|
|
|
|
|
2019-08-27 19:28:07 +00:00
|
|
|
See <https://github.com/ldapjs/node-ldapjs/issues>.
|