【问题标题】:Common Name from Active Directory with Spring Security来自带有 Spring Security 的 Active Directory 的通用名称
【发布时间】:2011-12-23 22:28:04
【问题描述】:

我正在使用 Spring Security 3.1RC2 并且我正在使用 org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider 对象:

<security:authentication-manager>
    <security:authentication-provider  ref="adAuthenticationProvider" />
 </security:authentication-manager>

 <bean id="adAuthenticationProvider"
      class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
    <constructor-arg value="DOMAIN" />
    <constructor-arg value="ldap://1.1.1.1/" />
 </bean>

我可以使用SecurityContextHolder.getContext () 获取安全上下文,这将引导我找到用户的用户名,但我正在尝试找出如何进一步获取通用名称。

【问题讨论】:

    标签: java spring spring-security


    【解决方案1】:

    作为身份验证的结果,您将在返回的身份验证对象中获得 UserDetails 对象。这是通过实现用于将用户详细信息与 LDAP 上下文数据映射的 UserDetailsContextMapper 策略来完成的。更多信息请查看http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ldap.html。

    【讨论】:

    • 您知道 3.1 中的新广告内容吗?我希望避免在两个地方跟踪 LDAP 信息(一个在 Spring Security 配置中,另一个在我可以用于手动 LDAP 绑定的其他地方)。
    • 我没有看到 Spring Security 3.1 Whats new section 中提到的内容? static.springsource.org/spring-security/site/docs/3.1.x/… 为了避免在两个地方进行 LDAP 配置,请使用属性文件。 Spring 可以从属性文件中读取,您也可以从其他模块/应用程序中使用相同的属性文件。
    猜你喜欢
    • 2012-03-25
    • 2020-03-16
    • 2016-03-27
    • 2020-12-10
    • 2014-10-05
    • 2015-04-17
    • 1970-01-01
    • 2015-02-18
    • 2014-08-16
    相关资源
    最近更新 更多