简体   繁体   English

LDAP身份验证到AD错误代码

[英]LDAP Authentication to AD error code

I have one question, i'm trying to to authenticate to AD via LDAP, and when i put invalid credentials i got exception message like this: LDAPException(resultCode=49 (invalid credentials), errorMessage='80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db0 , and this is ok, but more exact reason of this exception is in part"data 52e", and it tell's me "invalid credentials ". When credentials are good but for example "password expired" in exception message i will get "data 532". This part of message can have different values depending of exception reason (533-account disabled, 701-account expired etc.). My problem is how to catch only this part of exception message. I want to handle the exception according to this error code. Fore example : 我有一个问题,我正在尝试通过LDAP进行AD身份验证,当我输入无效的凭据时,我收到了如下异常消息: LDAPException(resultCode=49 (invalid credentials), errorMessage='80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db0 ,这是可以的,但是此异常的更确切原因部分在“数据52e”中,它告诉我“无效凭据”。当凭据良好但例如“密码已过期”时在异常消息中,我将获得“数据532”。这部分消息可以根据异常原因(禁用533帐户,701帐户已过期等)而具有不同的值。我的问题是如何仅捕获这部分异常消息我想根据此错误代码处理异常,例如:

switch(err_code){
case 52e:
System.out.println("invalid credentials");
break;
case "530,":
System.out.println("not permitted to logon at this time");
break;
}

But I don't want to use regular expresions to match error code. 但是我不想使用常规表达式来匹配错误代码。 Any ideas? 有任何想法吗?

These codes are probably specific to Active Directory implementation. 这些代码可能特定于Active Directory实施。 Have a look at the explanation to the similar question . 看一下对类似问题的解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM