<bean id="contextSource"
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<constructor-arg value="ldap://localhost:389/cn=Sandbox,dc=ITOrg"/>
<property name="userDn" value="cn=superuser,cn=People,cn=Sandbox,dc=ITOrg"/>
<property name="password" value="xxxxxx"/>
</bean>
<bean id="ldapAuthProvider"
class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<constructor-arg>
<bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
<constructor-arg ref="contextSource"/>
<property name="userDnPatterns">
<list>
<value>cn={0},cn=People</value>
</list>
</property>
</bean>
</constructor-arg>
</bean>
<bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
<constructor-arg index="0" value="cn=People"/>
<constructor-arg index="1" value="(cn={0})"/>
<constructor-arg index="2" ref="contextSource"/>
</bean>
<property name="userDn" value="cn=superuser,cn=People,cn=Sandbox,dc=ITOrg"/>
<value>cn={0},cn=People</value>
<constructor-arg index="0" value="cn=People"/>
<constructor-arg index="1" value="(cn={0})"/>
cn=People
(uid={0})
@Autowired
private LdapUserSearch ldapUserSearch;
@Autowired
private AuthenticationProvider authenticationProvider;
public void initialise()
{
DirContextOperations dirContextOperations = ldapUserSearch.searchForUser( "username" );
Authentication authentication = authenticationProvider.authenticate( new UsernamePasswordAuthenticationToken( "username", "password" ) );
}
Error 52b - Invalid password
[LDAP: error code 32 - 0000208D: NameErr: DSID-031521D2, problem 2001 (NO_OBJECT), data 0, best match of: 'CN=Sandbox,DC=ITOrg'
- This means the user is not in the administrator role (probably)