当ldapwhoami -U portal -h yorktown -Y PLAIN -ZZ
工作得很好时,有人能看出这个代码不起作用的原因吗?我正在做的事情是不是等同于什么?
LDAPConnection connection = new LDAPConnection();
connection.connect("yorktown.example.com", 389);
SSLUtil sslUtil = new SSLUtil(new TrustAllTrustManager());
SSLContext sslContext = sslUtil.createSSLContext();
ExtendedResult extendedResult = connection.processExtendedOperation(new StartTLSExtendedRequest(sslContext));
PLAINBindRequest bindRequest = new PLAINBindRequest("u:portal", "test");
BindResult bindResult = connection.bind(bindRequest);
此代码提供connection.bind
调用抛出的以下异常:
play.exceptions.JavaExecutionException: SASL(-13): user not found: Password verification failed at play.mvc.ActionInvoker.invoke(ActionInvoker.java:285) at Invocation.HTTP Request(Play!) Caused by: LDAPException(resultCode=49 (invalid credentials), errorMessage='SASL(-13): user not found: Password verification failed', diagnosticMessage='SASL(-13): user not found: Password verification failed') at com.unboundid.ldap.sdk.LDAPConnection.bind(LDAPConnection.java:1710)
答案 0 :(得分:0)
PLAINBindRequest
的文档是错误的,或者OpenLDAP 2.4.23处理请求的方式有问题。服务器日志显示u:
正在传递到服务器,从而产生uid=u:portal,dc=example,dc=com
之类的DN。一旦我将其更改为new PLAINBindRequest("portal", "test")
,就可以了。