【问题标题】:Spring 5, get info from LDAP (AD)Spring 5,从 LDAP (AD) 获取信息
【发布时间】: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


    【解决方案1】:

    如果您只想获取信息,可以使用LdapTemplate。您可以找到信息spring documentation。此外,这个tutorial 有很多带有LdapTemplate 的ldap 查询示例

    【讨论】:

      猜你喜欢
      • 2012-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-21
      • 1970-01-01
      • 2012-01-15
      • 1970-01-01
      相关资源
      最近更新 更多