ldap: use proper error message instead of dn

the dn is already in lde_dn field of the error object.
lde_message is the message
This commit is contained in:
Girish Ramakrishnan
2024-01-03 15:19:03 +01:00
parent e42579521c
commit 1ca46a064c
4 changed files with 19 additions and 19 deletions
+3 -3
View File
@@ -298,7 +298,7 @@ async function userAuth(req, res, next) {
// extract the common name which might have different attribute names
const cnAttributeName = Object.keys(req.dn.rdns[0].attrs)[0];
const commonName = req.dn.rdns[0].attrs[cnAttributeName].value;
if (!commonName) return next(new ldap.NoSuchObjectError(req.dn.toString()));
if (!commonName) return next(new ldap.NoSuchObjectError('Missing CN'));
const TOTPTOKEN_ATTRIBUTE_NAME = 'totptoken'; // This has to be in-sync with externalldap.js
const totpToken = req.dn.rdns[0].attrs[TOTPTOKEN_ATTRIBUTE_NAME] ? req.dn.rdns[0].attrs[TOTPTOKEN_ATTRIBUTE_NAME].value : null;
@@ -353,8 +353,8 @@ async function start() {
const config = await getConfig();
if (!req.dn.equals(constants.USER_DIRECTORY_LDAP_DN)) return next(new ldap.InvalidCredentialsError(req.dn.toString()));
if (req.credentials !== config.secret) return next(new ldap.InvalidCredentialsError(req.dn.toString()));
if (!req.dn.equals(constants.USER_DIRECTORY_LDAP_DN)) return next(new ldap.InvalidCredentialsError('Invalid DN'));
if (req.credentials !== config.secret) return next(new ldap.InvalidCredentialsError('Invalid Secret'));
req.user = { user: 'directoryServerAdmin' };