// Modify password.
Attributes attributes = new BasicAttributes( true );
Attribute attr = new BasicAttribute( "userPassword", newUserPassword );
attributes.put( attr );
DirContext person = ( DirContext ) ctx.lookup( RDN );
person.modifyAttributes( "", DirContext.REPLACE_ATTRIBUTE, attributes );
// Read again from directory.
person = ( DirContext ) ctx.lookup( RDN );