ldap: type SearchOptions scope

This commit is contained in:
Reto Brunner 2024-04-14 02:57:05 +02:00
parent 4614c35486
commit a4afa08add
2 changed files with 6 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import fs, {Stats} from "fs";
import os from "os";
import _ from "lodash";
import colors from "chalk";
import {SearchOptions} from "ldapjs";
import log from "./log";
import Helper from "./helper";
@ -57,7 +58,7 @@ type SearchDN = {
rootPassword: string;
filter: string;
base: string;
scope: string;
scope: SearchOptions["scope"];
};
type Ldap = {

View file

@ -67,11 +67,11 @@ function advancedLdapAuth(user: string, password: string, callback: (success: bo
});
const base = config.ldap.searchDN.base;
const searchOptions = {
const searchOptions: SearchOptions = {
scope: config.ldap.searchDN.scope,
filter: `(&(${config.ldap.primaryKey}=${userDN})${config.ldap.searchDN.filter})`,
attributes: ["dn"],
} as SearchOptions;
};
ldapclient.on("error", function (err: Error) {
log.error(`Unable to connect to LDAP server: ${err.toString()}`);
@ -178,12 +178,12 @@ function advancedLdapLoadUsers(users: string[], callbackLoadUser) {
const remainingUsers = new Set(users);
const searchOptions = {
const searchOptions: SearchOptions = {
scope: config.ldap.searchDN.scope,
filter: `${config.ldap.searchDN.filter}`,
attributes: [config.ldap.primaryKey],
paged: true,
} as SearchOptions;
};
ldapclient.search(base, searchOptions, function (err2, res) {
if (err2) {