Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ldapjs-promise-cel

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldapjs-promise-cel

A simple promise wrapper around ldapjs with client event listener

  • 1.2.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
36
decreased by-60.44%
Maintainers
1
Weekly downloads
 
Created
Source

ldapjs-promise-cel

Build Status

LDAP Client and Server API for node.js with Promise support.

This is a simple wrapper around ldapjs for basic operations.

Installation

npm install --save ldapjs-promise-cel

Usage

For full docs, head on over to http://ldapjs.org.

The methods signatures are the same except instead of callbacks they return promises.

import * as ldap from 'ldapjs-promise-cel';

const client = ldap.createClient({
  url: 'ldap://127.0.0.1:1389',
  clientEventListener: (err) => {
      console.log(err);
  }
});
await client.bind(dn, password);

The ldapjs authors made the search method a special method that returns an EventEmitter so the user can handle each searchEntry as it is returned. Since this library is just wrapping ldapjs, it does not make any assumptions and returns the same EventEmitter. cel version - added createClient(options.clientEventListener) function register, that adds to the underlying ldapjs client client.on('error', clientEventListener), so it can handle connection resets and other extreme cases.

In order to await all of the results you could:

const results = client.search(base, options, controls).then(response => {
    const entries = [];
    let referrals = [];
    return new Promise((resolve, reject) => {
        response.on('searchEntry', entry => {
            entries.push(entry.object);
        });
        response.on('searchReference', referral => {
            referrals = referrals.concat(referral.uris);
        });
        response.on('error', error => {
            return reject(error);
        })
        response.on('end', result => {
            if (result.status !== 0) {
                return reject(result.status);
            }

            return resolve({
                entries: entries,
                referrals: referrals
            });
        });
    });
});

If this is exactly what you want, an extension method searchReturnAll has been added that does this.

const results = await client.searchReturnAll(base, options, controls);
for (let entry of results.entries) {
    ...
}

Additional Methods

  • findUser(base, username, options)
  • userInGroup(base, username, groupName)

Keywords

FAQs

Package last updated on 11 May 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc