Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var ldap = require('ldapjs');
ldap.Attribute.settings.guid_format = ldap.GUID_FORMAT_D;
var LdapLookup = module.exports = function(options){
this._options = options;
this._client = ldap.createClient({
url: options.url,
maxConnections: 10,
bindDN: options.bindDN,
credentials: options.bindCredentials
});
this._client.on('error', function(e){
console.log('LDAP connection error:', e);
});
this._queue = [];
var ldap = require('ldapjs');
var LdapLookup = require('./LdapLookup');
ldap.Attribute.settings.guid_format = ldap.GUID_FORMAT_D;
var LdapValidator = module.exports = function(options){
this._options = options;
this._lookup = new LdapLookup(options);
};
LdapValidator.prototype.validate = function (username, password, callback) {
//lookup by username
this._lookup.search(username, function (err, up) {
if(err) return callback(err);
if(!up) return callback();
var client = ldap.createClient({ url: this._options.url });
//try bind by password
client.bind(up.dn, password, function(err) {
if(err) return callback(err);
callback(null, up);