Announcement Announcement Module
Collapse
No announcement yet.
Password refresh Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Password refresh

    Hi all!
    I use Spring+Acegi+Apache Directory DS 1.0 ( Ldap Server ).
    I customized the LdapAuthenticationProvider and it works in this way:
    if the account has expired, the user is authenticated with only one role ( ROLE_UPDATE ) and redirected to the update page.
    After user changed his password, he is redirected to the login page.
    Here we got the problem: user cannot log with the new password.

    If I restart the APPLICATION SERVER, nothing happens.

    If I restart the LDAP SERVER, the password is now updated.

    The system uses a controller to update the password:

    Code:
    ...
    
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    Account retrievedAccount = userManager.getUserDetailsByUid(auth.getName());
    
    retrievedAccount.setPassword("new pwd here");
    retrievedAccount.setExpireDate("new date here");
    
    userManager.updateUser(retrievedAccount);
    
    ldapAuthProvider.getUserCache().removeUserFromCache(auth.getName());
    
    ModelAndView _t = new ModelAndView("acegilogin");
    
    ...
    What do you think I am missing?

    Best regards

  • #2
    It sounds like the problem is with the LDAP server. It doesn't recognise the new passwork until it's restarted.

    Comment


    • #3
      I think so too.
      Maybe I do a mistake in the code .. I am looking into this:

      Code:
      ..
      <bean id="ldapTemplate"
      		class="org.springframework.ldap.LdapTemplate">
      		<constructor-arg ref="contextSource" />
      </bean>
      ..
      and again:
      Code:
      BasicAttribute userPasswordAttribute = new BasicAttribute("userpassword");
      userPasswordAttribute.add("new password here");
      ModificationItem replacedPassword = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, userPasswordAttribute);
      ModificationItem[] modificationItemArray = new ModificationItem[1];
      try { ldapTemplate.modifyAttributes(distinguishedName.toString(),modificationItemArray);
      		} catch (DataAccessException e) {
      			return false;
      		}
      Do the "ldapTemplate.modifyAttributes( .. )" ensure the connection closing?

      Comment


      • #4
        Why not write a junit test case which does this and step through it in a debugger?

        Whether the connection is closed or not isn't relevant to whether the password is updated, but that's what the template is for. You should probably use the Spring Ldap forum if you have questions about using templates.

        Comment


        • #5
          Although I've not done much with LdapTemplate, that looks fine to me. I'd follow Luke's suggestions.

          Comment

          Working...
          X