JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q65483F
  • License ISC

Run local LDAP server with specific users for local development and integration testing

Package Exports

  • @simulacrum/ldap-simulator
  • @simulacrum/ldap-simulator/dist/index.js
  • @simulacrum/ldap-simulator/dist/start

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@simulacrum/ldap-simulator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@simulacrum/ldap-simulator

Simulate an actual LDAP server for testing and development.

Often you are working on software that depends on the presence of an LDAP directory. This let's you create an LDAP server in a known state that can be used for offline development and testing.

There are two different ways to start an LDAP simulator, but they both involve the same set of options. If you are running in a vanilla JavaScript environment, you can use promise-based API.

Plain JavaScript

import { runLDAPServer } from "@simulacrum/ldap-simulator";

async function run() {
  let server = await runLDAPServer({
    port: 3890,
    baseDN: "ou=users,dc=org.com",
    bindDn: "admin@org.com",
    bindPassword: "password",
    groupDN:"ou=groups,dc=org.com",
    users: [{
      //required
      cn: 'Charles Lowell',
      //optional to bind using this user
      password: "super-secret-but-not-really",
      //optional:
      uid: 'cowboyd',

    }]
  });
  console.log(`LDAP server running on ${server.port}`);
  try {
    //.... do some stuff;
  } finally {
    // don't forget to release the server resources!
    await server.close();
  }
}

Effection

However, if you are already using Effection, the LDAP server is available as a Resource, and so you can use it freely in any context:

import { createLDAPServer } from "@simulacrum/ldap-simulator";

function* run() {
  let server = yield createLDAPServer({
    port: 3890,
    baseDN: "ou=users,dc=org.com",
    bindDn: "admin@org.com",
    bindPassword: "password",
    groupDN:"ou=groups,dc=org.com",
    users: [{
      //required
      cn: 'Charles Lowell',
      //optional to bind using this user
      password: "super-secret-but-not-really",
      //optional:
      uid: 'cowboyd',

    }]
  });

  //... do some stuff
}