
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@cs125/promised-ldap
Advanced tools
A thin wrapper over ldapjs to give a promise interface and a couple of other goodies
This library is a quick-n-dirty shim over ldapjs to add promises and easier authentication. It currently only supports the client interface.
To create a new client:
var LdapClient = require('promised-ldap');
var client = new LdapClient({url: 'ldap://127.0.0.1:389'});
The options argument to the constructor is identical to the options argument used in ldapjs
for
ldap.createClient
. Please see the docs here.
It supports the other methods documented there as well, except that instead of taking a callback, the methods return a promise. E.g.:
client.bind('username', 'password').then(function () { ... });
The search
method in ldapjs
is now accessible (in promisified form) by client._search
. I
have provided a method client.search
with similar behaviour as the original but an arguably
easier API. E.g.:
client.search(base, options).then(function (result) {
/* result is:
{
entries: [...],
references: [...]
}
no messing about with EventEmitters!
*/
});
Let's face it, the reason why you're messing about with LDAP is probably to add LDAP authentication to your app, so I've added a couple of helper method for this:
client.authenticate(base, cn, password).then(function (result) {
// if the authentication succeeded, then result is the LDAP user object
// otherwise, it is null
});
This basically does a bind
using the supplied credentials, and if successful, does a search
for
the specified user and returns that.
If all you really wanted was the user's name, email address, and list of unqualified groups, we can do that too:
client.authenticateUser(base, cn, password).then(function (result) {
/*
if the authentication succeeded, then result is:
{
name: <the user's DisplayName>,
email: <the user's PrincipalName>,
groups: <an array of the CNs of groups which are in the base CN>
}
otherwise, result is null
*/
});
Pull requests and suggestions are welcome!
FAQs
A thin wrapper over ldapjs to give a promise interface and a couple of other goodies
The npm package @cs125/promised-ldap receives a total of 1 weekly downloads. As such, @cs125/promised-ldap popularity was classified as not popular.
We found that @cs125/promised-ldap demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.