diff --git a/README.md b/README.md index cd9192f..66822ed 100644 --- a/README.md +++ b/README.md @@ -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 . 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 . 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 diff --git a/docs/index.md b/docs/index.md index d017167..e881198 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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(); });