|
|
@@ -1,7 +1,6 @@
|
|
|
import { configManager } from '~/server/service/config-manager';
|
|
|
import LdapService, { SearchResultEntry } from '~/server/service/ldap';
|
|
|
import PassportService from '~/server/service/passport';
|
|
|
-import loggerFactory from '~/utils/logger';
|
|
|
import { batchProcessPromiseAll } from '~/utils/promise';
|
|
|
|
|
|
import {
|
|
|
@@ -10,8 +9,6 @@ import {
|
|
|
|
|
|
import ExternalUserGroupSyncService from './external-user-group-sync';
|
|
|
|
|
|
-const logger = loggerFactory('growi:service:ldap-user-group-sync-service');
|
|
|
-
|
|
|
// When d = max depth of group trees
|
|
|
// Max space complexity of generateExternalUserGroupTrees will be:
|
|
|
// O(TREES_BATCH_SIZE * d * USERS_BATCH_SIZE)
|
|
|
@@ -41,15 +38,8 @@ class LdapUserGroupSyncService extends ExternalUserGroupSyncService<SyncParamsTy
|
|
|
const groupDescriptionAttribute: string = configManager.getConfig('crowi', 'external-user-group:ldap:groupDescriptionAttribute');
|
|
|
const groupBase: string = this.ldapService.getGroupSearchBase();
|
|
|
|
|
|
- let groupEntries: SearchResultEntry[];
|
|
|
- try {
|
|
|
- await this.ldapService.bind(options?.userBindUsername, options?.userBindPassword);
|
|
|
- groupEntries = await this.ldapService.searchGroupDir();
|
|
|
- }
|
|
|
- catch (e) {
|
|
|
- logger.error(e.message);
|
|
|
- throw Error('external_user_group.ldap.group_search_failed');
|
|
|
- }
|
|
|
+ await this.ldapService.bind(options?.userBindUsername, options?.userBindPassword);
|
|
|
+ const groupEntries = await this.ldapService.searchGroupDir();
|
|
|
|
|
|
const getChildGroupDnsFromGroupEntry = (groupEntry: SearchResultEntry) => {
|
|
|
// groupChildGroupAttribute and groupMembershipAttribute may be the same,
|
|
|
@@ -67,7 +57,7 @@ class LdapUserGroupSyncService extends ExternalUserGroupSyncService<SyncParamsTy
|
|
|
if (name == null) return null;
|
|
|
|
|
|
if (converted.includes(entry.objectName)) {
|
|
|
- throw Error('external_user_group.ldap.circular_reference');
|
|
|
+ throw Error('Circular reference inside LDAP group tree');
|
|
|
}
|
|
|
converted.push(entry.objectName);
|
|
|
|
|
|
@@ -128,14 +118,7 @@ class LdapUserGroupSyncService extends ExternalUserGroupSyncService<SyncParamsTy
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- let userEntries: SearchResultEntry[] | undefined;
|
|
|
- try {
|
|
|
- userEntries = await getUserEntries();
|
|
|
- }
|
|
|
- catch (e) {
|
|
|
- logger.error(e.message);
|
|
|
- throw Error('external_user_group.ldap.user_search_failed');
|
|
|
- }
|
|
|
+ const userEntries = await getUserEntries();
|
|
|
|
|
|
if (userEntries != null && userEntries.length > 0) {
|
|
|
const userEntry = userEntries[0];
|