javaspring-bootactive-directoryspring-ldapspring-data-ldap

Cannot read accountExpires attribute from Active Directory with Spring LDAP


I am using Spring Boot/Spring Data Ldap.

When I query users I cannot read accountExpires attribute, even when the property is shown in GetADUser.

I tried something like this:

return readTemplate().search(query()
      .base(ou)
      .attributes(new String[]{"samaccountname", "givenName", "sn", "mail", "userAccountControl", "accountExpires", "memberof"})
      .where("objectClass").is("person"), userExtractor);

I am sure the user has accountExpires property set, I tested with accountExpires and accountexpires (to check case-sensitivity), even I omitted attributes to read all attributes, but no chance, not all attributes are returned (well accountExpires is one of the missing ones).

How can I read that attribute?


Solution

  • The problem was on port of Active Directory I used. MS Active Directory exposes 2 ports 3268 which is readonly but return all results (even if result-set is so big) and 389 which is read/write but returns paged data.

    My readTemplate was set to read from 3268, but I don't know why that port does not return some attributes including accountExpires.

    When I read the data through writeTemplate (which was set on 389), I could read the attribute.