On 10/18/10 9:20 AM, Jukka Väänänen wrote:
Hi,
For testing purposes I need LDAP server that simulates some failure conditions
and such on search request. With my limited research it would seem that I could
do that with custom SearchHandler. But I can't find out how I can define custom
SearchHandler to be used. Is there documentation on this somewhere? Can someone
enlighten me? Is this something that can be done with configuration or does it
need code changes?
Without modifying the server code, it's not possible. However, you only
have one place you have to deal with if you want to substitute the
standard handling of search request in order to do what you want.
The project apacheds-protocol-ldap has a class
org.apache.directory.server.ldap.handlers.SearchHandler which deal with
all the search requests, and you can modify it, *or* you can also define
your own handler and inject it when the LdapServer instanc eis being
created.
Let's go for the second options. The
org.apache.directory.server.ldap.LdapServer class, in the same
sub-project ( apacheds-protocl-ldap) initialize the handlers in the
installDefaultHandlers() method :
...
if ( getSearchHandler() == null )
{
setSearchHandler( new SearchHandler() );
}
...
You can define your own SeahcHandler class, and inject it in place.
If you don't want to do that, then back to modifying the SearchHandler
class itself. It's just a matter of modifying the handler() method. In
order to generate an error, you have to call the handleException()
method with the appropriate exception (all the LDAP errors are mapped to
the appropriate LdapException extended class).
Hope it's clear enough...
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com