title: passport-ldapauth is not working properly
body: <p>I have setup LDAP server in my local system by this link <a href="https://www.digitalocean.com/community/articles/how-to-install-and-configure-a-basic-ldap-server-on-an-ubuntu-12-04-vps" rel="nofollow noreferrer">How To Install and Configure a Basic LDAP Server </a>. I mange to get LDAP server run and able to add group, user, etc through <code>phpldapadmin</code>. I have added a user as shown in this image<img src="https://i.stack.imgur.com/CcKJV.png" alt="enter image description here"></p>
  
  <p>To confirm the user in LDAP server I used below command </p>
  
  <pre><code>$ ldapsearch -x -W -D 'cn=thiru niren,cn=users,ou=group,dc=test,dc=com' -b "" -s base -H ldap://192.168.2.4
  </code></pre>
  
  <p>It asked me for password then I entered password and I get result</p>
  
  <pre><code>Enter LDAP Password: 
  # extended LDIF
  #
  # LDAPv3
  # base &lt;&gt; with scope baseObject
  # filter: (objectclass=*)
  # requesting: ALL
  #
  
  #
  dn:
  objectClass: top
  objectClass: OpenLDAProotDSE
  
  # search result
  search: 2
  result: 0 Success
  
  # numResponses: 2
  # numEntries: 1
  </code></pre>
  
  <p>Then I tried to use <a href="https://github.com/vesse/passport-ldapauth" rel="nofollow noreferrer">passport-ldapauth</a> module. Code I have written for this is </p>
  
  <pre><code>var LdapStrategy = require('passport-ldap').Strategy,
      passport = require('passport');
  
  passport.use(new LdapStrategy({server: {
                url: 'ldap://192.168.2.4',
          adminDn:'cn=thiru niren,cn=users,ou=group,dc=test,dc=com',
          adminPassword: 'infra'
          }},
          function(user, done) {
              console.log("user authenticated or not");
              return done(null, user);
          }
  ));
  console.log("check ldap");
  </code></pre>
  
  <p>After I execute this code, I see only <code>check ldap</code> and a keep on blinking cursor in <code>terminal</code>. Then I put up <code>console.log("user authenticated or not");</code> to verify whether <code>LdapStrategy</code> is call <code>callback</code> function or not but I don't see <code>user authenticated or not</code> in console but <code>check ldap</code>. What would be the problem? why <code>passport-ldapaut</code> is don't get any response from ldap server?</p>
  
  <p>I'm using ubuntu 14.04 LTS.
  node --version is v0.10.28.</p>
  
  <p><strong>Update:</strong>
  I tried with <a href="https://www.npmjs.org/package/ldapauth" rel="nofollow noreferrer">ldapauth</a> module as well but no luck I get same result, check my modified code of above mentioned website</p>
  
  <pre><code>var connect = require('connect');
  var LdapAuth = require('ldapauth');
  
  // Config from a .json or .ini file or whatever.
  var config = {
    ldap: {
      url: "ldap://192.168.2.4:389",
      adminDn: "cn=thiru niren,cn=users,ou=group,dc=test,dc=com",
      adminPassword: "infra",
      searchBase: "ou=group,dc=test,dc=com",
      searchFilter: "(uid=tniren)"
    }
  };
  
  var ldap = new LdapAuth({
    url: config.ldap.url,
    adminDn: config.ldap.adminDn,
    adminPassword: config.ldap.adminPassword,
    searchBase: config.ldap.searchBase,
    searchFilter: config.ldap.searchFilter,
    //log4js: require('log4js'),
    cache: true
  });
  //console.log("we here",ldap);
  var basicAuthMiddleware = connect.basicAuth(function (username, password, callback) {
      console.log("we");
    ldap.authenticate(username, password, function (err, user) {
      console.log("we are");
      if (err) {
        console.log("LDAP auth error: %s", err);
      }
      callback(err, user)
    });
  });
  </code></pre>
  
  <p>Here also I don't get any response from <code>ldap</code> server, is there any problem with server?</p>