如何使用 UnboundID LDAP SDK 连接到 localhost?我认为这很简单,但也许不是。我使用以下代码连接得很好,但我希望可以选择只使用 locahost 连接而不必进行身份验证。
通过连接,我执行了一系列添加/删除/修改,这适用于以下连接。
public LDAPConnection connect(LdapConnectionModel connectionModel)
{
this.connectionModel = connectionModel;
try
{
// Determine is SSL port was specified
int port = connectionModel.isSslEnabled() ? SSL_PORT : PORT;
// Determined bind DN
String bindDN = connectionModel.getUsername() + "@" + connectionModel.getDomain();
// Connect
connection = new LDAPConnection(connectionModel.getHost(), port, bindDN, String.valueOf(connectionModel.getPassword()));
// Clear out our password
connectionModel.setPassword(new char[] {});
}
catch (LDAPException e)
{
LOG.warning("CONNECTION FAILED: " + e.getMessage());
LOG.warning(e.getMessage());
}
return connection;
}
例如,获得这样的连接很好,但随后我收到此错误:“为了执行此操作,必须在连接上完成成功的 bing。”
// Connect
connection = new LDAPConnection("localhost",389);