title: Redirecting to specific page depending upon Authentication and Authorization
body: <p>I am building an Application where I am authorizing the user based on his Role. Role is defined in Ldap. We have three roles finance, cloud and sales. Depending upon the role we want to redirect to the particular page on successful login. If login fails it should redirect to some error page.</p>
  
  <p>I have written the following in spring-security.xml. I am not able to redirecting to different pages . </p>
  
  <pre><code> &lt;beans:beans xmlns="http://www.springframework.org/schema/security"
      xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/security
      http://www.springframework.org/schema/security/spring-security-3.0.3.xsd"&gt;
  
      &lt;http auto-config="true"&gt;
          &lt;intercept-url pattern="/finance*" access="ROLE_FINANCE"  /&gt;
  
          &lt;logout logout-success-url="/logout" /&gt;
          &lt;intercept-url pattern="/cloud*" access="ROLE_CLOUD" /&gt;
  
  
          &lt;logout logout-success-url="/logout" /&gt;
          &lt;intercept-url pattern="/sales*" access="ROLE_SALES" /&gt;
  
          &lt;!-- &lt;form-login login-page="/login1" default-target-url="/login1"
              authentication-failure-url="/loginfailed" /&gt; --&gt;
          &lt;logout logout-success-url="/logout" /&gt;
          &lt;!-- &lt;form-login login-page="/login.vtu" authentication-success-handler-ref="customHandler"
              authentication-failure-url="/login.vtu?error=true" default-target-url="/login.vtu"
              login-processing-url="/j_security_check"  /&gt;  --&gt;
      &lt;/http&gt;
   &lt;authentication-manager&gt;
           &lt;ldap-authentication-provider 
             user-search-filter="(uid={0})"
             user-search-base="cn=worldAdmin"
             group-search-filter="(uniqueMember={0})"
             group-search-base="cn=worldAdmin"
             group-role-attribute="cn"
             role-prefix="ROLE_"&gt;
           &lt;/ldap-authentication-provider&gt;
   &lt;/authentication-manager&gt;
  
   &lt;ldap-server url="ldap://localhost:12389/o=xyz" manager-dn="cn=xyzAdmin,cn=worldAdmin,o=xyz" manager-password="abc" /&gt; 
  
  &lt;/beans:beans&gt;
  </code></pre>