我有这段代码
// 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"));
}
}
cn = JacobKranz的条目添加了多个描述但我只能获得第一个值而不是循环遍历每个值。
我如何获得所有价值观?
答案 0 :(得分:4)
使用多值API:
for(String v : entry.getAttributeValues("description")) {
System.out.println(String.format("description value: %s", v));
}