I tried to retrieve data from the LDAP server. It returns a response sometimes, but occasionally it fails. Below is my code.
const username = username;
const password = password;
const domainController = url;
const baseDN = 'DC=auth,DC=hpicorp,DC=net';
const searchFilter = `(&(objectClass=user)(mail=${emailId}))`;
const users = await queryLDAP(username, password, domainController, baseDN, searchFilter);
async function queryLDAP(username: string, password: string, domainController: string, baseDN: string, searchFilter: string): Promise<any[]> {
return new Promise<any[]>((resolve, reject) => {
const config = {
url: `ldaps://${domainController}`,
baseDN,
username,
password,
timeout: 60000,
maxConnections: 10,
tlsOptions: { rejectUnauthorized: false }
};
try {
const attributes = [
"sAMAccountName",
"displayName",
"mail",
"hpStatus",
"reportees",
"users",
"distinguishedName",
"manager"
];
const ad = getLDAPConnection(config);
ad.findUsers({ filter: searchFilter, attributes }, (err, users) => {
if (err) {
reject(err);
return;
}
resolve(users || []);
});
} catch (error) {
reject(error);
}
});
}
Below is the error.
Failed to Retrieve AD data: Error: connect ETIMEDOUT (ipaddress)
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {
errno: -110,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '(ipaddress)',
port: 636
}
I tried to retrieve data from the LDAP server. It returns a response sometimes, but occasionally it fails. Below is my code.
Below is the error.
Failed to Retrieve AD data: Error: connect ETIMEDOUT (ipaddress)
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {
errno: -110,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '(ipaddress)',
port: 636
}