* 🛠️ Synchronization of the user with LDAP

* add configuration with LDAP attributes mappings
* add defalut company and remove application check since it's not configurable
* change error handling, now all the requests are independant
This commit is contained in:
Anton Shepilov
2023-09-12 23:02:46 +02:00
committed by GitHub
parent 79764988b8
commit efcb27b405
4 changed files with 24 additions and 43 deletions
+6 -6
View File
@@ -1,4 +1,4 @@
import ldap from "ldapjs";
import ldap, { SearchEntry } from "ldapjs";
import axios, { AxiosError } from "axios";
import dotenv from "dotenv";
@@ -119,14 +119,14 @@ client.bind(ldapConfig.bindDN, ldapConfig.bindCredentials, (err) => {
const apiRequests: Promise<any>[] = [];
searchRes.on("searchEntry", (entry: any) => {
console.log('Receive entry:: ' + JSON.stringify(entry.pojo));
searchRes.on("searchEntry", (entry: SearchEntry) => {
console.log('Receive entry:: ' + JSON.stringify(entry.attributes));
// Handle each search result entry
const userAttributes: UserAttributes = {
first_name: entry.attributes[0]?.values[0],
last_name: entry.attributes[1]?.values[0],
email: entry.attributes[2]?.values[0],
first_name: entry.attributes.find(a=> a.type == ldapConfig.mappings.firstName)?.vals[0]!,
last_name: entry.attributes.find(a=> a.type == ldapConfig.mappings.lastName)?.vals[0]!,
email: entry.attributes.find(a=> a.type == ldapConfig.mappings.email)?.vals[0]!,
};
if (userAttributes.email) {