I've been playing around for several weeks trying to get Spring Security 3.0.x authenticating against our corporate Active Directory server. The closest I've gotten were either errors around needing to do an authenticated bind before an actual user authentication and bad credentials. I took this to mean we needed to create a service account to bind to AD as and then perform an AD authorization. I will try this once I get that service account.
I then saw that 3.1 has native support for AD authentication so I've tried that but it's now failing because no results are being returned - I was following these instructions: http://static.springsource.org/sprin...tive-directory.
Looking at the debugging information, I'm not sure it's using the correct information and I am unsure as to how to provide it given our setup. Our employee user names are just an ID string, not our names. Our base DN is dc=corp,dc=foo,dc=com. Using an AD browser, our sAMAccountName is <username>@corp.foo.com whereas the value of userPrincipalName is <username>@foo.com.
Here is the code I am trying to execute that returns zero results:
The debug output is:Code:ActiveDirectoryLdapAuthenticationProvider adlap = new ActiveDirectoryLdapAuthenticationProvider("corp.foo.com", "ldap://xx.xx.xx.xx:389"); adlap.setConvertSubErrorCodesToExceptions(true); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("<username>@corp.foo.com", "<username's password>"); adlap.authenticate(auth);
My division's users are nested down a few layers from the initial tree node of "dc=corp,dc=foo,dc=com" but I don't see a way to specify additional nodes - or know if I even need to.Code:DEBUG ActiveDirectoryLdapAuthenticationProvider - Processing authentication request for user: <username@corp.foo.com DEBUG SpringSecurityLdapTemplate - Searching for entry under DN '', base = 'dc=corp,dc=foo,dc=com', filter = '(&(objectClass=user)(userPrincipalName={0}))' INFO SpringSecurityLdapTemplate - Ignoring PartialResultException org.springframework.dao.IncorrectResultSizeDataAccessException: Incorrect result size: expected 1, actual 0 at org.springframework.security.ldap.SpringSecurityLdapTemplate.searchForSingleEntryInternal(SpringSecurityLdapTemplate.java:239) ...
Any help would be most welcome. Thanks.


Reply With Quote
