LDAP authentication with Node.JS

I’m a big fan of Node.JS.

It has a large collection of third party add-ons, but it lacked anything for LDAP authentication – something I need for web-apps.

So, I created a small library with a single function that authenticates a username/password against an LDAP server.

var ldapauth = require('ldapauth'); 

ldapauth.authenticate('some.host', 389, 'someuser', 'somepassword',
  function(err, result) {
    if (err) {
      print('Error');
    } else {
      print('Credentials valid = ' + result); // true or false
    }
  });

(Full example)

Under the hood it’s a native C++ module using¬†OpenLDAP.

To use it, grab the ldapauth.node binary and include in your Node path (or reference directly when calling require()). The binary is built for 64bit Linux – if you use another platform, you’ll have to get the code and build it yourself.

Comments are closed.
%d bloggers like this: