How do you authenticate against an Active Directory server using Spring Security?

I had the same banging-my-head-against-the-wall experience you did, and ended up writing a custom authentication provider that does an LDAP query against the Active Directory server. So my security-related beans are: <beans:bean id=”contextSource” class=”org.springframework.security.ldap.DefaultSpringSecurityContextSource”> <beans:constructor-arg value=”ldap://hostname.queso.com:389/” /> </beans:bean> <beans:bean id=”ldapAuthenticationProvider” class=”org.queso.ad.service.authentication.LdapAuthenticationProvider”> <beans:property name=”authenticator” ref=”ldapAuthenticator” /> <custom-authentication-provider /> </beans:bean> <beans:bean id=”ldapAuthenticator” class=”org.queso.ad.service.authentication.LdapAuthenticatorImpl”> <beans:property name=”contextFactory” ref=”contextSource” /> … Read more

Using PrincipalSearcher to find users with “or” parameters

It’s obviously not possible, here is a workaround: List<UserPrincipal> searchPrinciples = new List<UserPrincipal>(); searchPrinciples.Add(new UserPrincipal(context) { DisplayName=”tom*”}); searchPrinciples.Add(new UserPrincipal(context) { SamAccountName = “tom*” }); searchPrinciples.Add(new UserPrincipal(context) { MiddleName = “tom*” }); searchPrinciples.Add(new UserPrincipal(context) { GivenName = “tom*” }); List<Principal> results = new List<Principal>(); var searcher = new PrincipalSearcher(); foreach (var item in searchPrinciples) { searcher … Read more

HttpServletRequest.getRemoteUser() vs HttpServletRequest.getUserPrincipal().getName()

A Principal represents someone who could potentially authenticate with your application. The Principal’s name depends on the authentication method used: a username such as “fred” (in the case of HTTP Basic authentication) a Distinguished Name such as “CN=bob,O=myorg” (in the case of X.509 client certificates – in which case a X500Principal may be returned) getRemoteUser() … Read more

Checklist for IIS 6/ASP.NET Windows Authentication?

It sounds like you’ve covered all the server-side bases–maybe it’s a client issue? I assume your users have integrated authentication enabled in IE7? (Tools -> Internet Options -> Advanced -> Security). This is enabled by default. Also, is your site correctly recognized by IE7 as being in the Local Intranet zone? The IE7 default is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)