Created
August 24, 2016 03:02
-
-
Save yellowred/22f9989e3a951448c84ed8eab1f3c93d to your computer and use it in GitHub Desktop.
authenticate in LDAP
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
let authenticate = (userId, password) => { | |
return new Promise((resolve, reject) => { | |
const ldapClient = ldapjs.createClient(ldapOptions); | |
ldapClient.bind( | |
'cn=' + userId + ',' + ldapConfig.domain, | |
password, | |
(err, res) => { | |
if (err) { | |
//@see https://github.com/mcavage/node-ldapjs/blob/7059cf6b8a0b4ff4c566714d97f3cef04f887c3b/test/client.test.js @ 305 | |
return reject(err); | |
} | |
ldapClient.unbind(); | |
return resolve(res); | |
} | |
); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment