Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ldapjs-client

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldapjs-client

LDAP js client

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

LDAP js client

'Build status'

node >= 8.0

No ldapjs (https://www.npmjs.com/package/ldapjs) as dependency.

Why: because ldapjs is not maintained for more than two years.

Installation

npm install ldapjs-client

Usage

To create a new client:

var LdapClient = require('ldapjs-client');
var client = new LdapClient({ url: 'ldap://127.0.0.1:389' });
AttributeTypeDescription
urlStringA valid LDAP URL (proto/host/port only)
timeoutNumberMilliseconds client should let operations live for before timing out (Default: Infinity)
tlsOptionsObjectAdditional options passed to TLS connection layer when connecting via ldaps:// (See: The TLS docs for node.js)

add

try {
  const entry = {
    cn: 'foo',
    sn: 'bar',
    email: ['foo@bar.com', 'foo1@bar.com'],
    objectclass: 'fooPerson'
  };

  await client.add('cn=foo, o=example', entry);
} catch (e) {
  console.log('Add failed');
}

bind

try {
  await client.bind('username', 'password');
} catch (e) {
  console.log('Bind failed');
}

del

try {
  await client.del('cn=foo, o=example');
} catch (e) {
  console.log(e);
}

modify

try {
  const change = {
    operation: 'add', // add, delete, replace
    modification: {
      pets: ['cat', 'dog']
    }
  };

  await client.modify('cn=foo, o=example', change);
} catch (e) {
  console.log(e);
}

modifyDN

try {
  await client.modifyDN('cn=foo, o=example', 'cn=bar');
} catch (e) {
  console.log(e);
}
try {
  const options = {
    filter: '(&(l=Seattle)(email=*@foo.com))',
    scope: 'sub',
    attributes: ['dn', 'sn', 'cn']
  };

  const entries = await client.search('o=example', options);
} catch (e) {
  console.log(e);
}
AttributeTypeDescription
scopeStringOne of base, one, or sub. Defaults to base
filterStringA string version of an LDAP filter. Defaults to (objectclass=*)
attributesArray of Stringattributes to select and return. Defaults to the empty set, which means all attributes
sizeLimitNumberthe maximum number of entries to return. Defaults to 0 (unlimited)
timeLimitNumberthe maximum amount of time the server should take in responding, in seconds. Defaults to 10. Lots of servers will ignore this
typesOnlyBooleanon whether you want the server to only return the names of the attributes, and not their values. Borderline useless. Defaults to false

unbind

try {
  await client.unbind();
} catch (e) {
  console.log(e);
}

destroy

try {
  await client.destroy();
} catch (e) {
  console.log(e);
}

Close connection if exists and destroy current client


Pull requests and suggestions are welcome!

License

MIT.

Keywords

FAQs

Package last updated on 10 Jan 2024

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