【问题标题】:spring LDAP does not throw specific error codespring LDAP 不会抛出特定的错误代码
【发布时间】:2021-04-07 15:28:54
【问题描述】:

环境

  1. LDAP 服务器:TurnKey OpenLDAP
  2. Spring-ldap-core 版本:2.3.3.RELEASE

活动是什么

  1. 用户被锁定在 LDAP 服务器中
  2. 用户尝试通过我们的网络应用登录
  3. 登录失败
  4. 错误代码 49 - 抛出无效凭据

预期结果

应该抛出特定的异常(例如:错误代码775 USER_ACCOUNT_LOCKED)

例外

commentdata 等一些信息在异常中找不到

org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]; nested exception is javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
    at org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:191)```

【问题讨论】:

  • 你的问题是什么?

标签: java spring ldap


【解决方案1】:

LDAP 规范是基础。它定义了错误代码。 诸如 OPEN_LDAP、ACTIVE_DIRECTORY 等 LDAP 的实现可以定义自己的带有异常消息的子错误代码。 Active Directory 在错误消息中提供自己的子错误代码。 ldap-related-rfcs active-directory-error-codes

【讨论】:

    【解决方案2】:

    LDAP protocol RFC 没有为被拒绝的身份验证请求提供所需的粒度级别,它只是错误代码 49 invalidCredentials。标准中没有锁定帐户。

    在另一个关于错误代码的LDAP wiki documentation here中,它还指定错误代码49对锁定的帐户有效。

    如果您热衷于拥有此功能,您可以选择控制您的安全层并为您的应用程序设置最大重试次数(而不是依赖第三方 LDAP 服务器中的默认设置),如果它是达到,并抛出/返回您想要的适当响应。我可以在 this post 中看到一个示例,说明您如何做到这一点,但如果您想这样做,我会花更多时间寻找最佳解决方案。

    【讨论】:

    • 谢谢克里斯蒂安·托德。你说的对。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-04
    • 2014-06-19
    • 1970-01-01
    • 2019-02-23
    • 2017-07-08
    • 2013-06-03
    • 1970-01-01
    相关资源
    最近更新 更多