From c7f8d51124bddba995470ae4c46ef5100e79d2db Mon Sep 17 00:00:00 2001 From: vromav Date: Thu, 30 Jul 2020 16:08:04 +0300 Subject: [PATCH] rm1759: fix group synchronization --- .../ru/runa/wfe/security/logic/LdapLogic.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/wfe-core/src/main/java/ru/runa/wfe/security/logic/LdapLogic.java b/wfe-core/src/main/java/ru/runa/wfe/security/logic/LdapLogic.java index ba0728db43..6c6461dabf 100644 --- a/wfe-core/src/main/java/ru/runa/wfe/security/logic/LdapLogic.java +++ b/wfe-core/src/main/java/ru/runa/wfe/security/logic/LdapLogic.java @@ -254,13 +254,30 @@ private int synchronizeGroups(DirContext dirContext, Map actorsBy controls.setSearchScope(SearchControls.SUBTREE_SCOPE); Map groupResultsByDistinguishedName = Maps.newHashMap(); for (String ou : LdapProperties.getSynchronizationOrganizationUnits()) { - NamingEnumeration list = dirContext.search(ou, OBJECT_CLASS_GROUP_FILTER, controls); - while (list.hasMore()) { - SearchResult searchResult = list.next(); - if (searchResult.getAttributes().get(ATTR_GROUP_MEMBER) == null) { - continue; + try { + NamingEnumeration list = dirContext.search(ou, OBJECT_CLASS_GROUP_FILTER, controls); + while (list.hasMore()) { + SearchResult searchResult = list.next(); + if (searchResult.getAttributes().get(ATTR_GROUP_MEMBER) == null) { + continue; + } + groupResultsByDistinguishedName.put(searchResult.getNameInNamespace(), searchResult); + } + list.close(); + } catch (SizeLimitExceededException e) { + for (String y : ALPHABETS) { + NamingEnumeration list = dirContext.search(ou, + MessageFormat.format(LOGIN_FIRST_LETTER_FILTER, ATTR_GROUP_NAME, y, y.toLowerCase(), OBJECT_CLASS_GROUP_FILTER), + controls); + while (list.hasMore()) { + SearchResult searchResult = list.next(); + if (searchResult.getAttributes().get(ATTR_GROUP_MEMBER) == null) { + continue; + } + groupResultsByDistinguishedName.put(searchResult.getNameInNamespace(), searchResult); + } + list.close(); } - groupResultsByDistinguishedName.put(searchResult.getNameInNamespace(), searchResult); } } for (SearchResult searchResult : groupResultsByDistinguishedName.values()) {