13 private static $userLimit = 1000;
14 private static $userLimitExceededTag =
'LDAP_USER_LIMIT_EXCEEDED';
15 private static $isUserLimitExceeded =
false;
19 if(self::$isUserLimitExceeded !==
true)
21 $isFeatureEnabled = \CBXFeatures::IsFeatureEnabled(
'LdapUnlimitedUsers');
22 $featuresList = \CBXFeatures::GetFeaturesList();
24 if($isFeatureEnabled && !empty($featuresList))
26 self::$isUserLimitExceeded =
false;
30 self::$isUserLimitExceeded = self::countLdapUsers() >= self::$userLimit;
32 if(self::$isUserLimitExceeded)
34 self::notifyUserLimitExceeded();
39 return self::$isUserLimitExceeded;
44 return loc::getMessage(
45 'LDAP_LIMIT_USER_LIMIT_EXCEEDED',
46 [
'#LIMIT#' => self::$userLimit]
50 private static function notifyUserLimitExceeded(): void
53 "SEVERITY" => \CEventLog::SEVERITY_WARNING,
54 "AUDIT_TYPE_ID" => self::$userLimitExceededTag,
55 "MODULE_ID" =>
"ldap",
56 "DESCRIPTION" => self::getUserLimitNotifyMessage()
60 'MODULE_ID' =>
'ldap',
61 'TAG' => self::$userLimitExceededTag,
62 'ENABLE_CLOSE' =>
'Y',
63 'NOTIFY_TYPE' => \CAdminNotify::TYPE_NORMAL,
64 'MESSAGE' => self::getUserLimitNotifyMessage()
68 private static function countLdapUsers(): int
72 $res = UserTable::query()
73 ->addSelect(
new ExpressionField(
'CNT',
'COUNT(1)'))
74 ->whereLike(
'EXTERNAL_AUTH_ID',
'LDAP#%')
77 if($row = $res->fetch())
79 $result = (int)$row[
'CNT'];
static loadMessages($file)