Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/famous-falcons-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Ensures seat limit validation in LDAP sync, preventing activations beyond license restrictions.
14 changes: 14 additions & 0 deletions apps/meteor/server/lib/ldap/UserConverter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { IImportUser, IUser } from '@rocket.chat/core-typings';
import { License } from '@rocket.chat/license';
import type { Logger } from '@rocket.chat/logger';
import { Users } from '@rocket.chat/models';

import { logger } from './Logger';
import type { ConverterCache } from '../../../app/importer/server/classes/converters/ConverterCache';
import { type RecordConverterOptions } from '../../../app/importer/server/classes/converters/RecordConverter';
import { UserConverter, type UserConverterOptions } from '../../../app/importer/server/classes/converters/UserConverter';
Expand Down Expand Up @@ -45,6 +47,18 @@ export class LDAPUserConverter extends UserConverter {
}
}

async insertUser(userData: IImportUser): Promise<IUser['_id']> {
if (!userData.deleted) {
// #TODO: Change the LDAP sync process to split the inserts and updates into two stages so that we can validate this only once for all insertions
if (await License.shouldPreventAction('activeUsers')) {
logger.warn({ msg: 'Max users allowed reached, creating new LDAP users in inactive state ', username: userData.username });
userData.deleted = true;
}
}

return super.insertUser(userData);
}

static async convertSingleUser(userData: IImportUser, options?: UserConverterOptions): Promise<void> {
const converter = new LDAPUserConverter(options);
await converter.addObject(userData);
Expand Down
Loading