0

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?

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.