title: LDAP authentication using passport-ldapauth npm
body: <p>I am trying to authenticate openLDAP username and password using passport-ldapauth npm. While executing the below code I am always getting error as 
  <code>{ message: 'Missing credentials' }</code>. Kindly help me what is wrong with my code.</p>
  
  <pre><code>var connect = require('connect'),
      app = connect(),
      passport = require('passport'),
      LdapStrategy = require('passport-ldapauth');
  
  // Credentials from the free LDAP test server by forumsys
  // More info at: http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
  var OPTS = {
      server: {
          url: 'ldap://&lt;ip&gt;',
          bindDn: '&lt;admin username&gt;',
          bindCredentials: '&lt;admin password&gt;',
          usernameField: "&lt;passing actual username&gt;",
          passwordField: "&lt;password&gt;"
      }
  };
  
  passport.use(new LdapStrategy(OPTS));
  
  app.use(passport.initialize());
  
  
  app.use(connectRoute(function (router) {
          router.post('/login', function (req, res, next) {
              passport.authenticate('ldapauth', {session: false}, function (err, user, info) {
                  console.log(info);
                  if (err) {
                      return next(err); // will generate a 500 error
                  }
                  // Generate a JSON response reflecting authentication status
                  if (!user) {
                      return res.send({success: false, message: 'authentication failed'});
                  }
                  return res.send({success: true, message: 'authentication succeeded'});
              })(req, res, next);
          });
      }))
  
  app.listen(8080);
  </code></pre>
  
  <p>For more details, please see this <a href="https://www.npmjs.com/package/passport-ldapauth" rel="noreferrer">badRequestMessage flash message for missing username/password (default: 'Missing credentials')</a></p>