Pass username as second parameter for search filter.

Allows the username only (without domain) to be used in custom search filter like "sAMAccountName={1}",
in eg. situations where the userPrincipalName has a different suffix than domain.

Thanks to contributors in issue.

fixes gh-2448
This commit is contained in:
Trygve Aasjord
2017-07-18 22:11:04 +02:00
committed by Rob Winch
parent cdcf65de1e
commit 8d717c62af
2 changed files with 6 additions and 5 deletions

View File

@@ -140,9 +140,9 @@ public class ActiveDirectoryLdapAuthenticationProviderTests {
any(Object[].class), any(SearchControls.class));
}
// SEC-2897
// SEC-2897,SEC-2224
@Test
public void bindPrincipalUsed() throws Exception {
public void bindPrincipalAndUsernameUsed() throws Exception {
// given
final String defaultSearchFilter = "(&(objectClass=user)(userPrincipalName={0}))";
ArgumentCaptor<Object[]> captor = ArgumentCaptor.forClass(Object[].class);
@@ -166,7 +166,7 @@ public class ActiveDirectoryLdapAuthenticationProviderTests {
Authentication result = customProvider.authenticate(joe);
// then
assertThat(captor.getValue()).containsOnly("joe@mydomain.eu");
assertThat(captor.getValue()).containsExactly("joe@mydomain.eu", "joe");
assertThat(result.isAuthenticated()).isTrue();
}