How to use the ldapjs.InvalidCredentialsError function in ldapjs

To help you get started, we’ve selected a few ldapjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flamencist / ldap4net / .test_config / index.js View on Github external
server.bind(SUFFIX, function(req, res, next) {
  console.log(req.dn.toString());
  var dn = req.dn.toString().replaceSpaces();
  if (!db[dn]){
	  return next(new ldap.NoSuchObjectError(dn));
  }
  if (!db[dn].userpassword)
    return next(new ldap.NoSuchAttributeError('userPassword'));

  if (db[dn].userpassword.indexOf(req.credentials) === -1){
    return next(new ldap.InvalidCredentialsError());
  }
  res.end();
  return next();
});
github 4minitz / 4minitz / tests / support / ldap-server.js View on Github external
let matchingUsers = _.filter(users, user => normalizedDn == user.dn);

    console.log(matchingUsers);

    if (matchingUsers.length > 1) {
        return next(new ldap.UnwillingToPerformError());
    }

    if (matchingUsers.length == 0) {
        return next(new ldap.NoSuchObjectError(dn));
    }

    let user = matchingUsers[0];

    if (user.password != password) {
        return next(new ldap.InvalidCredentialsError());
    }

    res.end();
    return next();
});
github PhilWaldmann / openrecord / test / ldap / __server.js View on Github external
server.bind(SUFFIX, function(req, res, next) {
    var dn = req.dn
      .toString()
      .replace(/, /g, ',')
      .toLowerCase()
    if (!db[dn]) {
      return next(new ldap.NoSuchObjectError(dn))
    }

    if (!db[dn].userpassword) {
      return next(new ldap.NoSuchAttributeError('userPassword'))
    }

    if (db[dn].userpassword.indexOf(req.credentials) === -1) {
      return next(new ldap.InvalidCredentialsError())
    }

    res.end()
    return next()
  })
github codingchili / kibana-mithril / test / mock / ldap.js View on Github external
function authenticateAdmin(req, res, next) {
    if (req.credentials === Mock.PASSWORD_WRONG) {
        return next(new LDAP.InvalidCredentialsError());
    } else {
        res.end();
        return next();
    }
}
github trueaccord / FallingRock / server.js View on Github external
server.bind(config.admin.username, function(req, res, next) {
        if (!req.dn.equals(config.admin.username)) {
            winston.info('Got a bind for a child of the admin user: %s', req.dn.toString());
            return next(new ldap.NoSuchObjectError(req.dn.toString()));
        }
        if (req.credentials !== config.admin.password) {
            winston.info('Got invalid credentials for admin user.');
            return next(new ldap.InvalidCredentialsError());
        }
        res.end();
        return next();
    });
github parse-community / parse-server / spec / MockLdapServer.js View on Github external
server.bind('o=example', function(req, res, next) {
    if (req.dn.toString() !== dn || req.credentials !== 'secret')
      return next(new ldapjs.InvalidCredentialsError());
    res.end();
    return next();
  });
github conjurinc / teleport / lib / ldap.js View on Github external
server.bind('ou=layers,o=teleport', function(req, res, next) {
  	if ( 3 === keys(req.rdns).length && req.rdns.cn )
  		require('./ldap/bindLayer')(req, res, next);
  	else
  		next(new ldap.InvalidCredentialsError("Invalid login"));
  });
  server.unbind(function(req, res, next) {
github trueaccord / FallingRock / server.js View on Github external
function(r) {
                next(new ldap.InvalidCredentialsError(dn));
            });
    });
github marklogic-community / marklogic-samplestack / appserver / node-express / lib / ldapWorker.js View on Github external
server.bind(SUFFIX, function (req, res, next) {
  var dn = req.dn.toString();
  if (!db[dn]) {
    return next(new ldap.NoSuchObjectError(dn));
  }

  if (!db[dn].attributes.userPassword) {
    return next(new ldap.NoSuchAttributeError('userPassword'));
  }

  if (db[dn].attributes.userPassword !== req.credentials) {
    return next(new ldap.InvalidCredentialsError());
  }

  res.end();
  return next();
});
github conjurinc / teleport / lib / dataStore.js View on Github external
function authenticate(layer, credential, callback) {
	var password = process.env[format('LDAP_LAYER_%s_PASSWORD', layer.toUpperCase())];
	if ( password && credential === password )
		callback(null, password)
	else
		callback(new ldap.InvalidCredentialsError("Invalid login for layer " + layer));
}