【问题标题】:Is there a neater way to analyse the AuthenticationException for the error code?有没有更简洁的方法来分析错误代码的 AuthenticationException ?
【发布时间】:2023-04-09 12:29:01
【问题描述】:

有没有更简洁的方法来检查javax.naming.AuthenticationException(或弹簧)的主要故障原因? LDAP Wiki (Binding Errors) 中描述了不同的错误。

AuthenticationException 没有提供足够的 API 来轻松确定错误代码。唯一的内容是异常消息。

[LDAP: error code 49 - 80090308: 
 LdapErr: DSID-0C090334, 
 comment: AcceptSecurityContext error, data 773, vece]

标识块是“数据 773”——代表错误 ERROR_PASSWORD_MUST_CHANGE。但是检查message.contains("data 773") 对我来说感觉很奇怪!有没有更好的方法检查错误码?


抛出AuthenticationException的sn-p是用org.springframework.security.ldap.DefaultSpringSecurityContextSource写的。

InitialLdapContext context = (InitialLdapContext) contextFactory
                     .getReadWriteContext(principal, password);

【问题讨论】:

    标签: java active-directory ldap


    【解决方案1】:

    不幸的是,这是我见过的唯一处理方法,因为我使用过的 LDAP 服务(Active Directory)产生的故障代码总是在消息中对故障代码进行编码。即使这不是一个好的做事方式,也不要感觉太糟糕。

    【讨论】:

      【解决方案2】:

      据我所知,没有更好的实现。您可以尝试在外部文件中为 ldap 错误代码提供完整的翻译,并使用它们进行翻译。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-30
        • 1970-01-01
        相关资源
        最近更新 更多