Skip to content

Instantly share code, notes, and snippets.

@arturokunder
Created August 25, 2016 15:35
Show Gist options
  • Save arturokunder/49ff37b9f0d5cb0918ea714a7a76385b to your computer and use it in GitHub Desktop.
Save arturokunder/49ff37b9f0d5cb0918ea714a7a76385b to your computer and use it in GitHub Desktop.
ActiveDirectory/LDAP Authentication test
{
"name": "ad_test",
"version": "1.0.0",
"description": "ActiveDirectory/LDAP user authentication test",
"main": "test.js",
"dependencies": {
"activedirectory": "^0.7.2"
},
"devDependencies": {},
"author": "arturokunder",
"license": "MIT"
}
var activedirectory = require('activedirectory');
var config = {
url: 'ldap://example.com', // AD url
baseDN: 'cn=users,dc=domain,dc=example,dc=com' // ldap search query string
username: 'user', // username for connection (can be empty, depending on AD configuration)
passsword: 'pass' // pass for user (can be empty, depending on user configuration)
};
var ad = new ActiveDirectory(config);
var username = 'AUTH_USER'; // User to be authenticated
var pass = 'AUTH_PASS'; // Password for the user
ad.authenticate(username, password, function(err, auth) {
if(err) {
console.log('ERROR: ' + JSON.stringofy(err));
return;
}
if(auth) {
console.log('Authenticated!');
} else {
console.log('Authentication failed');
}
});
@arturokunder
Copy link
Author

To run the test:

npm install
node test.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment