javaspringactive-directoryldapspring-data-ldap

not able to fetch custom attributes from AD using spring-data-ldap


I am connecting to the Active Directory using spring-data-LDAP. I have used domain admin user credentials to connect to the AD. The application.properties configurations are,

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 

I have created a repository to fetch the AD data.

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

My employee entity is

    @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
    
    }

when I call findByCn method, I am getting a response but the employeeID will be null. if I call findByEmployeeID method I am getting an empty response.

Can anyone help why is this? do I need to add any configurations to fetch these custom AD attributes?


Solution

  • I was Connecting to the AD via port 3268. It seems some attributes can be fetched only by connecting to the AD via port 389.