[英]LDAP: error code 49 - 80090308: LdapErr: DSID-0C09044E, comment: AcceptSecurityContext error, data 52e, v2580 (first time using ldap)
[英]LDAP error code 49 AcceptSecurityContext error data 52e v2580 even with the correct credentials
我正在向 spring-boot 應用程序添加 LDAP 身份驗證。 全部設置相應,即使提供了正確的憑據,我也會收到“LDAP 錯誤代碼 49 AcceptSecurityContext 錯誤數據 52e v2580”錯誤。
我正在使用import javax.naming.Context;
並提到了下面的代碼。
String url = ldap_url;
String domain = ldap_domain;
String uname = request.getUsername();
String pwd = request.getPassword();
boolean authentication = false;
boolean error = true;
String msg;
String ldapSearchBase = "OU=TEST_OU, DC=DC2, DC=DC1";
// create env for initial context
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, url);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "CN=" + uname + "@" + domain + "," + ldapSearchBase);
env.put(Context.SECURITY_CREDENTIALS, pwd);
NamingEnumeration results = null;
try {
LdapContext ctx = new InitialLdapContext(env, null);
authentication = true;
error = false;
} catch (NamingException e) {
logger.error("LDAP error for :{NamingException}" + e);
return ResponseEntity.ok(new ApiResponse(true, e.getMessage()));
} finally {
if (!error) {
msg = "Login success!!!";
} else {
msg = "Authentication failed!";
}
}
logger.info("exitinig...");
if (authentication) {
return ResponseEntity.ok(new ApiResponse(false, msg));
} else {
return ResponseEntity.ok(new ApiResponse(true, msg));
}
錯誤被捕獲為NamingException
。
錯誤響應 LDAP 錯誤代碼 49... 數據 52e “當用戶名有效但密碼/憑據無效時返回。”
可能存在基礎架構問題,例如域 controller 計算機帳戶可能無法與密鑰分發中心 (KDC) 同步。 但是,當這種情況存在時,您可能會遇到更多其他問題。
如果您指定用戶名而不是 windows 域,您可能會在 Active Directory(Windows 流行的 LDAP 實現)中遇到此錯誤。
這是你應該做的:
用戶名:<YOUR_WINDOWS_DOMAIN><YOUR_USERNAME>
密碼:<您的密碼>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.