New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ldap-studio

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldap-studio

schema-aware, type-safe LDAP client, written in typescript to create hight-level functionalities

  • 0.5.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-63.16%
Maintainers
1
Weekly downloads
 
Created
Source

LDAP Studio

schema-aware, type-safe LDAP client, written in typescript to create hight-level functionalities using ldap-ts-client

How to ues

import { Client, IClientConfig } from "ldap-ts-client";
import { userFindOne } from "ldap-studio";

const baseDN = "DC=Domain,DC=Com";

const config: IClientConfig = {
  ldapServerUrl: process.env.AD_URI ?? "",
  user: process.env.AD_USER ?? "",
  pass: process.env.AD_Pass ?? "",
  baseDN,
};

const client = new Client(config);

const user = await userGetOne("username*", {
  attributes: [
    "displayName",
    "userPrincipalName",
    "adminDisplayName",
    "assistant",
    "manager",
  ],
  client,
  baseDN,
});
console.log(user);

Api Documentations

for full API documentation look at API Website

Advance Uses

generate typescript interfaces from ldap schema. (this is recommended just for first time and after each ldap schema modification)

const config: IClientConfig = {
  ldapServerUrl: process.env.AD_URI ?? "",
  user: process.env.AD_USER ?? "",
  pass: process.env.AD_Pass ?? "",
  baseDN,
};
const interfaceDirPath = await initial({
  generateInterfaces: true,
  useCachedInterfaces: false,
  ...config,
});

auto complete and type check, base on ldap schema interfaces that generated at first time.

Example 1 (using ldap-ts-client)

import { Client, IClientConfig } from "ldap-ts-client";
import { User } from "./generated/interfaces";

const baseDN = "DC=Domain,DC=Com";
const config: IClientConfig = {
  ldapServerUrl: process.env.AD_URI ?? "",
  user: process.env.AD_USER ?? "",
  pass: process.env.AD_Pass ?? "",
  baseDN,
};
const client = new Client(config);

const user = await userGetOne<User>("username*", {
  attributes: [
    "displayName",
    "userPrincipalName",
    "adminDisplayName",
    "assistant",
    "manager",
  ],
  client,
  baseDN,
});
console.log(user);

Example 2 (using ldap-query-generator which will be install with package):

import { QueryGenerator } from "ldap-query-generator";
import { Client, IClientConfig } from "ldap-ts-client";
import { User } from "./generated/interfaces";

const baseDN = "DC=Domain,DC=Com";
const config: IClientConfig = {
  ldapServerUrl: process.env.AD_URI ?? "",
  user: process.env.AD_USER ?? "",
  pass: process.env.AD_Pass ?? "",
  baseDN,
};
const client = new Client(config);

const qGen = new QueryGenerator<User>({
  logger,
  scope: "sub",
});

const { query } = qGen
  .where({ field: "userPrincipalName", action: "substrings", criteria })
  .whereAnd({ field: "objectClass", action: "equal", criteria: "user" })
  .whereOr({ field: "objectClass", action: "equal", criteria: "person" })
  .whereNot({
    field: "objectClass",
    action: "equal",
    criteria: "computer",
  })
  .whereNot({ field: "objectClass", action: "equal", criteria: "group" })
  .select(["displayName", "userPrincipalName"]);

const data = await client.queryAttributes<User>({
  base: baseDN,
  attributes: query.attributes,
  options: {
    filter: query.toString(),
    scope: query.scope,
    paged: true,
  },
});

Motivations:

Dealing with LDAP servers to get information is hard!

the goal of this package is to:

  • Provide High level functions to interact with LDAP servers
  • Taking advantage of typescript type safety and auto code competition
  • Provide unified solution for all ldap & typescript related tools

Keywords

FAQs

Package last updated on 26 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc