spring - 如何解决 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 服务器是如何实现的,因为它是由另一个团队安装的......
解决方案
我会说港口不见了;)
contextSource.setUrl("ldap://192.168.113.12:389");
推荐阅读
- julia - Julia中2点之间的绘图线
- amazon-web-services - 如何使用 Amazon S3 Uri 链接下载图像?
- algorithm - OpenCV - 如何查看函数背后使用的算法?(读)
- node.js - 打字稿模块扩充在 Heroku 上部署时不起作用,但在本地工作
- prometheus-operator - 持久卷的仪表板显示 AKS 上没有数据
- python - 当我在 Django 中使用 INNER JOIN 时,原始查询结果成倍增加
- bash - 带有“路径必须在表达式之前”输出的 Bash 脚本
- python - 段的哈希
- laravel - 为什么将 ta-gallery 添加到 Laravel 8 应用程序中我在 tailwind.config.js 中出现错误?
- solidity - 使用 Hardhat 在 EtherScan 上验证智能合约时出错