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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.