Active directory 使用SpringSecurity2.0.3的LDAP身份验证
我正在尝试使用SpringSecurity2.0.3进行LDAP身份验证 这是我的配置Active directory 使用SpringSecurity2.0.3的LDAP身份验证,active-directory,spring-security,ldap,spring-ldap,Active Directory,Spring Security,Ldap,Spring Ldap,我正在尝试使用SpringSecurity2.0.3进行LDAP身份验证 这是我的配置 <bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource"> <constructor-arg value="ldap://IP:3268"/> <property name="base" value="d
<bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<constructor-arg value="ldap://IP:3268"/>
<property name="base" value="dc=alliance",dc=com,OU=Users,OU=India"/>
<property name="userDn" value="sAMAccountName=username" />
<property name="password" value="password" />
</bean>
<bean id="ldapProvider" class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
<sec:custom-authentication-provider/>
<constructor-arg>
<bean class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator">
<constructor-arg ref="contextSource"/>
<!--<property name="userSearch" ref="ldapSearchBean"/>-->
<property name="userDnPatterns">
<list><value>sAMAccountName={0}</value></list>
</property>
</bean>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.security.ldap.populator.DefaultLdapAuthoritiesPopulator">
<constructor-arg ref="contextSource"/>
<constructor-arg value="ou=groups"/>
<property name="groupSearchFilter" value="member={0}"/>
<property name="groupRoleAttribute" value="ou"/>
<property name="rolePrefix" value="ROLE_"/>
<property name="searchSubtree" value="true"/>
<property name="convertToUpperCase" value="true"/>
</bean>
</constructor-arg>
</bean>
如果您联机搜索错误消息,您会发现类似的内容,它在顶部列出了您的错误:
Common Active Directory LDAP bind errors:
80090308: LdapErr: DSID-0C09030B, comment: AcceptSecurityContext error, data 525, v893
HEX: 0×525 – user not found
DEC: 1317 – ERROR_NO_SUCH_USER (The specified account does not exist.)
NOTE: Returns when username is invalid.
所以根据广告,用户并不存在。您尝试将sAMAccountName
属性用作DN模式的一部分,但由于它是LDAP属性,因此无法使用。您需要使用搜索来首先通过此属性的值定位用户。本网站和web上的其他地方都有这样做的例子。看起来您已经尝试过了,因为您注释掉了一个搜索bean。如果这不起作用,你应该解释一下你的问题出了什么问题
事实上,它似乎失败了,因为您的上下文源有一些问题。的值是错误的。它必须是目录中的有效可分辨名称,而“sAMAccountName=username”不是。“base”属性看起来也不正确。它通常应该是根目录树(dc=mycompany,dc=com
位于末尾)。所以它应该是ou=mygroup,ou=mycountry,dc=mycompany,dc=com
最后,您不应该使用版本2.0.3。它已知安全漏洞。始终更新您正在使用的修补程序和库的新版本-。如果遇到已修复的bug,检查最新版本也是有意义的
Common Active Directory LDAP bind errors:
80090308: LdapErr: DSID-0C09030B, comment: AcceptSecurityContext error, data 525, v893
HEX: 0×525 – user not found
DEC: 1317 – ERROR_NO_SUCH_USER (The specified account does not exist.)
NOTE: Returns when username is invalid.