diff --git a/server/config.ts b/server/config.ts index bba3e334..bbbb3457 100644 --- a/server/config.ts +++ b/server/config.ts @@ -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 = { diff --git a/server/plugins/auth/ldap.ts b/server/plugins/auth/ldap.ts index 9e7a3e37..d30b9a1c 100644 --- a/server/plugins/auth/ldap.ts +++ b/server/plugins/auth/ldap.ts @@ -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) {