Created
October 9, 2021 15:20
-
-
Save ibrezm1/69fd03cb4a1df7f60caa9c7b682d0862 to your computer and use it in GitHub Desktop.
Active directory authentication using activedirectory module in Nodejs
This file contains hidden or 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://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