protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
        AuthenticationInfo info;
        try {
            info = queryForAuthenticationInfo(token, ensureContextFactory());
        } catch (javax.naming.AuthenticationException e) {
            throw new AuthenticationException("LDAP authentication failed.", e);
        } catch (NamingException e) {
            String msg = "LDAP naming error while attempting to authenticate user.";
            throw new AuthenticationException(msg, e);
        }

        return info;
    }
Configures the {@link LdapContextFactory} implementation that is used to create LDAP connections for
authentication and authorization.  If this is set, the {@link LdapContextFactory} provided will be used.
Otherwise, a {@link JndiLdapContextFactory} instance will be created based on the properties specified
in this realm.

@param ldapContextFactory the factory to use - if not specified, a default factory will be created automatically.
core/src/main/java/org/apache/shiro/realm/ldap/AbstractLdapRealm.java