Hi, We've starting moving some of our JNDI code to the ApacheDS API. The
method below is used to get an Array of entries.
When we close the cursor ( I think), we see the following log message.
[NioProcessor-4] WARN org.apache.directory.shared.asn1.ber.Asn1Decoder -
ERR_00043_REMAINING_BYTES_FOR_DECODED_PDU The PDU has been fully decoded but
there are still bytes in the buffer.
We get the results we want but is there something else we need to do with the
cursor to avoid the message? Thanks.
protected Entry[] getEntries(SearchRequest req, long limit) throws
LdapException{
List<Entry> lstEntries = new ArrayList<Entry>();
req.setSizeLimit(limit);
SearchCursor cursor = connection.search(req);
try {
while(cursor.next()){
Response response = cursor.get();
Entry entry =
((SearchResultEntry)response).getEntry();
lstEntries.add(entry);
}
SearchResultDone done = cursor.getSearchResultDone();
if(ResultCodeEnum.SUCCESS.equals(done.getLdapResult().getResultCode())){
cursor.close();
}
else
{
log.error(ERROR_LDAP_RESULT,
done.getLdapResult().getResultCode().toString());
}
} catch (Exception e) {
e.printStackTrace();
try {
cursor.close(e);
} catch (Exception e1) {
e1.printStackTrace();
}
}
return lstEntries.toArray(new Entry[lstEntries.size()]);
}
We set the SearchRequest up like this.
SearchRequest req = new SearchRequestImpl();
try {
req.setBase(new Dn(strDefaultDirRootSuffix));
req.setScope(SearchScope.SUBTREE);
req.setFilter(strSearch);
if (attrs != null && attrs.length > 0){
req.addAttributes(attrs);
} else {
req.addAttributes(DEFAULT_ATTRIBUTES);
}
} catch (LdapInvalidDnException e1) {
e1.printStackTrace();
} catch (LdapException e) {
e.printStackTrace();
}