[
https://issues.apache.org/jira/browse/DIRSERVER-2131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15189478#comment-15189478
]
Peter Jamieson edited comment on DIRSERVER-2131 at 3/11/16 10:25 AM:
---------------------------------------------------------------------
I wrote a unit test for this for my embedded application: -
{code}
@Test
public void testDIRSERVER2131() throws IOException, LdapException
{
try(LdapNetworkConnection conn = new LdapNetworkConnection("localhost",
11389))
{
BindResponse bindResponse = conn.bind(bindRequest);
assertEquals(ResultCodeEnum.SUCCESS,
bindResponse.getLdapResult().getResultCode());
assertEquals(PasswordPolicyErrorEnum.CHANGE_AFTER_RESET,
((PasswordPolicy)
bindResponse.getControl(PasswordPolicy.OID)).getResponse().getPasswordPolicyError());
PasswordModifyRequest passModRequest = new
PasswordModifyRequestImpl();
passModRequest.setUserIdentity(Dn.getBytes(dnUser1));
passModRequest.setOldPassword(DEFAULT_PASSWORD.getBytes());
passModRequest.setNewPassword("five5five%".getBytes());
ExtendedResponse passModResponse = conn.extended(passModRequest);
assertTrue(passModResponse instanceof PasswordModifyResponse);
assertEquals(ResultCodeEnum.SUCCESS, ((PasswordModifyResponse)
passModResponse).getLdapResult().getResultCode());
}
}
{code}
The response from the final object is actually "NO_SUCH_OBJECT".
was (Author: peterjam28):
I wrote a unit test for this for my embedded application: -
{code}
@Test
public void testDIRSERVER2131() throws Exception
{
Dn dnUser1 = new Dn("uid=x135_Y246,ou=users,dc=intervoice,dc=int");
LdapRequestHandler<ExtendedRequest> handler =
ldapServer.getExtendedRequestHandler();
assertNotNull(handler);
DummySession ioSession = new DummySession();
ioSession.setHandler(new IoHandler()
{
@Override
public void exceptionCaught(IoSession arg0, Throwable arg1) throws
Exception
{
arg1.printStackTrace();
}
@Override
public void messageReceived(IoSession arg0, Object arg1) throws
Exception
{
System.out.println("messageReceived - " + arg1);
}
@Override
public void messageSent(IoSession arg0, Object arg1) throws
Exception
{
System.out.println("messageSent - " + arg1);
if (arg1 instanceof Response)
{
setLastResponse((Response) arg1);
}
}
@Override
public void sessionClosed(IoSession arg0) throws Exception
{
System.out.println("sessionClosed");
}
@Override
public void sessionCreated(IoSession arg0) throws Exception
{
System.out.println("sessionCreated");
}
@Override
public void sessionIdle(IoSession arg0, IdleStatus arg1) throws
Exception
{
System.out.println("sessionIdle");
}
@Override
public void sessionOpened(IoSession arg0) throws Exception
{
System.out.println("sessionOpened");
}
});
ldapServer.getLdapSessionManager().addLdapSession(new
LdapSession(ioSession));
LdapRequestHandler<BindRequest> bindHandler =
ldapServer.getBindRequestHandler();
BindRequest bind = new BindRequestImpl();
bind.setDn(dnUser1);
bind.setCredentials(DEFAULT_PASSWORD);
bind.addControl(new PasswordPolicyImpl());
bindHandler.handleMessage(ioSession, bind);
assertTrue(ldapServer.getLdapSessionManager().getLdapSession(ioSession).isAuthenticated());
assertTrue(lastResponse instanceof BindResponse);
assertEquals(ResultCodeEnum.SUCCESS, ((BindResponse)
lastResponse).getLdapResult().getResultCode());
assertEquals(PasswordPolicyErrorEnum.CHANGE_AFTER_RESET,
((PasswordPolicy)
lastResponse.getControl(PasswordPolicy.OID)).getResponse().getPasswordPolicyError());
PasswordModifyRequest message = new PasswordModifyRequestImpl();
message.setUserIdentity("uid=x135_Y246,ou=users,dc=intervoice,dc=int".getBytes());
message.setOldPassword(DEFAULT_PASSWORD.getBytes());
message.setNewPassword("five5five%".getBytes());
handler.handleMessage(ioSession, message);
assertTrue(lastResponse instanceof PasswordModifyResponse);
assertEquals(ResultCodeEnum.SUCCESS, ((PasswordModifyResponse)
lastResponse).getLdapResult().getResultCode());
}
{code}
The response from the final object is actually "NO_SUCH_OBJECT".
> cannot log in with ads-pwdmustchange true
> -----------------------------------------
>
> Key: DIRSERVER-2131
> URL: https://issues.apache.org/jira/browse/DIRSERVER-2131
> Project: Directory ApacheDS
> Issue Type: Bug
> Components: core
> Affects Versions: 2.0.0-M21
> Environment: centos 7.
> Reporter: Peter Jamieson
>
> If i modify the authentication policy to set ads-pwdmustchange to TRUE, when
> i log in, i get: -
> {noformat}
> provisioning:root *#ssh [email protected]
> Authorized users only. All activity may be monitored and reported.
> [email protected]'s password:
> Password expired. Change your password now.
> Last login: Mon Mar 7 15:46:02 2016 from provisioning
> Authorized users only. All activity may be monitored and reported.
> WARNING: Your password has expired.
> You must change your password now and login again!
> Changing password for user user2.
> Current Password:
> New password:
> Retype new password:
> Password change failed. Server message: Cannot find an entry for DN
> uid=user2,ou=users,dc=example,dc=com
> passwd: Authentication token manipulation error
> Connection to 192.168.56.164 closed.
> {noformat}
> and this appears in the apacheds.log: -
> [15:46:33] ERROR
> [org.apache.directory.server.ldap.handlers.extended.PwdModifyHandler] -
> Cannot find an entry for DN uid=user2,ou=users,dc=example,dc=com, exception :
> password needs to be reset before performing this operation
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)