Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Security Ldap remember me not working
    text
    copied!<p>I have an application which uses spring security 3.0. The application uses my company's Active directory for login. I borrowed some of the code from the examples on the net and now I am able to successfully perform a bind. But the remember-me functionality is not working. To be more specific, I am able to sign into the application but when I close the browser and open the application it is redirecting to the login page again. Can anyone please tell me what is wrong in my configuration. </p> <p>Security.xml</p> <pre><code>&lt;http path-type="regex" use-expressions="true" auto-config="true"&gt; &lt;form-login login-page="/Login.html" login-processing-url="/j_spring_security_check" default-target-url="/home.html" authentication-failure-url = "/Login.html?login_error=1" /&gt; &lt;logout logout-success-url="/Login.html" invalidate-session="true" delete-cookies="JSESSIONID" /&gt; &lt;intercept-url pattern="\A/Login\Z" access="IS_AUTHENTICATED_ANONYMOUSLY"/&gt; &lt;intercept-url pattern="\A/(?!Login).*\Z" access="isAuthenticated()" /&gt; &lt;remember-me key="_spring_security_remember_me" token-validity-seconds="3600" user-service-ref="ldapUserDetailsService"/&gt; &lt;/http&gt; &lt;authentication-manager alias="authenticationManager"&gt; &lt;authentication-provider ref="ldapAuthProvider"/&gt; &lt;/authentication-manager&gt; &lt;beans:bean class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider" id="ldapAuthProvider"&gt; &lt;beans:constructor-arg ref="ldapBindAuthenticator"/&gt; &lt;beans:property name="userDetailsContextMapper" ref="ldapUserDetailsContextMapper"/&gt; &lt;/beans:bean&gt; &lt;beans:bean class="org.springframework.security.ldap.DefaultSpringSecurityContextSource" id="ldapServer"&gt; &lt;!-- MS Active Directory --&gt; &lt;beans:constructor-arg value="ldap://hostname/DC=myCompany,DC=com"/&gt; &lt;beans:property name="userDn" value="CN=user,OU=Users,DC=mycompany,DC=com"/&gt; &lt;beans:property name="password" value="xxxxxx"/&gt; &lt;/beans:bean&gt; &lt;beans:bean class="org.springframework.security.ldap.authentication.BindAuthenticator" id="ldapBindAuthenticator"&gt; &lt;beans:constructor-arg ref="ldapServer"/&gt; &lt;beans:property name="userSearch" ref="ldapSearchBean"/&gt; &lt;/beans:bean&gt; &lt;beans:bean class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch" id="ldapSearchBean"&gt; &lt;beans:constructor-arg value="OU=Users"/&gt; &lt;beans:constructor-arg value="(sAMAccountName={0})"/&gt; &lt;beans:constructor-arg ref="ldapServer"/&gt; &lt;/beans:bean&gt; &lt;beans:bean class="org.springframework.security.ldap.userdetails.InetOrgPersonContextMapper" id="ldapUserDetailsContextMapper"/&gt; &lt;beans:bean id="ldapUserDetailsService" class="org.springframework.security.ldap.userdetails.LdapUserDetailsService"&gt; &lt;beans:constructor-arg index="0"&gt; &lt;beans:ref local="ldapSearchBean" /&gt; &lt;/beans:constructor-arg&gt; &lt;/beans:bean&gt; &lt;!-- Bean used for LDAP querying. --&gt; &lt;beans:bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate"&gt; &lt;beans:constructor-arg ref="ldapServer" /&gt; &lt;/beans:bean&gt; &lt;beans:bean class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler" id="expressionHandler"/&gt; </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload