ldap.js
* This authentication adapter authenticates users against a LDAP server.
* @module greppy/auth/adapter/ldap
* @author Ralf Grawunder <r.grawunder@googlemail.com>
* @param {Object} options - Options of the LDAP authentication adapter
var LdapAuthAdapter = function(options)
* Authenticate a user with his credentials against a LDAP server.
* @param {String} user - username
* @param {String} credentials - password
* @param {Function} callback - Function to call when finished
LdapAuthAdapter.prototype.authentication = function(user, credentials, callback)
// Prepare the credentials mapping for ldapjs
self.options.ldap.bindCredentials = credentials;
// Prepare the configured userBindDN
self.options.ldap.bindDN = require('mustache').render(
var connectionInfo = self.options.ldap.bindDN.green.bold +
' @ ' + self.options.ldap.url.green.bold;
var ldapClientHelper = new (greppy.get('helper.ldap.client'))({
ldapClientHelper.connect(function(err) {
return callback && callback(err, false);
return callback && callback(null, true);