使用apache LDAP在java中进行LDAP身份验证

问题描述 投票:0回答:1

你能为我提供一个简单的apache LDAP身份验证示例吗?以下是我的示例代码段。

@Bean

CommandLineRunner runner() {
    return args -> {

        LOGGER.info("CommandLineRunner running in the UnsplashApplication class...");

        LdapConnection connection = new LdapNetworkConnection(
                "ldap://server.TEST.COM:389/DC=TEST,DC=COM", 389, false);
        connection.setTimeOut(0);
        LOGGER.info("@@ Trying to connect to LDAP...");

        connection.bind();
        connection.connect();
        LOGGER.info("@@ isConnected: " + connection.isConnected());

        // connection.bind("uid=user,ou=users", "password@123");
        // connection.bind("ou=users,DC=TEST,DC=COM", "password@123");

    };
}
java apache security authentication ldap
1个回答
0
投票
LdapConnection connection = new LdapNetworkConnection(
            "ldap://server.TEST.COM:389/DC=TEST,DC=COM", 389, false);

LdapNetworkConnection(String, int, boolean)的第一个参数是服务器名称,而不是URL。

非常好的线索

Hostname 'ldap://TEST.COM:389/DC=TEST,DC=COM' could not be resolved
© www.soinside.com 2019 - 2024. All rights reserved.