我尝试设置Springboot Security以使用Active Directory对用户进行身份验证。
我已遵循本指南:
https://medium.com/@dmarko484/spring-boot-active-directory-authentication-5ea04969f220
并拥有以下内容:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated().and().httpBasic();
}
@Override
protected void configure(AuthenticationManagerBuilder authManagerBuilder) throws Exception {
authManagerBuilder.authenticationProvider(activeDirectoryLdapAuthenticationProvider()).userDetailsService(userDetailsService());
}
@Bean
public AuthenticationManager authenticationManager() {
return new ProviderManager(Arrays.asList(activeDirectoryLdapAuthenticationProvider()));
}
@Bean
public AuthenticationProvider activeDirectoryLdapAuthenticationProvider() {
ActiveDirectoryLdapAuthenticationProvider provider = new ActiveDirectoryLdapAuthenticationProvider("test.local", "ldap://192.168.0.26:389");
provider.setConvertSubErrorCodesToExceptions(true);
provider.setUseAuthenticationRequestCredentials(true);
return provider;
}
}
我已设置管理员用户(可以使用它登录Windows Server 2012)并在服务器上安装Active Directory域服务确定。
但是当我登录时(目前正在使用HTTP Basic),我总是得到" Bad Credentials"
我试过了: 用户名:管理员密码:密码 用户名:TEST \ Administrator密码:密码 用户名:Administrator@test.local密码:密码
然而,这些组合中的每一个都给出了坏证书。
是否还需要在AD中设置其他内容以允许外部登录?目前,我只是安装并配置了AD DS的Windows Server 2012虚拟机。
我还使用服务器上的Get-ADDomain检查了域名,这是正确的。
是的,我已经检查了用户名和密码拼写....
非常感谢任何帮助!
由于