From e345bc77c6d7599688b80b9ad82a8e6cdeec8b51 Mon Sep 17 00:00:00 2001 From: DouDou <877258667@qq.com> Date: Thu, 11 Sep 2025 18:17:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/sys/task/LdapAccountRefreshTask.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/spring/modules/sys/task/LdapAccountRefreshTask.java b/src/main/java/com/spring/modules/sys/task/LdapAccountRefreshTask.java index e86b8635..6a782d3d 100644 --- a/src/main/java/com/spring/modules/sys/task/LdapAccountRefreshTask.java +++ b/src/main/java/com/spring/modules/sys/task/LdapAccountRefreshTask.java @@ -1,5 +1,6 @@ package com.spring.modules.sys.task; +import com.alibaba.fastjson.JSONArray; import com.spring.common.utils.LdapReadUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,7 +25,9 @@ import java.util.Properties; @Component @EnableScheduling public class LdapAccountRefreshTask { + private static final Logger logger = LoggerFactory.getLogger(LdapAccountRefreshTask.class); + @Value("${spring.ldap.urls}") private String ldapUrl; @Value("${spring.ldap.base}") @@ -49,16 +52,17 @@ public class LdapAccountRefreshTask { env.put(Context.REFERRAL, "ignore"); LdapContext ctx = null; - //尝试解析数据 try{ // 创建DirContext对象,建立与LDAP服务器的连接 ctx = new InitialLdapContext(env, null); //调用方法读取数据 - Map ldapAccountMap = LdapReadUtils.getAllLdapAccount(ctx, ldapBase); + Map ldapAccountMap = LdapReadUtils.getAllLdapAccount(ctx, ldapBase, redisTemplate); + logger.info("域控账号缓存的数量:"+ldapAccountMap.size()); // 数据放到redis中去 - redisTemplate.opsForHash().putAll("ldapAccount", ldapAccountMap); + // redisTemplate.opsForHash().putAll("ldapAccount", ldapAccountMap); + logger.info("域控账号缓存:"+ JSONArray.toJSONString(ldapAccountMap)); } catch (NamingException | IOException e) { logger.error("Failed to connect to the LDAP server.");