private Authentication authenticateUserPassword(UsernamePasswordAuthenticationToken token) throws NamingException {
Object login = login(token);
LOGGER.debug("Starting authentication login='{}'", login);
Object password = token.getCredentials();
LdapContext ctx = createLdapCtx(login, password);
SearchControls ctrls = createSearchControls();
String filter = String.format(this.filter, login);
NamingEnumeration<SearchResult> ne = ctx.search(dn, filter, ctrls);
....
J'ai la méthode suivante pour connecter l'utilisateur. Cela dépend de LDAP. Parfois, il se bloque au dernier rang. Je ne sais pas pourquoi. Il se reproduit parfois sur des tests de performance.Définir le délai de la méthode sur la recherche Ldap
Est-il possible d'attendre un certain temps et si la méthode n'a pas répondu - retourner une valeur prédéfinie?
P.S.
private LdapContext createLdapCtx(Object login, Object password) throws NamingException {
Hashtable<String, String> props = new Hashtable<String, String>();
props.put(Context.INITIAL_CONTEXT_FACTORY, factory);
props.put(Context.PROVIDER_URL, url);
props.put(Context.SECURITY_AUTHENTICATION, "simple");
props.put(Context.SECURITY_PRINCIPAL, String.format(domain, login));
props.put(Context.SECURITY_CREDENTIALS, password.toString());
return new InitialLdapContext(props, null);
}
@RealSkeptic et Tunaki s'il vous plaît préciser la différence – gstackoverflow
@gstackoverflow Cela peut ne pas être tout à fait correct (je ne suis pas sûr de tous les détails gourmands), mais 'setTimeLimit' n'est pas utilisé pour les opérations de recherche (et je ne sais pas vraiment pourquoi) – Tunaki
NamingException est une exception ldap courante. Je n'ai pas vérifié mais je pense que TimeLimitExceededException sera lancé – gstackoverflow