SEC-1848: LDAP encode name when using user DN patterns in AbstractLdapAuthenticator.

This commit is contained in:
Luke Taylor 2011-11-01 13:28:56 +00:00
parent 8fd2963e6b
commit 8e1d407e3e
2 changed files with 4 additions and 2 deletions

View File

@ -55,10 +55,11 @@ public class BindAuthenticatorTests extends AbstractLdapIntegrationTests {
@Test
public void testAuthenticationWithCorrectPasswordSucceeds() {
authenticator.setUserDnPatterns(new String[] {"uid={0},ou=people"});
authenticator.setUserDnPatterns(new String[] {"uid={0},ou=people", "cn={0},ou=people"});
DirContextOperations user = authenticator.authenticate(bob);
assertEquals("bob", user.getStringAttribute("uid"));
authenticator.authenticate(new UsernamePasswordAuthenticationToken("mouse, jerry", "jerryspassword"));
}
@Test

View File

@ -15,6 +15,7 @@
package org.springframework.security.ldap.authentication;
import org.springframework.ldap.core.LdapEncoder;
import org.springframework.security.core.SpringSecurityMessageSource;
import org.springframework.security.ldap.search.LdapUserSearch;
import org.springframework.beans.factory.InitializingBean;
@ -91,7 +92,7 @@ public abstract class AbstractLdapAuthenticator implements LdapAuthenticator, In
}
List<String> userDns = new ArrayList<String>(userDnFormat.length);
String[] args = new String[] {username};
String[] args = new String[] {LdapEncoder.nameEncode(username)};
synchronized (userDnFormat) {
for (MessageFormat formatter : userDnFormat) {