繁体   English   中英

如何使用UnboundID LDAP SDK连接到本地主机?

[英]How do I connect to the localhost using UnboundID LDAP SDK?

如何使用UnboundID LDAP SDK连接到本地主机? 我认为这很简单,但也许不是。 我可以使用以下代码很好地进行连接,但是我希望可以选择仅使用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);

在目录服务器的运行位置或主机上没有什么区别。 LDAP客户端连接到服务器时,该连接未经身份验证 LDAP客户端必须使用BIND请求来请求服务器将连接的授权状态更改为允许LDAP客户端进行所需操作的状态。

也可以看看

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM