【问题标题】:not able to fetch custom attributes from AD using spring-data-ldap无法使用 spring-data-ldap 从 AD 获取自定义属性
【发布时间】:2021-02-11 12:56:35
【问题描述】:

我正在使用 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 方法时,我得到了响应,但employeeID 将为空。如果我调用 findByEmployeeID 方法,我会得到一个空响应。

任何人都可以帮助这是为什么?我需要添加任何配置来获取这些自定义 AD 属性吗?

【问题讨论】:

    标签: java spring active-directory ldap spring-data-ldap


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-17
      • 1970-01-01
      • 1970-01-01
      • 2012-07-12
      相关资源
      最近更新 更多