使用 openldap 服务器进行 java sasl 身份验证
当 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)
Can anyone see any reason this code doesn't work when ldapwhoami -U portal -h yorktown -Y PLAIN -ZZ
works just fine? Is there something I'm doing that isn't equivalent?
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);
this code gives the following exception thrown by the connection.bind
call:
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PLAINBindRequest
的文档有误,或者 OpenLDAP 2.4.23 处理请求的方式有问题。服务器日志显示u:
正在传递到服务器,导致 DN 类似于uid=u:portal,dc=example,dc=com
。一旦我将其更改为new PLAINBindRequest("portal", "test")
,它就起作用了。Either the documentation for
PLAINBindRequest
is wrong or there's something wrong with how OpenLDAP 2.4.23 is handling the request. Server logs revealed that theu:
was being passed through to the server, resulting in DNs likeuid=u:portal,dc=example,dc=com
. Once I changed it tonew PLAINBindRequest("portal", "test")
it worked.