Handling Results

A significant aspect of working with LDAP searches is processing the results after issuing the query. The results from the search are returned as an LDAPSearchResults object, which implements Enumeration. Note that once you iterate over the result set, it is not available anymore. If you must do multiple passes over the result set, then you must save the values in a store that is internal to your program.

There are two methods for iteration: nextElement and next. The nextElement method returns Object, which could be LDAPEntry, LDAPReferralException, or LDAPException. You are responsible for detecting the type of result (using instanceof) and taking appropriate action. The next method returns LDAPEntry and may throw an LDAPReferralException ...

Get LDAP Programming with Java™ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.