@Override
                public void handle(final ILdapClientConnection connection) {
                    String searchBaseDN = formatDn(config.getUserSearch().getBaseDn(), username, request);
                    String searchExpr = formatDn(config.getUserSearch().getExpression(), username, request);

                    connection.search(searchBaseDN, searchExpr, LdapSearchScope.SUBTREE)
                            .setLdapErrorHandler(new IAsyncHandler<LdapException>() {
                                // At the moment it's just generic, but in future we can make better use of it.
                                @Override
                                public void handle(LdapException exception) {
                                    handler.handle(AsyncResultImpl.<Boolean>create(exception));
                                }
                            }).search(successHandler(handler, new IAsyncHandler<List<ILdapSearchEntry>>() {

                                @Override
                                public void handle(List<ILdapSearchEntry> searchEntries) {
                                    handleLdapSearch(connection, searchEntries, config, ldapConfigBean,
                                            ldapComponent, context, username, password, handler);
                                }
                            }));
                }
@see io.apiman.gateway.engine.policies.auth.IIdentityValidator#validate(java.lang.String, java.lang.String, io.apiman.gateway.engine.beans.ApiRequest, io.apiman.gateway.engine.policy.IPolicyContext, java.lang.Object, io.apiman.gateway.engine.async.IAsyncResultHandler)
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/auth/LDAPIdentityValidator.java