Entry userEntry = adminConnection.lookup( "cn=User7,ou=system", "*", "+" );
Attribute attribute = userEntry.get( "pwdHistory" );
assertEquals( 1, attribute.size() );
PwdModifyRequestImpl pwdModifyRequest = null;
PwdModifyResponse pwdModifyResponse = null;
// Fail modify user with user account
try {
userConnection = getNetworkConnectionAs( getLdapServer(), "cn=User7,ou=system", "secret7" );
pwdModifyRequest = new PwdModifyRequestImpl();
pwdModifyRequest.setUserIdentity( Strings.getBytesUtf8( "cn=User7,ou=system" ) );
pwdModifyRequest.setNewPassword( Strings.getBytesUtf8( "secret4Bis" ) );
pwdModifyResponse = (PwdModifyResponse)userConnection.extended( pwdModifyRequest );
assertNotEquals( ResultCodeEnum.SUCCESS, pwdModifyResponse.getLdapResult().getResultCode() );
}
finally {
safeCloseConnections( userConnection );
}
// Modify the user with the admin account
pwdModifyRequest = new PwdModifyRequestImpl();
pwdModifyRequest.setUserIdentity( Strings.getBytesUtf8( "cn=User7,ou=system" ) );
pwdModifyRequest.setNewPassword( Strings.getBytesUtf8( "secret4Bis" ) );
pwdModifyResponse = (PwdModifyResponse)adminConnection.extended( pwdModifyRequest );
assertEquals( ResultCodeEnum.SUCCESS, pwdModifyResponse.getLdapResult().getResultCode() );
userEntry = adminConnection.lookup( "cn=User7,ou=system", "*", "+" );
attribute = userEntry.get( "pwdHistory" );
assertEquals( 2, attribute.size() );
// Now try to bind with the new password