Skip to content

Instantly share code, notes, and snippets.

@antonfisher
Last active April 4, 2016 16:29
Show Gist options
  • Save antonfisher/3ad7c5aa097e842b23d65b04d6086d72 to your computer and use it in GitHub Desktop.
Save antonfisher/3ad7c5aa097e842b23d65b04d6086d72 to your computer and use it in GitHub Desktop.
var ActiveDirectory = require('activedirectory');
var ad = new ActiveDirectory({
url: 'ldap://10.10.10.10',
baseDN: 'dc=domain,dc=com',
username: 'Administrator',
password: 'kokoko'
});
ad.findUser('', function (err, user) {
console.log('-- callback');
if (err) {
console.log('Error: ' + JSON.stringify(err));
} else {
console.log('User: ' + JSON.stringify(user));
}
});
// Double error issue:
// ===================
//
// activedirectory: ldapjs:
// ---------------- -------
//
// findUser()
// |
// v
// search()
// |
// v
// client ============================ createClient()
// |
// v
// retry = backoff.exponential()
// |
// x-----------------------------------x
// |
// v
// client.on('error', !callback!) ---> this.search()
// ^ ^ this.connect()
// | | |
// | | x-----------------x
// | | |
// | | v
// | | retry.on('ready', function)
// | | |
// | | v
// | | connectSocket()
// | | onConnect()
// | | setupClient()
// | | forEachPipeline()
// | | |
// | | v
// | | this.on('setup', function(err, cb))
// | | | |
// | | | v
// | | | retry.backoff(err)
// | | | |
// | | | x----------------x
// | | (Solution is get rid this)-->X |
// | | | v
// | | | retry.on('fail', function)
// | | | |
// | | | x-------------------x
// | | | |
// | | v v
// | | self.emit('error', err)
// | | | |
// | x---------------------------------------x |
// x-------------------------------------------x
//
//
// Fix:
// ====
//
// ldapjs/lib/client/client.js:348
//
// clt.bind(options.bindDN, options.bindCredentials, function (err) {
// if (err) {
// self.emit('error', err);
// }
// cb(err);
// });
//
// to
//
// clt.bind(options.bindDN, options.bindCredentials, cb);
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment