node-ldapjs/README.md

57 lines
1.1 KiB
Markdown
Raw Normal View History

2014-07-06 16:55:33 +00:00
# LDAPjs
[!['Build status'][travis_image_url]][travis_page_url]
2018-01-27 20:15:33 +00:00
[travis_image_url]: https://api.travis-ci.org/joyent/node-ldapjs.svg
[travis_page_url]: https://travis-ci.org/joyent/node-ldapjs
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
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
DTrace support is included in ldapjs. To enable it, `npm install dtrace-provider`
2011-08-04 20:32:01 +00:00
## License
MIT.
## Bugs
See <https://github.com/mcavage/node-ldapjs/issues>.