Skip to content

Instantly share code, notes, and snippets.

@ibrezm1
Created October 9, 2021 15:20
Show Gist options
  • Select an option

  • Save ibrezm1/69fd03cb4a1df7f60caa9c7b682d0862 to your computer and use it in GitHub Desktop.

Select an option

Save ibrezm1/69fd03cb4a1df7f60caa9c7b682d0862 to your computer and use it in GitHub Desktop.
Active directory authentication using activedirectory module in Nodejs
var ActiveDirectory = require('activedirectory');
var config = { url: 'ldap://ldap.forumsys.com',
bindDN: 'cn=read-only-admin,dc=example,dc=com',
baseDN:'ou=mathematicians,dc=example,dc=com',
password: 'password' }
var ad = new ActiveDirectory(config);
var username = 'uid=gauss,dc=example,dc=com';
var password = 'password';
ad.authenticate(username, password, function(err, auth) {
if (err) {
console.log('ERROR: '+JSON.stringify(err));
return;
}
if (auth) {
console.log('Authenticated!');
}
else {
console.log('Authentication failed!');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment