# adldap

> A light weight interface to Active Directory based on LDAPjs

Latest version **3.1.5** (published 2018-04-17) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install adldap
pnpm add adldap
yarn add adldap
bun add adldap
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.1.5 |
| Published | 2018-04-17 |
| First published | 2016-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 82.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | James Sumners |
| Maintainers | jsumners |
| Keywords | ldap, ad, active-directory, activedirectory |

## Links

- npm: https://www.npmjs.com/package/adldap
- Repository: https://github.com/jsumners/adldap
- Issues: https://github.com/jsumners/adldap/issues
- npm.io page: https://npm.io/package/adldap

## Dependencies (5)

- [joi](https://npm.io/package/joi.md) ^10.5.2
- [ldapjs](https://npm.io/package/ldapjs.md) ^1.0.1
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.0
- [bluebird-co](https://npm.io/package/bluebird-co.md) ^2.1.2
- [abstract-logging](https://npm.io/package/abstract-logging.md) ^1.0.0

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 3.1.5 (latest) — 2018-04-17
- 3.1.4 — 2017-10-12
- 3.1.3 — 2017-07-19
- 3.1.2 — 2017-06-01
- 3.1.1 — 2017-04-11
- 3.1.0 — 2017-04-11
- 3.0.1 — 2017-03-07
- 3.0.0 — 2017-02-24
- 2.0.0 — 2016-08-02
- 1.0.1 — 2016-08-02
- 1.0.0 — 2016-07-20
- 0.1.1 — 2016-04-27
- 0.1.0 — 2016-04-27

## README

# adldap

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

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.

[ldapjs]: https://www.npmjs.com/package/ldapjs
[ad2]: https://www.npmjs.com/package/activedirectory2

## Example

```javascript
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][bb] and [bluebird-co][bbco]:

```js
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()
```

[bb]: http://bluebirdjs.com/
[bbco]: https://www.npmjs.com/package/bluebird-co

## 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](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](http://jsumners.mit-license.org/)

---
_Source: https://npm.io/package/adldap · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
