Searching and Comparing

The LDAP SDK allows you to compare a value in memory to the value of an attribute of an entry without actually retrieving the entry. This is called a compare operation. In many ways a compare can be simulated using a search by setting the scope of the search to SCOPE_BASE and providing a search filter with which the value can be compared; if an entry is returned, the compare operation was successful. A compare, however, may improve performance because the return data from the LDAP server is a small packet that says either that the value is the same or that it is different.

Let's examine a small piece of code to compare a specific record and see if the l attribute (the LDAP attribute for location) has the value Santa Clara ...

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.