Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wet-crabs-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed LDAP "Group filter" malfunction, which prevented LDAP users from logging in.
4 changes: 2 additions & 2 deletions apps/meteor/server/lib/ldap/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,9 @@ export class LDAPConnection {

searchLogger.debug({ msg: 'Group filter LDAP:', filter: searchOptions.filter });

const result = await this.searchRaw(this.options.baseDN, searchOptions);
const result = await this.searchAndCount(this.options.baseDN, searchOptions);

if (!Array.isArray(result) || result.length === 0) {
if (result === 0) {
return false;
}
return true;
Expand Down
14 changes: 12 additions & 2 deletions apps/meteor/server/lib/ldap/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,18 @@ export class LDAPManager {
}
}

if (!(await ldap.isUserAcceptedByGroupFilter(escapedUsername, ldapUser.dn))) {
throw new Error('User not in a valid group');
const adminLdap = new LDAPConnection();
try {
try {
await adminLdap.connect();
if (!(await adminLdap.isUserAcceptedByGroupFilter(escapedUsername, ldapUser.dn))) {
throw new Error('User not in a valid group');
}
} catch (error) {
logger.error(error);
}
} finally {
adminLdap.disconnect();
}

return ldapUser;
Expand Down