1

如何使用 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);
4

1 回答 1

1

目录服务器在何处或在哪个主机上运行没有区别。当 LDAP 客户端连接到服务器时,该连接是unauthenticated。LDAP 客户端必须使用 BIND 请求来请求服务器将连接的授权状态更改为允许 LDAP 客户端所需操作的状态。

也可以看看

于 2013-07-30T18:25:23.830 回答