首页 > 解决方案 > 如何解决 Spring LDAP 中的 ldap 套接字关闭错误?

问题描述

我试图为我的项目制作示例程序。它是带有 Spring Boot 的 LDAP。

我在我的开发环境中对其进行了测试。然后,它运作良好。但是,当我在部署环境中测试它时,会出现套接字关闭错误。

区别只是 LDAP URL 和密码(我不能用特殊字符设置 admin 的密码,例如。@、#)。

因此,我尝试在部署环境中使用 ldapsearch 访问 LDAP。然后,我得到了一些错误。但是,当我搜索此错误时,我无法为我搜索合适的解决方案。

这是我访问 LDAP 的 spring 配置。

@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 的错误图片。

在此处输入图像描述 在此处输入图像描述

帮我。

附言。我不知道 LDAP 服务器是如何实现的,因为它是由另一个团队安装的......

标签: springspring-bootldapspring-ldap

解决方案


我会说港口不见了;)

contextSource.setUrl("ldap://192.168.113.12:389");

推荐阅读