🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

ldapts-search

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldapts-search

Search through active directory

2.1.5
latest
Version published
Weekly downloads
12
-58.62%
Maintainers
1
Weekly downloads
 
Created

ldapts-search

Utility to help search through active directory.

Definition:

class LdapSearch<Result> {
  constructor(params: {
    host: string;
    port: number;
    dn: string;
    password: string;
    searchBase: string;
    attributes?: string[];
  });
  match: (filter: string, sizeLimit?: number | undefined) => Promise<Result[]>;
}

Example usage:

type Result = {
  sAMAccountName: string;
  name: string;
  dn: string;
};

const ldapSearch = new LdapSearch<Result>({
  dn: "dn=test",
  host: "0.0.0.0",
  port: 1234,
  password: "password",
  searchBase: "dn=some,cn=searchbase",
  attributes: [
    "sAMAccountName",
    "name",
    "dn"
  ]
});

export function searchActiveDirectory(name: string): ActiveDirectoryRecord[] {
  return await ldapSearch.match(`(&(objectClass=Person)(sAMAccountName=${name}))`); // returns Result[]
}

FAQs

Package last updated on 25 Sep 2019

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