# ldap-ts-client

> Type-safe LDAP client written in typescript

Latest version **0.14.8** (published 2022-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install ldap-ts-client
pnpm add ldap-ts-client
yarn add ldap-ts-client
bun add ldap-ts-client
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.14.8 |
| Published | 2022-08-17 |
| First published | 2020-04-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 50.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Saeid Ostad |
| Maintainers | saostad |
| Keywords | ldap, typescript, client, active directory |

## Links

- npm: https://www.npmjs.com/package/ldap-ts-client
- Repository: https://github.com/saostad/ldap-ts-client
- Homepage: https://github.com/saostad/ldap-ts-client#readme
- Issues: https://github.com/saostad/ldap-ts-client/issues
- npm.io page: https://npm.io/package/ldap-ts-client

## Dependencies (3)

- [ldapjs](https://npm.io/package/ldapjs.md) ^2.3.3
- [@types/ldapjs](https://npm.io/package/@types/ldapjs.md) ^2.2.3
- [fast-node-logger](https://npm.io/package/fast-node-logger.md) ^3.0.3

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.14.8 (latest) — 2022-08-17
- 0.14.7 — 2022-08-16
- 0.14.6 — 2022-08-16
- 0.14.5 — 2022-07-19
- 0.14.4 — 2022-07-11
- 0.14.3 — 2021-03-03
- 0.14.2 — 2020-12-10
- 0.14.0 — 2020-06-10
- 0.13.1 — 2020-06-04
- 0.13.0 — 2020-06-04
- 0.12.0 — 2020-06-04
- 0.11.1 — 2020-06-04
- 0.11.0 — 2020-06-04
- 0.10.2 — 2020-04-19
- 0.10.1 — 2020-04-19
- … 28 more at https://npm.io/package/ldap-ts-client/versions

## README

# Type-safe Promise base LDAP Client

LDAP Client to do low level promise base interaction with ldap server

- Promise based functions
- type-safe with [Typescript](https://www.typescriptlang.org/)

## How to use it:

- `npm i ldap-ts-client`

```ts
import { IClientConfig, LdapClient } from "ldap-ts-client";

const config: IClientConfig = {
  url: "ldap://Domain.com" /** Domain name here */,
  bindDN: "{USER_NAME}" /** user name to connect to AD server */,
  secret: "{PASSWORD}" /** password for account */,
  baseDN: "{ROOT_OF_TREE}" /** root of tree that want to query */,
};

const client = new LdapClient(config);

// do something with client!

// always free-Up after you done the job!
client.unbind();
```

## API Documentation

for full API documentation look at [API Website](https://saostad.github.io/ldap-ts-client/).

## functionalities:

#### async queryAttributes()

```ts
/** get displayName of all users */
const users = await client.queryAttributes({
  attributes: ["displayName"],
  options: {
    filter:
      "(&(|(objectClass=user)(objectClass=person))(!(objectClass=computer))(!(objectClass=group)))",
    scope: "sub",
    paged: true,
  },
});

// always unbind after finish the operation to prevent memory leak
client.unbind();
```

### Advance Uses:

#### async query() (raw search to provided full flexibility)

```ts
/** get displayName and distinguished name  of empty groups */
const groups = await client.query({
  attributes: ["displayName", "dn"],
  options: {
    filter: "(&(objectClass=group)(!(member=*)))",
    scope: "sub",
    paged: true,
  },
});

// always unbind after finish the operation to prevent memory leak
client.unbind();
```

#### async bind() to access underlying api. returns a connected [ldap.js](http://ldapjs.org/) client.

#### NOTICE: lpad.js is using node EventEmitters not ES6 Promises

```ts
client.bind().then((client) => {
  client.search(this.config.baseDN, opts, (err, res) => {
    if (err) {
      reject(err);
    }
    res.on("searchEntry", (entry) => {});
    res.on("error", (err) => {});
    res.on("end", function (result) {
      client.unbind();
    });
  });
});
```

## TODO

- [ ] remove dependency to [ldap.js](http://ldapjs.org/) package
- [ ] add Windows Integrated Authentication [Kerberos](https://github.com/mongodb-js/kerberos)

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