简体   繁体   中英

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"

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

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 "";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM