你能为我提供一个简单的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");
};
}
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