现在我有以下代码来创建新的连接:
return LDAPConnection(opts, host, port).apply {
connectionName = "foo-$userDn-$host-$port"
processExtendedOperation(StartTLSExtendedRequest(SSLUtil(TrustAllTrustManager()).createSSLContext()))
bind(userDn, password)
}
现在我想切换使用LDAPConnectionPool
。
我尝试这样做:
val simpleBindRequest = SimpleBindRequest(userDn, password)
val exampleConnection = LDAPConnection(opts, host, port).apply {
connectionName = "foo-$userDn-$host-$port"
processExtendedOperation(StartTLSExtendedRequest(SSLUtil(TrustAllTrustManager()).createSSLContext()))
bind(simpleBindRequest )
}
val ldapConnectionPool = LDAPConnectionPool(exampleConnection , 1, 10)
ldapConnectionPool.setBindRequest(simpleBindRequest)
稍后在某段代码中我第一次调用了 fir
connectionPool.getConnection()
并且它有效,因为它返回最初传递的连接(exampleConnection
)
但是当我打电话的时候
connectionPool.getConnection()
第二次我得到 LDAPException:
LDAPException(resultCode = 8(需要强身份验证),diagnosticMessage ='BindSimple:需要传输加密。',ldapSDKVersion = 6.0.11,修订版 = 8b21d0a4c6eb8b5c3e60a96fc3e9e13b9c2f650f)在com.unboundid.ldap.sdk.LDAPConnectionPool.createConnection(LDAPConnectionPool.java:1388)在com.unboundid.ldap.sdk.LDAPConnectionPool.createConnection(LDAPConnectionPool.java:1269)在com.unboundid.ldap.sdk.LDAPConnectionPool.getConnection(LDAPConnectionPool.java:1866)
我想是因为
processExtendedOperation(StartTLSExtendedRequest(SSLUtil(TrustAllTrustManager()).createSSLContext()))
未被调用
有办法解决吗?