npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ldapper

v1.0.9

Published

Node module that provides an ldapjs client

Downloads

4

Readme

Ldapper 1.x

Node module that provides wrapper methods for ldapjs client.

Installation

In your project root run from command line:

$ npm install -save ldapper

Example

Let's start! Include in your node application ldapper module:

//require object
var Ldapper = require('ldapper').Ldapper;
//or require factory
var factory = require('ldapper');

//create options
var options = {
  domainControllers: ['192.168.99.100'],
  searchScope: 'ou=users,dc=acme,dc=com',
  root: {
    dn: 'cn=admin,dc=acme,dc=com',
    password: {
      crypton: false,
      value: 'admin'
    }
  }     
};

//create an instance
var ldappermanager1 = new Ldapper(options);
//or use factory
var ldappermanager2 = factory.create(options);

ldappermanager1.find('|(cn=test*)(sn=test*)')
.then(function(res) {
  console.log(res);
});

Documentation

Construction

A Ldapper instance can be created using factory or using the new keyword.

var factory = require('ldapper');
var ldappermanager1 = factory.create();
//or
var Ldapper = require('ldapper').Ldapper;
var ldappermanager2 = new Ldapper();

new Ldapper( [options] ) : Object

The ldapper module can be initialized with a configuration object.

Arguments

[options] {Object} Optional configuration

Returns

{Object} Get an instance

The configuration object allows you to overrides default values. If you don't specify any configuration, it uses a default object:

{
  domainControllers: [],
  searchScope: null,
  searchOptions: {
    scope: 'sub',
    filter: '(objectclass=*)',
    attributes: [],
    sizeLimit: 0,
    paged: false
  },
  root: {
    dn: null,
    password: {
      crypton: false,
      value: null
    }
  },
  crypton: null,
  ssl: false,
  timeout: null,
  connectTimeout: null,
  strictdn: false
}

Methods

find( [filter], [attributes], [searchDn], [options] ) : Promise( Array )

Search entries from ldap.

Arguments

[filter]      {string} An ldap filter
[attributes]  {Array} Specify returned attributes
[searchDn]    {string} Search path
[options]     {object} Overrides configuration for searchOptions

Returns

{Array} Returns a list of entries

Throws

{LDAPSearchError}

findOne( dn, [attributes], [options] ) : Promise( Object )

Get an entry from ldap.

Arguments

dn            {string} Distinguished name
[attributes]  {Array} Specify returned attributes
[options]     {object} Overrides configuration for searchOptions

Returns

{Object} Returns the entry

Throws

{LDAPSearchError}

findGuid( guid, [attributes], [options] ) : Promise( Object )

Get an entry from Active Directory by objectGuid.

Arguments

guid          {string|Buffer} Object guid
[attributes]  {Array} Specify returned attributes
[options]     {object} Overrides configuration for searchOptions

Returns

{Object} Returns the entry

Throws

{LDAPSearchError}

findSid( sid, [attributes], [options] ) : Promise( Object )

Get an entry from Active Directory by objectSid.

Arguments

sid           {string|Buffer} Object sid
[attributes]  {Array} Specify returned attributes
[options]     {object} Overrides configuration for searchOptions

Returns

{Object} Returns the entry

Throws

{LDAPSearchError}

add( dn, [entry] ) : Promise( bool )

Create a new entry into ldap.

Arguments

dn      {string} Distinguished name to create
[entry] {Object} Attributes to set on ldap for entry

Returns

{bool} Returns success

Throws

{LDAPAddError}

change( dn, changes ) : Promise( Object )

Change an entry into ldap. The list of changes must be an object with these attributes:

  • op one of these values [write | append | delete]
  • attr the ldap attribute name to change
  • val the ldap value to add/replace
//Example:
var changes = [
  //Add a new value or replace the old value if exists
  { op: 'write', attr: 'cn', val: 'test' },
  //Append values to the attribute
  { op: 'append', attr: 'mail', val: '[email protected]' },
  { op: 'append', attr: 'mail', val: '[email protected]' },
  //Delete all values for the given attribute
  { op: 'delete', attr: 'loginShell' }
  //Delete only the value specified
  { op: 'delete', attr: 'mail', val: '[email protected]' }
]

Arguments

dn        {string} Distinguished name to change
[changes] {Array|Object} A list of changes or a single change

Returns

{Object} Returns the changed entry

Throws

{LDAPChangeError}

rename( dn, newDn ) : Promise( bool )

Rename an entry into ldap.

Arguments

dn      {string} Old distinguished name
newDn   {string} New distinguished name

Returns

{bool} Returns success

Throws

{LDAPRenameError}

delete( dn ) : Promise( bool )

Delete an entry from ldap.

Arguments

dn  {string} Distinguished name to delete

Returns

{bool} Returns success

Throws

{LDAPDeleteError}

authenticate( username, password, [authAttributes], [retAttribute], [searchDn] ) : Promise( Object )

Check if given credentials are valid on ldap.

Arguments

username          {string} The username
password          {string} The password
[authAttributes]  {Array|string} Specify which attributes using for authentication
[retAttribute]    {Array|string} Specify returned attributes
[searchDn]        {string} Search path

Returns

{Object} Returns an object

Throws

{LDAPAuthenticationError}

License

The MIT License

Copyright (c) 2017 Michele Andreoli http://thinkingmik.com