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 yet I am only able to get the first value rather than cycle through each one.
How would I go about getting all values?
Use the multi-value API:
for(String v : entry.getAttributeValues("description")) {
System.out.println(String.format("description value: %s", v));
}