java - 无需用户名/密码的简单安全身份验证即可产生结果

标签 java ldap apacheds

为什么这有效?

env.put(Context.PROVIDER_URL, "ldap://localhost:10389/o=csRepository");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
//env.put(Context.SECURITY_PRINCIPAL, "cn=John Eipe, ou=employees, o=csRepository");
//env.put(Context.SECURITY_CREDENTIALS, "qwer1234");

DirContext ctx = new InitialDirContext(env);
//operations on ctx

我的理解是,当 SECURITY_AUTHENTICATION 指定为简单且未指定用户名或密码时,它应该抛出 javax.naming.AuthenticationException。

最佳答案

已解决。可悲的是它就是这样运作的。 Oracle 文档中对此进行了如下说明。

If you supply an empty string, an empty byte/char array, or null to the Context.SECURITY_CREDENTIALS environment property, then the authentication mechanism will be "none". This is because the LDAP requires the password to be nonempty for simple authentication. The protocol automatically converts the authentication to "none" if a password is not supplied.

这会导致严重的安全漏洞。但是,我想这是留给应用程序来验证的。

关于java - 无需用户名/密码的简单安全身份验证即可产生结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22881112/

相关文章:

java - 通过 LdapExtLoginModule 针对 Active Directory 林 (LDAP_REFERRAL) 进行身份验证

java - 为什么我无法获取所有页面

java - 将 Web 服务添加到已经可用的 Java 项目

java - 如何在java中用字符串数组检查字符串?

java - 如何使用非管理员用户登录apacheds

java - 在我的应用程序中嵌入 ApacheDS,它在 service.startup() 上失败 -> DefaultSchemaService.getSchemaManager() 返回 null

java - 使用 java.util.Calendar 在 Java 中获取一年中的下一周

c++ - ADsOpenObject 绑定(bind)失败

c# - Mono.Security加载问题