{"id":23819822,"url":"https://github.com/kth/kth-node-ldap","last_synced_at":"2026-02-27T11:40:38.258Z","repository":{"id":73510700,"uuid":"68855364","full_name":"KTH/kth-node-ldap","owner":"KTH","description":"A small promise wrapper and convenience functions for ldapjs","archived":false,"fork":false,"pushed_at":"2024-12-01T04:36:22.000Z","size":1341,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":18,"default_branch":"main","last_synced_at":"2024-12-07T00:41:23.092Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KTH.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-21T20:33:30.000Z","updated_at":"2024-11-06T13:06:58.000Z","dependencies_parsed_at":"2024-11-06T14:19:38.589Z","dependency_job_id":"52953f4d-3370-40e8-8b14-37748e5f1133","html_url":"https://github.com/KTH/kth-node-ldap","commit_stats":{"total_commits":78,"total_committers":11,"mean_commits":7.090909090909091,"dds":0.7948717948717949,"last_synced_commit":"fc4cc6ab9bb5bd67e7214fb8103abef86ddeecc7"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KTH%2Fkth-node-ldap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KTH%2Fkth-node-ldap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KTH%2Fkth-node-ldap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KTH%2Fkth-node-ldap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KTH","download_url":"https://codeload.github.com/KTH/kth-node-ldap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232163091,"owners_count":18481581,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-02T07:15:51.219Z","updated_at":"2026-02-27T11:40:38.199Z","avatar_url":"https://github.com/KTH.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kth-node-ldap\n\nConvenience library on top of the [ldapts](https://www.npmjs.com/package/ldapts) client.\n\n## Code Example LDAPTS\n\nHow to create client connection object and re-export relevant methods. In this example the file is named ldapImportClient.js\n\n```javascript\nconst { createClient, search, searchOne } = require('kth-node-ldap')\nconst config = require('../configuration').server\nconst log = require('@kth/log')\n\n// ldap client is used to find users and need to be exposed\nconst ldapClient = createClient({\n  url: config.ldap.uri,\n  timeout: 30 * 60 * 1000,\n  connectTimeout: config.ldap.connecttimeout,\n  bindDN: config.ldap.username,\n  bindCredentials: config.ldap.password,\n})\nmodule.exports = {\n  ldapClient,\n  ldapSearch: search,\n  ldapSearchOne: searchOne,\n}\n```\n\nUsing the client above, perform the search\n\n```javascript\nconst { ldapClient, ldapSearch, ldapSearchOne } = require('./ldapImportClient')\n\n// Get all users changed since 2020-03-01\ntry {\n  const base = 'DC=ldap,DC=example,DC=com'\n  const since = '20200301000000.0Z'\n  const query = {\n    scope: 'sub',\n    attributes: ['givenName', 'familyName', 'updatedOn'],\n    filter: `(\u0026(whenChanged\u003e=${since}))`,\n  }\n\n  const usersArray = await ldapSearch(ldapClient, base, query)\n  for (const user of usersArray) {\n    // Do what you have to do..\n  }\n} catch (err) {\n  log.error('Could not query LDAP ', { err: e })\n}\n\n// Find a single user\ntry {\n  const base = 'DC=ldap,DC=example,DC=com'\n  const username = 'paddy'\n  const query = {\n    scope: 'sub',\n    attributes: ['givenName', 'familyName', 'updatedOn'],\n    filter: '(\u0026(ugUsername=${username}))',\n  }\n\n  const user = await ldapSearchOne(ldapClient, base, query)\n\n  // Do what you have to do..\n} catch (err) {\n  log.error('Could not query LDAP ', { err: e })\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkth%2Fkth-node-ldap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkth%2Fkth-node-ldap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkth%2Fkth-node-ldap/lists"}