Skip to content

Commit

Permalink
feat: reset conn on each search (pls work)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sampiiiii committed Apr 15, 2024
1 parent a7cecb9 commit ecb7308
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion apps/anvil/src/ldap/ldap.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,22 @@ export class LdapService implements OnModuleInit {
}
}

async resetConnection() {
if (this.client) {
this.client.unbind((err) => {
if (err) {
this.logger.error(`Error unbinding LDAP client: ${err.message}`);
}
this.client = null;
this.logger.debug("LDAP client unbound and reset.");
});
}
await this.connect();
}

private async search(base: string, options: ldap.SearchOptions): Promise<ldap.SearchEntry[]> {
this.logger.debug(`Performing search with base: ${base} and filter: ${options.filter}`);
await this.ensureConnected();
await this.resetConnection(); // Reset connection before each search
return new Promise((resolve, reject) => {
this.client!.search(base, options, (err, res) => {
if (err) {
Expand Down

0 comments on commit ecb7308

Please sign in to comment.