LDAP UnboundId: Get all attribute values ​​from one entry

I have this code

    // get the search results, getConnection = LDAPConnection
    SearchResult searchResults = getConnection().search(basedn,
            SearchScope.SUB, "(cn=JacobKranz)", "description");

    System.out.println(searchResults.getEntryCount());
    if (searchResults.getEntryCount() > 0)
    {
        for(int i=0; i < searchResults.getEntryCount(); i++)
        {
            //System.out.println(i);
            SearchResultEntry entry = searchResults.getSearchEntries().get(i);

            System.out.println(entry.getAttributeValue("description"));

        }

    }

      

The entry where cn = JacobKranz has multiple descriptions added to it, but I can only get the first value and not loop through each one.

How do I get all the values?

+3


source to share


1 answer


Use multivalued API:



for(String v : entry.getAttributeValues("description")) {
    System.out.println(String.format("description value: %s", v));
}

      

+4


source







All Articles