5.3.0 • Published 1 month ago
kth-node-ldap v5.3.0
kth-node-ldap
Convenience library on top of the ldapts client.
Code Example LDAPTS
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
1 month ago
5.2.0
4 months ago
5.1.0
7 months ago
5.0.0
8 months ago
4.0.11
10 months ago
4.0.10
2 years ago
4.0.9
2 years ago
4.0.8
2 years ago
4.0.7
2 years ago
4.0.6
2 years ago
4.0.5
3 years ago
4.0.4
3 years ago
4.0.3
3 years ago
4.0.2
3 years ago
4.0.1
3 years ago
4.0.0
4 years ago
3.1.1
4 years ago
3.1.0
4 years ago
3.0.8
4 years ago
3.0.7
4 years ago
3.0.6
4 years ago
3.0.5
5 years ago
3.0.4
5 years ago
3.0.3
5 years ago
3.0.2
5 years ago
3.0.1
5 years ago
3.0.0
5 years ago
2.4.0
5 years ago
2.3.8
6 years ago
2.3.7
6 years ago
2.3.6
6 years ago
2.3.5
6 years ago
2.3.4
6 years ago
2.3.3
6 years ago
2.3.2
6 years ago
2.3.1
6 years ago
2.3.0
6 years ago
2.2.0
6 years ago
2.1.1
7 years ago
2.1.0
7 years ago
2.0.3
7 years ago
2.0.2
7 years ago
2.0.1
7 years ago