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

adldap

v3.1.5

Published

A light weight interface to Active Directory based on LDAPjs

Downloads

149

Readme

adldap

This is a simple wrapper around ldapjs for basic operations against an Active Directory instance. If you're looking for a robust interface, you may be interested in activedirectory2.

What can you do with adldap?

  • Issue generic searches
  • Find users
  • Authenticate arbitrary users
  • Determine if a user is a member of a specific group
  • Update specific attribute values

This library was written because activedirectory2 pulls back too much data when retreiving groups. I merely need the list of names; activedirectory2 pulls back much more information than that.

If I ever get the time and desire, I may flesh out this library more. Pull requests are always welcome.

Example

const adldapFactory = require('adldap')()
const client = adldapFactory({
  searchUser: 'dn=Generic Searcher,ou=accounts,dn=example,dn=com',
  searchUserPass: 'supersecret',
  ldapjs: {
    url: 'ldaps://ad.example.com',
    searchBase: 'dn=example,dn=com',
    scope: 'sub'
  }
})

// You must bind before you can do anything else.
client.bind()
  .then(() => {
    client.findUser('someUser')
      .then((user) => console.log(user.memberOf))
      .catch((err) => console.error(err))
      .then(() => client.unbind())
  })
  .catch((err) => console.error(err))

You could also "flatten" the code via Bluebird and bluebird-co:

const Promise = require('bluebird')
require('bluebird-co')

function * doItGenerator () {
  try {
    yield client.bind()

    const user = yield client.findUser('someUser')
    console.log(user.memberOf)

    yield client.unbind()
  } catch (e) {
    console.error(e.message)
  }
}

const doIt = Promise.coroutine(doItGenerator)
doIt()

Config

  • searchUser: A fully qualified DN to a user that can perform searches against your Active Directory.
  • searchUserPass: The search user's password, obviously.
  • ldapjs
    • url: The URL to your Active Directory in LDAP format.
    • searchBase: Default search base to use for all searches unless overridden by a method's options.
    • scope: The default search scope to use for all searches unless overridden by a method's options. Can be 'base', 'one', or 'sub'. Defaults to 'base'. (optional)
    • attributes: An array of default attributes to return with searches. The default list is ['dn', 'cn', 'sn', 'givenName', 'mail', 'memberOf']. If overridden by a method, you must supply the complete list of attributes you want. (optional)

Methods

The full documentation is included in the api.md document.

  • authenticate(username, password)
  • bind()
  • findUser(username, options)
  • search(base, options, controls)
  • unbind()
  • userInGroup(username, groupName)
  • replace(dn, change)
  • replaceAttribute(cn, attribute, value)
  • incrementAttribute(cn, attribute)

License

MIT License