当我尝试使用 DIGEST-MD5 对使用 UnboundID LDAP SDK 的 ApacheDS 进行绑定时,出现以下错误。我已经使用 UnboundID 和 Apache Shiro 的简单绑定测试了连接,因此 ApacheDS 正在工作。
LDAPException(resultCode=82 (local error), errorMessage='Unable to create a subsequent DIGEST-MD5 SASL request: NullPointerException(trace='processChallenge(DigestMD5Client.java:339) / evaluateChallenge(DigestMD5Client.java:207) / processSASLBind(SASLHelper.java:149) / process(DIGESTMD5BindRequest.java:406) / bind(LDAPConnection.java:1837) / main(UnboundDemo.java:38)', revision=15579)')
at com.unboundid.ldap.sdk.SASLHelper.processSASLBind(SASLHelper.java:154)
at com.unboundid.ldap.sdk.DIGESTMD5BindRequest.process(DIGESTMD5BindRequest.java:406)
at com.unboundid.ldap.sdk.LDAPConnection.bind(LDAPConnection.java:1837)
at com.mizar.ldap.UnboundDemo.main(UnboundDemo.java:38)
Caused by: java.lang.NullPointerException
at com.sun.security.sasl.digest.DigestMD5Client.processChallenge(DigestMD5Client.java:339)
at com.sun.security.sasl.digest.DigestMD5Client.evaluateChallenge(DigestMD5Client.java:207)
at com.unboundid.ldap.sdk.SASLHelper.processSASLBind(SASLHelper.java:149)
... 3 more
我按照 JavaDoc 中的示例进行操作,示例测试代码如下所示:
LDAPConnection conn;
BindResult bindResult;
DIGESTMD5BindRequest mdBind;
try {
conn = new LDAPConnection("1.1.1.1",389);
mdBind = new DIGESTMD5BindRequest("dn:uid=someuser,ou=dev,dc=blah,dc=com", "test");
bindResult = conn.bind(mdBind);
System.out.println("MD5 bind success!");
}
catch (Exception e) {
e.printStackTrace();
}