Hi,
We're trying to use the API with Active Directory. Sometimes a search result
includes a SEARCH_RESULT_REFERENCE..
Even though I'm getting my result, I think this is telling me somewhere else I
can go find it.
I've never encountered this with ApacheDS as a server but in those cases it's a
single stand alone machine.
Any patterns or ideas about how to correctly handle this case are appreciated.
Thanks!
Here is the search request..
MessageType : SEARCH_REQUEST
Message ID : 2
SearchRequest
baseDn : 'dc=qualitysys,dc=com'
filter : '(sAMAccountName=test.user)'
scope : whole subtree
typesOnly : false
Size Limit : 1
Time Limit : 10000
Deref Aliases : deref Always
attributes : '*'
org.apache.directory.api.ldap.model.message.SearchRequestImpl@6a8393b3<mailto:org.apache.directory.api.ldap.model.message.SearchRequestImpl@6a8393b3>
Value of Response response = cursor.get();
MessageType : SEARCH_RESULT_REFERENCE
Message ID : 2
Search Result Reference
References
'ldap://ForestDnsZones.qualitysys.com/DC=ForestDnsZones,DC=qualitysys,DC=com'
Here's the code I'm using.
List<Entry> lstEntries = new ArrayList<Entry>();
req.setSizeLimit(limit);
SearchCursor cursor = connection.search(req);
try
{
int count = 0;
while(cursor.next())
{
count++;
Response response = cursor.get();
Entry entry =
((SearchResultEntry)response).getEntry(); // Exception is thrown here.
if (entry != null)
{
lstEntries.add(entry);
}
}
SearchResultDone done = cursor.getSearchResultDone();
java.lang.ClassCastException:
org.apache.directory.api.ldap.codec.decorators.SearchResultReferenceDecorator
cannot be cast to org.apache.directory.api.ldap.model.message.SearchResultEntry
at com.ibsamericainc.dir.DirectoryServerConnection.getEntries(Unknown
Source)
at
com.ibsamericainc.dir.DirectoryServerConnection.searchEntries(Unknown Source)
at
com.ibsamericainc.dir.DirectoryServerConnection.searchEntries(Unknown Source)
at com.ibsamericainc.dir.DirectoryServerConnection.searchEntry(Unknown
Source)
at
com.ibsamericainc.dir.DirectoryServerConnection.getEntryFromUsername(Unknown
Source)
at
com.ibsamericainc.dir.DirectoryServerConnection.getEntryFromUsername(Unknown
Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.