是否有更简洁的方法来分析错误代码的AuthenticationException?

Chr*_*wes 5 java ldap active-directory

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

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

[LDAP: error code 49 - 80090308: 
 LdapErr: DSID-0C090334, 
 comment: AcceptSecurityContext error, data 773, vece]
Run Code Online (Sandbox Code Playgroud)

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


抛出的片段AuthenticationException是用它写的org.springframework.security.ldap.DefaultSpringSecurityContextSource.

InitialLdapContext context = (InitialLdapContext) contextFactory
                     .getReadWriteContext(principal, password);
Run Code Online (Sandbox Code Playgroud)

Pau*_*ett 5

不幸的是,这是我看到它处理的唯一方法,因为我遇到的LDAP服务(Active Directory)产生的失败代码总是对消息中的失败代码进行编码.即使不是一种很好的做事方式,也不要感觉太糟糕.