成功进行LDAP身份验证后出错

时间:2017-09-15 07:50:19

标签: java ldap

我正在使用电子邮件和密码进行LDAP身份验证。在成功进行身份验证后,我在响应中返回了一些错误。我怀疑这是由于配置错误造成的。我有猴子修补了验证部分并粘贴在这里,提前感谢!

private Authenticator  createAuthenticator() throws Exception{
    NoOpDnResolver dnResolver = new NoOpDnResolver();
    final ConnectionConfig connectionConfig = new ConnectionConfig();
    connectionConfig.setConnectTimeout(Duration.ofSeconds(3));
    connectionConfig.setResponseTimeout(Duration.ofSeconds(6));
    connectionConfig.setLdapUrl("some ldap server");

    connectionFactory.setConnectionConfig(connectionConfig);
    connectionFactory.getConnection().open();
    final PoolConfig poolConfig = new PoolConfig();
    poolConfig.setMinPoolSize(1);
    poolConfig.setMaxPoolSize(5);
    poolConfig.setValidateOnCheckOut(false);
    poolConfig.setValidateOnCheckIn(false);
    poolConfig.setValidatePeriodically(false);

    final BlockingConnectionPool connectionPool = new BlockingConnectionPool();
    connectionPool.setPoolConfig(poolConfig);
    connectionPool.setBlockWaitTime(Duration.ofSeconds(10));
    connectionPool.setConnectionFactory(connectionFactory);

    connectionPool.initialize();
    final PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory();
    pooledConnectionFactory.setConnectionPool(connectionPool);
    final PooledBindAuthenticationHandler handler = new PooledBindAuthenticationHandler();
    handler.setConnectionFactory(pooledConnectionFactory);
    final Authenticator authenticator = new Authenticator();
    authenticator.setDnResolver(dnResolver);
    authenticator.setAuthenticationHandler(handler);
    return authenticator;
}


public void testLdap() throws Exception {
        connectionFactory = new DefaultConnectionFactory();
        final AuthenticationRequest request = new AuthenticationRequest("someemail", new org.ldaptive.Credential("somepassword"),
                ReturnAttributes.NONE.value());
        final AuthenticationResponse response = createAuthenticator().authenticate(request);
}

这是相关的错误日志:

  

[2017-09-15 15:23:40.964] log4j - 9028 DEBUG [main] --- BindOperation:   执行请求= [org.ldaptive.BindRequest@743893925 :: bindDn = someemail,   saslConfig = null,controls = null,referralHandler = null,   intermediateResponseHandlers = null] with   连接= [org.ldaptive.DefaultConnectionFactory$DefaultConnection@436338687 ::配置= [org.ldaptive.ConnectionConfig@938941445 :: LDAPURL = someldapurl,   connectTimeout = PT3S,responseTimeout = PT6S,sslConfig = null,   useSSL = false,useStartTLS = false,connectionInitializer = null,   connectionStrategy=org.ldaptive.DefaultConnectionStrategy@5bd3ca3c]   providerConnectionFactory = [org.ldaptive.provider.jndi.JndiConnectionFactory@1647441786 ::元数据= [LDAPURL = someldapurl,   count = 1],environment = {com.sun.jndi.ldap.connect.timeout = 3000,   java.naming.ldap.version = 3,   java.naming.factory.initial的= com.sun.jndi.ldap.LdapCtxFactory,   com.sun.jndi.ldap.read.timeout = 6000},classLoader = null,   providerConfig = [org.ldaptive.provider.jndi.JndiProviderConfig@688662124 :: operationExceptionResultCodes = [PROTOCOL_ERROR,   SERVER_DOWN],properties = {},   controlProcessor=org.ldaptive.provider.ControlProcessor@75b363c3,   environment = null,tracePackets = null,removeDnUrls = true,   searchIgnoreResultCodes = [TIME_LIMIT_EXCEEDED,SIZE_LIMIT_EXCEEDED,   PARTIAL_RESULTS],classLoader = null,sslSocketFactory = null,   的HostnameVerifier =空],   providerConnection=org.ldaptive.provider.jndi.JndiConnection@6ea3a513]

0 个答案:

没有答案