我试图为我的项目制作示例程序。它是带有弹簧启动的LDAP。
我在开发环境中对其进行了测试。然后,它运作良好。但是,当我在部署环境中对其进行测试时,会发生套接字关闭错误。
不同之处仅在于LDAP URL和密码(我无法使用特殊字符(例如@,#)设置admin的密码。
因此,我尝试在部署环境中使用ldapsearch访问LDAP。然后,我出现了一些错误。但是,当我搜索此错误时,找不到适合我的解决方案。
这是我用于访问LDAP的春季配置。
@Bean
public ContextSource contextSource() {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldap://192.168.113.12");
contextSource.setBase("dc=test,dc=test");
contextSource.setUserDn("cn=admin,dc=test,dc=test");
contextSource.setPassword("test2019!@");
contextSource.afterPropertiesSet();
//for develop
// contextSource.setUrl("ldap://192.168.0.192");
// contextSource.setPassword("test2019");
PoolingContextSource pcs = new PoolingContextSource();
pcs.setDirContextValidator(new DefaultDirContextValidator());
pcs.setContextSource(contextSource);
TransactionAwareContextSourceProxy proxy = new TransactionAwareContextSourceProxy(pcs);
return proxy;
}
@Bean
public LdapTemplate ldapTemplate() {
return new LdapTemplate(contextSource());
}
这是使用spring LDAP访问LDAP时的错误图片。
这是使用ldapsearch的错误图片。
帮帮我。
ps。我不知道LDAP服务器是如何实现的,因为它是由另一个团队安装的...
我想说这个端口不见了;)
contextSource.setUrl("ldap://192.168.113.12:389");