【发布时间】:2020-02-17 22:59:30
【问题描述】:
我正在尝试制作一个控制器,它接收电子邮件并从 Active Directory 中的该用户获取信息,并将其作为 json 返回。 我很难找到有用的材料,因为我发现的一切都是试图通过 WebSecurity 注释来教授身份验证...... 我不在乎身份验证,我只希望 Spring 获取信息而不是其他任何东西。
谁能告诉我如何摆脱这种状况,达到我需要的程度?
@Bean
public ActiveDirectoryLdapAuthenticationProvider activeDirectoryLdapAuthenticationProvider() {
ActiveDirectoryLdapAuthenticationProvider provider = new ActiveDirectoryLdapAuthenticationProvider(LDAP_DOMAIN, LDAP_URL, LDAP_ROOT_DN);
provider.setConvertSubErrorCodesToExceptions(true);
provider.setUseAuthenticationRequestCredentials(true);
provider.setSearchFilter(LDAP_FILTER);
return provider;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().fullyAuthenticated().and().formLogin();
}
【问题讨论】:
标签: java spring spring-security active-directory ldap