minor doc/readme update

This commit is contained in:
Mark Cavage 2011-08-24 21:46:31 -07:00
parent d9b6a07be9
commit facf477fe8
2 changed files with 19 additions and 22 deletions

View File

@ -1,4 +1,4 @@
ldapjs makes the LDAP protocol a first class citizen in node.js.
ldapjs makes the LDAP protocol a first class citizen in Node.js.
## Usage
@ -8,24 +8,16 @@ For full docs, head on over to <http://ldapjs.org>.
var server = ldap.createServer();
server.bind('cn=root', function(req, res, next) {
if (req.credentials !== 'secret')
return next(new ldap.InvalidCredentialsError());
res.end();
});
server.search('dc=example', function(req, res, next) {
var obj = {
dn: req.dn.toString(),
attributes: {
objectclass: 'helloworld',
cn: 'hello',
sn: 'world'
objectclass: ['organization', 'top'],
o: 'example'
}
};
if (req.filter.matches(obj))
if (req.filter.matches(obj.attributes))
res.send(obj);
res.end();
@ -35,14 +27,14 @@ For full docs, head on over to <http://ldapjs.org>.
console.log('ldapjs listening at ' + server.url);
});
To run that, assuming you've got the [OpenLDAP](http://www.openldap.org/) client on
your system:
To run that, assuming you've got the [OpenLDAP](http://www.openldap.org/) client
on your system:
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -b dc=example objectclass=*
ldapsearch -H ldap://localhost:1389 -x -b dc=example objectclass=*
## Installation
For now this is not published to npm. Use at your own risk.
npm install ldapjs
## License

View File

@ -17,16 +17,21 @@ ldapjs is a pure JavaScript, from-scratch framework for implementing
[Node.js](http://nodejs.org). It is intended for developers used to interacting
with HTTP services in node and [express](http://expressjs.com).
var server = require('ldapjs').createServer();
var ldap = require('ldapjs');
var server = ldap.createServer();
server.search('o=example', function(req, res, next) {
res.send({
dn: 'o=example',
var obj = {
dn: req.dn.toString(),
attributes: {
o: ['example'],
objectclass: ['organization', 'top']
objectclass: ['organization', 'top'],
o: 'example'
}
});
};
if (req.filter.matches(obj.attributes))
res.send(obj);
res.end();
});