无法使用 spring-data-ldap 从 AD 获取自定义属性

问题描述

我正在使用 spring-data-LDAP 连接到 Active Directory。我已使用域管理员用户凭据连接到 AD。 application.properties 配置是,

spring.ldap.urls=ldap://xxx.xxx.xxx.xxx:3268
spring.ldap.username=adprofile
spring.ldap.password=Admin@123#
spring.ldap.base=DC=TEST,DC=COM
spring.data.ldap.repositories.enabled=true 

我创建了一个存储库来获取 AD 数据。

@Repository
public interface EmployeeRepo extends LdapRepository<Employee> {
    List<Employee> findByCn(String cn);
    List<Employee> findBySn(String sn);
    List<Employee> findByEmployeeID(String id);
}

我的员工实体是

    @Entry(base = "ou=Employees",objectClasses = {"top","person","organizationalPerson","user"})
    public class Employee {
        @Id
        @JsonIgnore
        private Name id;
    
    public @Attribute(name = "CN") String cn;
    public @Attribute(name = "sn") String sn;
    public @Attribute(name = "EmployeeID") String employeeID;
    
-- getters and setters
    
    }

当我调用 findByCn 方法时,我得到了响应,但员工 ID 将为空。如果我调用 findByEmployeeID 方法,我会得到一个空响应。

谁能帮忙看看这是为什么?我需要添加任何配置来获取这些自定义 AD 属性吗?

解决方法

我通过端口 3268 连接到 AD。似乎有些属性只能通过端口 389 连接到 AD 才能获取。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...