O'Reilly logo

LDAP Programming with Java™ by Tony Dahbura, Rob Weltman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required