If you use the IETF LDAP API to develop your application, maybe you’ve not noticed some operations work in asynchronous mode by default. For example, let’s consider the following piece of code, which generates a simple LDAP search request for entries matching a given email address :

LDAPSearchResults res = conn.search(ldapUserBase, LDAPConnection.SCOPE_SUB, « (mail= » + aEmailAddress + « ) », attrs, false);

Written this way, the API may return partial results, since the request will be considered as asynchronous. To prevent such « headache prone » behaviour, the proper way to make such requests consists in adding an LDAP search constraint to the request, with a 0 batch size, as shown below:

LDAPSearchConstraints cons = new LDAPSearchConstraints(); cons.setBatchSize(0); LDAPSearchResults res = conn.search(ldapUserBase, LDAPConnection.SCOPE_SUB, « (mail= » + aEmailAddress + « ) », attrs, false, cons);

Les derniers articles par janua (tout voir)