Skip to content

Instantly share code, notes, and snippets.

@prodehghan
Created March 18, 2020 16:00
Show Gist options
  • Save prodehghan/5fb96403404e73f28b7763b48d92cb4f to your computer and use it in GitHub Desktop.
Save prodehghan/5fb96403404e73f28b7763b48d92cb4f to your computer and use it in GitHub Desktop.
A test for active directory authentication, using "ldapauth-fork" library
var LdapAuth = require('ldapauth-fork');
var ldap = new LdapAuth({
url: 'ldap://sgdc.SYSTEMGROUP.NET',
bindDN: "[email protected]",//"CN=MohammadHasan Dehghan,OU=Users,OU=MIS,OU=VNK,OU=SG Main,DC=systemgroup,DC=net",
bindCredentials: 'your_password', // <-- supply a valid email and password
searchBase: 'DC=systemgroup,DC=net',
searchFilter: '(|(samaccountname={{username}})(mail={{username}}))',
reconnect: true
});
ldap.authenticate('user_name', 'password', function (err, user) {
if (err) {
return console.log(err);
}
else {
console.log('succeeded:');
console.log(user);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment