Skip to content

The request to the LDAP server works sometimes but occasionally fails with an ETIMEDOUT error #252

@anushree663

Description

@anushree663

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions