Created
August 25, 2016 15:35
-
-
Save arturokunder/49ff37b9f0d5cb0918ea714a7a76385b to your computer and use it in GitHub Desktop.
ActiveDirectory/LDAP Authentication test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run the test: