Skip to content

Instantly share code, notes, and snippets.

@yellowred
Created August 24, 2016 03:02
Show Gist options
  • Save yellowred/22f9989e3a951448c84ed8eab1f3c93d to your computer and use it in GitHub Desktop.
Save yellowred/22f9989e3a951448c84ed8eab1f3c93d to your computer and use it in GitHub Desktop.
authenticate in LDAP
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