title: ldap authentication in nodejs
body: <p>I am trying to authenticate LDAP user using the below code. The code was working fine in Node v10.X. I have migrated my app to <strong>Node v4.1.1</strong> where I am not able to install <strong>ldapjs</strong> npm. </p>
  
  <blockquote>
    <p>Can someone help me with any LDAP npm which works in Nodev4.1.1</p>
  </blockquote>
  
  <pre><code>var ldap = require('ldapjs');
  
  function authDN(dn, password, cb) {
    var client = ldap.createClient({url: 'ldap://YOUR_SERVER:PORT'});
  
    client.bind(dn, password, function (err) {
      client.unbind();
      cb(err === null, err);
    });
  }
  
  
  function output(res, err) {
    if (res) {
      console.log('success');
    } else {
      console.log('failure');
    }
  }
  
  // should print "success"
  authDN('cn=user', 'goodpasswd', output);
  </code></pre>