y580user
y580user

Reputation: 29

OpenDJ with UnboundId LDAP SDK for Java

I got the following problem. There is working OpenDJ server, connection using UnboundID LDAP SKD for Java. I learned how to search for particular entries, but what is the way to obtain value of "entryUUID" attribute for a given entry? OpenDJ says that is one of "non-editable attributes" and I can't see any of those in SearchResultEntry object using getAttributes() method.

I mean something like:

public String getUserUUID(String cn) {
   SearchResult sr = connection.search(dn, SearchScope.SUB, Filter.createEqualityFilter("cn",          cn));
   if (sr.getEntryCount() > 0){     
       return sr.getSearchEntries().get(0).getAttributeValue("entryUUID");
   }
}

But in attributes map in SearchResultEntry there is no parameters "non-editable parameters"

Upvotes: 2

Views: 684

Answers (2)

user454322
user454322

Reputation: 7649

EntryUUID is an operational attribute and by default only the user attributes are returned. For that you have to explicitly request the operational attributes. You can use ALL_OPERATIONAL_ATTRIBUTES.


The method below works with UnboundId LDAP SDK for Java 2.3.8.

public String getUserUUID(String cn) throws LDAPSearchException {
    SearchResult sr = connection.search(dn, SearchScope.SUB, Filter.createEqualityFilter("cn",cn), ALL_OPERATIONAL_ATTRIBUTES);
    if (sr.getEntryCount() > 0){
        return sr.getSearchEntries().get(0).getAttributeValue("entryUUID");
    }
    return "";
}

Upvotes: 1

Ludovic Poitou
Ludovic Poitou

Reputation: 4868

EntryUUID is a non-editable OPERATIONAL attribute. With LDAP, the operational attributes are only returned when searching, if you have specifically requested them. In your case, the search request doesn't specify the requested attributes, and thus implies to return all user attributes. I'm pretty sure UnboundID SDK has a search method which accepts a list of attributes to return.

Regards, Ludovic

Upvotes: 2

Related Questions