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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ldapha

v1.0.15

Published

A very simple LDAP client to for authentication and managing password

Readme

ldapha

Lightweight LDAP helper for Active Directory password changes and simple searches
Built on top of ldapts · Promise-based · Minimal API

Features

  • Change user passwords in Active Directory (self-service & admin reset)
  • Simple LDAP search / list operations
  • Automatic connection & clean unbind
  • Works with both ldap:// and ldaps://
  • TypeScript-friendly (ships with types)
  • Very small surface area — ideal for password reset forms & user portals

Installation

npm install ldapha
# or
yarn add ldapha
# or
pnpm add ldapha

Usage

1. Import & Initialize

import ldapha from 'ldapha';
// or
const ldapha = require('ldapha').default;
const ldap = ldapha('ldaps://ldap.yourcompany.com:636', {
  // optional global settings
  timeout: 10000,
  connectTimeout: 7000,
  tlsOptions: {
    rejectUnauthorized: true,           // set to false only for self-signed/testing
    // ca: fs.readFileSync('path/to/ca.pem'),   // if needed
  }
});

2. Change Password (user self-service)

async function handlePasswordChange(userDn, oldPw, newPw) {
  try {
    await ldap.changePassword(userDn, oldPw, newPw);
    console.log('Password changed successfully');
  } catch (err) {
    console.error('Password change failed:', err.message);
    // Common errors: invalid credentials, policy violation, connection issues
  }
}

3. Admin Reset (bypass old password)

await ldap.changePassword(
  'CN=John Doe,OU=Users,DC=company,DC=com',
  '[email protected]',           // ← admin credentials here
  'NewSecurePass123!',
  { adminReset: true }
);

Important: For admin reset, bind with an account that has permission to reset passwords (usually Domain Admin or delegated rights).

4. Search / List entries

const entries = await ldap.list(
  'OU=Users,DC=company,DC=com',          // base DN
  '[email protected]',         // bind user
  'SecretServicePass456!',               // bind password
  {
    filter: '(&(objectClass=user)(mail=*@company.com))',
    scope: 'sub',
    attributes: ['cn', 'mail', 'sAMAccountName', 'memberOf']
  }
);

console.log(entries);
// → [ { dn: '...', cn: '...', mail: '...', ... }, ... ]

API

ldapha(url: string, options?: ClientOptions): {
  list(
    baseDn: string,
    bindDn: string,
    bindPw: string,
    opts?: {
      filter?: string;
      scope?: 'base' | 'one' | 'sub';
      attributes?: string[];
      [key: string]: any;
    }
  ): Promise<SearchEntry[]>;

  changePassword(
    userDn: string,
    oldPassword: string,
    newPassword: string,
    opts?: { adminReset?: boolean }
  ): Promise<void>;
}

Requirements & Notes

  • Use LDAPS (ldaps://…:636) when changing passwords — Active Directory requires secure connection for unicodePwd modifications.
  • Passwords must meet your domain policy (length, complexity, history).
  • The library quotes passwords automatically (\"password\") and uses correct unicodePwd format.
  • Tested primarily against Microsoft Active Directory — may work with other LDAP servers that support unicodePwd.

Security Considerations

  • Never log passwords or store them in plain text.
  • Use short-lived service accounts with minimal permissions.
  • Prefer LDAPS + proper certificate validation in production.
  • Consider connection pooling if you make many operations (not included in this tiny helper).

License

MIT

Related Projects

  • ldapts – the excellent underlying LDAP client (TypeScript, modern, actively maintained)

Made with ❤️ for simple AD password reset flows
Questions / PRs welcome!