user2205421
user2205421

Reputation: 11

How I get or set isMemberOf(memberOf), createdTimestamp, and modifiedTimestamp

I'm using spring ldap with OpenDJ and was not able to set the attribute isMemberOf or memberOf for the person. Also, I'm having problem to get createdTimestamp and modifiedTimestamp attributes for the person. Please help

Upvotes: 1

Views: 1348

Answers (2)

Nathan Karasch
Nathan Karasch

Reputation: 338

In my implementation, which currently uses Spring LDAP repositories (spring-boot-starter-data-ldap version 3.0.0-M3) and Oracle Unified Directory (OUD), I was able to fetch the operational attribute isMemberOf by simply including the @Attribute annotation on the appropriate user property.

For example:

@Entry(...)
public class AppUser implements UserDetails {
    
    // ... other fields ...

    @Attribute(name = "isMemberOf")
    private List<String> groups;

    // ... getters/setters ...

}

@Repository
public interface AppUserRepository extends LdapRepository<AppUser> {
}

By fetching a user with the repository's findOne() method, and without any additional configuration, it correctly populated the groups property. However, as mentioned in the other answer, it's read-only; to set the isMemberOf, you would need to add the user DN to any relevant groups.

Upvotes: 0

Ludovic Poitou
Ludovic Poitou

Reputation: 4878

The createTimeStamp and modifyTimeStamp LDAP attributes are by specification Operational and read-only: they are set automatically by the server when the entry is created (LDAP ADD operation) or modified.

The isMemberOf is also an operational and read-only attribute in OpenDJ. It is a backlink between a Group and a user. It's computed on the fly, based on Static or Dynamic group. Add the user DN to a group, and you will be able to read the isMemberOf attribute in the user entry.

Upvotes: 0

Related Questions