我創建一個本地LDAP服務器,並添加用戶「djiao」,密碼爲「123456 使用什麼登錄名春LDAP身份驗證
試圖與春季安全和Spring引導來實現認證。我webconfig類如下:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest()
.authenticated()
.and()
.formLogin();
}
@Bean
public ActiveDirectoryLdapAuthenticationProvider activeDirectoryLdapAuthenticationProvider() {
ActiveDirectoryLdapAuthenticationProvider provider = new ActiveDirectoryLdapAuthenticationProvider("", "ldap://localhost:10389");
provider.setConvertSubErrorCodesToExceptions(true);
provider.setConvertSubErrorCodesToExceptions(true);
provider.setUseAuthenticationRequestCredentials(true);
return provider;
}
@Bean
public LoggerListener loggerListener() {
return new LoggerListener();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(activeDirectoryLdapAuthenticationProvider());
}
但是我似乎無法從登錄頁面登錄
如果我使用djiao(。 (LDAP:error code 34 - 給出的DN不正確:djiao1(0x64 0x6A 0x69 0x61 0x6F 0x31)無效];嵌套異常是javax.naming.InvalidNameException:[LDAP:錯誤代碼34 - 錯誤的DN給出:djiao1(0x64 0x6A 0x69 0x61 0x6F 0x31)無效]
如果我使用dn「cn = djiao,ou = Users, dc = example,dc = com「作爲用戶名,我將得到」Bad credentials「錯誤。並且密碼僅爲123456.
登錄的用戶名應該是什麼?或者我在websecurityconfig類中丟失了什麼?
正如我所看到的,您正在使用正在尋找名爲SAMAccountName而不是uid的屬性的AD連接器。請檢查「正常」Ldap連接器。 –
@ daniel.eichten我是Spring Security的新手。我需要使用普通的ldap連接器進行哪些更改? – Nasreddin