Skip to content

jxjj/simple-ldap-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Nov 24, 2017
4136f21 · Nov 24, 2017

History

76 Commits
Nov 24, 2017
Nov 24, 2017
Apr 23, 2017
Apr 16, 2017
Dec 12, 2015
Dec 12, 2015
Aug 20, 2017
Apr 9, 2017
Sep 2, 2017
Nov 24, 2017
Nov 24, 2017

Repository files navigation

Simple LDAP Search

Travis Build NPM Version

Searches LDAP. Nothing fancy.

A thin, promisified wrapper over LDAPjs's client.

Installation

$ npm install --save simple-ldap-search

Usage

import SimpleLDAP from 'simple-ldap-search';

const config = {
  url: 'ldap://0.0.0.0:1389',
  base: 'dc=users,dc=localhost',
  dn: 'cn=root',
  password: 'secret',
}

// create a new client
const ldap = new SimpleLDAP(config);

// setup a filter and attributes for your LDAP query
const filter = '(uid=artvandelay)';
const attributes = [
  'idNumber',
  'uid',
  'givenName',
  'sn',
  'telephoneNumber',
];

// using async/await
const users = await ldap.search(filter, attributes);

// [{
//   dn: 'uid=artvandelay, dc=users, dc=localhost',
//   idNumber: 1234567,
//   uid: 'artvandelay',
//   givenName: 'Art',
//   sn: 'Vandelay',
//   telephoneNumber: '555-123-4567',
// }]

API

ldap.search(filter, attributes)

Parameters

  • filter: filters results.
  • attributes: a list of attributes to return

Returns

  • A promise for the results

ldap.destroy()

Destroys the connection to the LDAP server. Use when all done with LDAP client.