results = ldap.search("", pattern, new SearchControls(SearchControls.SUBTREE_SCOPE, 1, Integer.parseInt(Configuration.getProperty("no.feide.moria.backend.ldap.timeout", "15")), new String[] {}, false, true));
long searchStart = System.currentTimeMillis(); results = ldap.search("", pattern, new SearchControls(SearchControls.SUBTREE_SCOPE, 1, 1000*Integer.parseInt(Configuration.getProperty("no.feide.moria.backend.ldap.timeout", "15")), new String[] {}, false, true));
    private String ldapSearch(String pattern)    throws BackendException {        log.finer("ldapSearch(String)");                try {                        NamingEnumeration results;            try {                // Search and destroy.                try {                    results = ldap.search("", pattern, new SearchControls(SearchControls.SUBTREE_SCOPE, 1, Integer.parseInt(Configuration.getProperty("no.feide.moria.backend.ldap.timeout", "15")), new String[] {}, false, true));                } catch (ConfigurationException e) {                    log.severe("ConfigurationException caught and re-thrown as BackendException");                    throw new BackendException(e);                }                if (!results.hasMore()) {                    log.warning("No match for "+pattern+" on "+ldap.getEnvironment().get(Context.PROVIDER_URL));                    return null;                }                            } catch (LdapReferralException e) {                                // We just caught a referral. Follow it recursively, enabling                // SSL.                log.info("Enabling SSL");                Hashtable refEnv = new Hashtable();                refEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");                refEnv.put(Context.REFERRAL, "throw");  // To catch referrals.                refEnv.put(Context.SECURITY_PROTOCOL, "ssl");                refEnv = e.getReferralContext(refEnv).getEnvironment();                log.info("Matched "+pattern+" to referral "+refEnv.get(Context.PROVIDER_URL));                ldap.close();                ldap = new InitialLdapContext(refEnv, null);                return ldapSearch(pattern);                            }                        // We just found an element.            SearchResult entry = (SearchResult)results.next();            String rdn = entry.getName();            log.info("Matched "+pattern+" on "+ldap.getEnvironment().get(Context.PROVIDER_URL)+" to element "+rdn);            return rdn;                    } catch (NamingException e) {            e.printStackTrace();            log.severe("NamingException caught and re-thrown as BackendException");            throw new BackendException(e);        }    }