1

为另一个 AD 集成问题道歉:)

我在 Windows Server 2008 R2 上全新安装了 JasperReports Server 5.2,我正在尝试配置 AD 身份验证,但登录总是失败。

我已将示例 applicationContext-externalAuth-LDAP.xml 文件复制到 WEB-INF 文件夹并对其进行了自定义:

    <bean id="ldapAuthenticationProvider" class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
        <constructor-arg>
            <bean class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator">
                <constructor-arg><ref local="ldapContextSource"/></constructor-arg>
                <property name="userSearch" ref="userSearch"/>
            </bean>
        </constructor-arg>
        <constructor-arg>
            <bean class="org.springframework.security.ldap.populator.DefaultLdapAuthoritiesPopulator">
                <constructor-arg index="0"><ref local="ldapContextSource"/></constructor-arg>
                <constructor-arg index="1"><value></value></constructor-arg>
                <property name="groupRoleAttribute" value="cn"/>
                <property name="groupSearchFilter" value="((member={0})(objectClass=group))"/>
                <property name="searchSubtree" value="true"/>
                <!-- Can setup additional external default roles here  <property name="defaultRole" value="LDAP"/> -->
            </bean>
        </constructor-arg>
    </bean>

    <bean id="userSearch"
          class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
        <constructor-arg index="0">
            <value></value>
        </constructor-arg>
        <constructor-arg index="1">
            <value>((sAMAccountName={0})(objectClass=user))</value>
        </constructor-arg>
        <constructor-arg index="2">
            <ref local="ldapContextSource" />
        </constructor-arg>
        <property name="searchSubtree">
            <value>true</value>
        </property>
    </bean>

    <bean id="ldapContextSource" class="com.jaspersoft.jasperserver.api.security.externalAuth.ldap.JSLdapContextSource">
        <constructor-arg value="ldap://hostname:389/dc=domain,dc=local"/>
        <!-- manager user name and password (may not be needed)  -->
        <property name="userDn" value="Administrator"/>
        <property name="password" value="password"/>
    </bean>

上面的实际主机名、域名和密码已被删除,我们的 AD 设置有点奇怪,因为用户分布在多个 OU 中,所以我将分支 DN 属性留空,并尝试将搜索限制为具有某些对象类(用户或组)。

我已经为 org.springframework.security 和 com.jaspersoft.jasperserver.api.security 启用了调试级别日志记录,但我在日志中没有得到任何特别有用的信息:

    2013-09-03 10:12:32,882 DEBUG BaseAuthenticationProcessingFilter,http-bio-80-exec-6:252 - Request is to process authentication
    2013-09-03 10:12:32,884 DEBUG ProviderManager,http-bio-80-exec-6:183 - Authentication attempt using org.springframework.security.providers.ldap.LdapAuthenticationProvider
    2013-09-03 10:12:32,888 DEBUG FilterBasedLdapUserSearch,http-bio-80-exec-6:109 - Searching for user 'username', with user search [ searchFilter: '((sAMAccountName={0})(objectClass=user))', searchBase: '', scope: subtree, searchTimeLimit: 0, derefLinkFlag: false ]
    2013-09-03 10:12:32,905 DEBUG SpringSecurityLdapTemplate,http-bio-80-exec-6:197 - Searching for entry in under DN 'dc=domain,dc=local', base = '', filter = '((sAMAccountName={0})(objectClass=user))'
    2013-09-03 10:12:32,933 DEBUG ProviderManager,http-bio-80-exec-6:183 - Authentication attempt using com.jaspersoft.jasperserver.api.security.internalAuth.InternalDaoAuthenticationProvider
    2013-09-03 10:12:32,940  WARN LoggerListener,http-bio-80-exec-6:60 - Authentication event AuthenticationFailureBadCredentialsEvent: username; details: org.springframework.security.ui.WebAuthenticationDetails@21a2c: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: F8EA36A4CF952E3DE41E7211B4EB529D; exception: Bad credentials
    2013-09-03 10:12:32,941 DEBUG BaseAuthenticationProcessingFilter,http-bio-80-exec-6:406 - Updated SecurityContextHolder to contain null Authentication
    2013-09-03 10:12:32,941 DEBUG BaseAuthenticationProcessingFilter,http-bio-80-exec-6:412 - Authentication request failed: org.springframework.security.BadCredentialsException: Bad credentials
    2013-09-03 10:12:32,943 DEBUG HttpSessionContextIntegrationFilter,http-bio-80-exec-6:255 - SecurityContextHolder now cleared, as request processing completed

感谢收到任何建议,我已经尝试过 externalAuth XML 文件中的设置,但似乎对日志或登录失败没有任何影响。

干杯,马特

4

1 回答 1

1

一般来说,在 AD 上进行 ldap 搜索时,唯一一次毫无根据的搜索会起作用是在与 GC 交谈时。

尝试放入 DC=domain,DC=local 的基础,这仍然应该搜索整个域。

同样在您的用户和组搜索中,您似乎缺少第一个 (.

例如

<property name="groupSearchFilter" value="(&amp;(member={0})(objectClass=group))"/>

<constructor-arg index="1">
    <value>(&amp;(sAMAccountName={0})(objectClass=user))</value>
</constructor-arg>

我看到的对 Spring LDAP 有帮助的最后一件事是将 DN 用于绑定帐户。

例如

高温高压

于 2013-09-17T02:38:22.053 回答