log.logInfo("ldapSearch: Truststore is " + System.getProperty("javax.net.ssl.trustStore"));
    private String ldapSearch(final InitialLdapContext ldap, final String pattern)    throws BackendException {        // Check pattern for illegal content.        String[] illegals = {"*", "\2a"};        for (int i = 0; i < illegals.length; i++) {            if (pattern.indexOf(illegals[i]) > -1)                return null;        }        // The context provider URL, for later logging.        String url = "unknown backend";        // Start counting the (milli)seconds.        long searchStart = System.currentTimeMillis();        NamingEnumeration results;        try {            // Remember the URL, for later logging.            url = (String) ldap.getEnvironment().get(Context.PROVIDER_URL);            // Perform the search.            results = ldap.search("", pattern, new SearchControls(SearchControls.SUBTREE_SCOPE, 1, 1000 * myTimeout, new String[] {}, false, false));            if (!results.hasMore())                return null;        } catch (TimeLimitExceededException e) {            // The search timed out.            throw new BackendException("Search on " + url + " for " + pattern                    + " timed out after " + (System.currentTimeMillis() - searchStart) + "ms", e);        } catch (NameNotFoundException e) {            // Element not found. Possibly non-existing reference.            log.logInfo("Could not find " + pattern + " on " + url, mySessionTicket); // Necessary?            return null;        } catch (LimitExceededException e) {            // We hit some configured limit on the server's part.            log.logInfo("Search on " + url + " for " + pattern + " exceeded some configured limit", mySessionTicket);            return null;        } catch (NamingException e) {            // All other exceptions.            throw new BackendException("Unable to complete search for " + pattern + " on " + url, e);        }        // We just found an element.        SearchResult entry = null;        try {            entry = (SearchResult) results.next();        } catch (NamingException e) {            throw new BackendException("Unable to read search results", e);        }        return entry.getName(); // Relative DN (to the reference).    }