Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
kth-node-ldap
Advanced tools
Adds a Promise-based API on top of ldapjs as well as a filter builder.
Convenience library on top of the ldapts client.
How to create client connection object and re-export relevant methods. In this example the file is named ldapImportClient.js
const { createClient, search, searchOne } = require('kth-node-ldap')
const config = require('../configuration').server
const log = require('@kth/log')
// ldap client is used to find users and need to be exposed
const ldapClient = createClient({
url: config.ldap.uri,
timeout: 30 * 60 * 1000,
connectTimeout: config.ldap.connecttimeout,
bindDN: config.ldap.username,
bindCredentials: config.ldap.password,
})
module.exports = {
ldapClient,
ldapSearch: search,
ldapSearchOne: searchOne,
}
Using the client above, perform the search
const { ldapClient, ldapSearch, ldapSearchOne } = require('./ldapImportClient')
// Get all users changed since 2020-03-01
try {
const base = 'DC=ldap,DC=example,DC=com'
const since = '20200301000000.0Z'
const query = {
scope: 'sub',
attributes: ['givenName', 'familyName', 'updatedOn'],
filter: `(&(whenChanged>=${since}))`,
}
const usersArray = await ldapSearch(ldapClient, base, query)
for (const user of usersArray) {
// Do what you have to do..
}
} catch (err) {
log.error('Could not query LDAP ', { err: e })
}
// Find a single user
try {
const base = 'DC=ldap,DC=example,DC=com'
const username = 'paddy'
const query = {
scope: 'sub',
attributes: ['givenName', 'familyName', 'updatedOn'],
filter: '(&(ugUsername=${username}))',
}
const user = await ldapSearchOne(ldapClient, base, query)
// Do what you have to do..
} catch (err) {
log.error('Could not query LDAP ', { err: e })
}
[5.3.0] - 2024-04-18
Updated readme to remove some config that was never used.
FAQs
Adds a Promise-based API on top of ldapjs as well as a filter builder.
The npm package kth-node-ldap receives a total of 122 weekly downloads. As such, kth-node-ldap popularity was classified as not popular.
We found that kth-node-ldap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.