From 4a61bd39df51ddb2138aed2e26bb0e377b5654db Mon Sep 17 00:00:00 2001 From: Felix Sidokhine <felix.sidokhine@randstad.ca> Date: Mon, 11 May 2020 13:07:13 +0300 Subject: [PATCH] fixed the specials chars problem with LDAP, possibly may need to add this to AD --- .../src/main/java/net/jami/jams/server/Server.java | 8 ++++---- .../jams/ldap/connector/service/UserProfileService.java | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/jams-server/src/main/java/net/jami/jams/server/Server.java b/jams-server/src/main/java/net/jami/jams/server/Server.java index 49c01881..f6a36edf 100644 --- a/jams-server/src/main/java/net/jami/jams/server/Server.java +++ b/jams-server/src/main/java/net/jami/jams/server/Server.java @@ -57,11 +57,11 @@ public class Server { try { InputStream path; ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - path = classLoader.getResourceAsStream("adsampleconfig.json"); - userAuthenticationModule.attachADAuthSource(new String(path.readAllBytes())); + path = classLoader.getResourceAsStream("ldapconfig.json"); + userAuthenticationModule.attachLDAPAuthSource(new String(path.readAllBytes())); UserProfile[] userProfile = userAuthenticationModule.getAuthenticationSources() - .get(new AuthModuleKey("SAVOIRFAIRELINU", AuthenticationSourceType.AD)) - .getUserProfile("Sidokhine","FULL_TEXT_NAME"); + .get(new AuthModuleKey("savoirfairelinux", AuthenticationSourceType.LDAP)) + .getUserProfile("Félix","FULL_TEXT_NAME"); System.out.println(userProfile[0]); } catch (Exception e) { log.error("Could not load and inject active directory connector with error: " + e.toString()); diff --git a/ldap-connector/src/main/java/net/jami/jams/ldap/connector/service/UserProfileService.java b/ldap-connector/src/main/java/net/jami/jams/ldap/connector/service/UserProfileService.java index 1f1f0471..e0334e15 100644 --- a/ldap-connector/src/main/java/net/jami/jams/ldap/connector/service/UserProfileService.java +++ b/ldap-connector/src/main/java/net/jami/jams/ldap/connector/service/UserProfileService.java @@ -5,6 +5,9 @@ import net.jami.jams.common.objects.user.UserProfile; import net.jami.jams.ldap.connector.LDAPConnector; import org.ldaptive.*; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.text.Normalizer; import java.util.HashMap; @Slf4j @@ -33,6 +36,7 @@ public class UserProfileService { UserProfile[] profiles = null; Connection connection = null; try { + queryString = URLEncoder.encode(queryString,StandardCharsets.UTF_8).replace("%","\\"); connection = connectionFactory.getConnection(); try { connection.open(); -- GitLab