Hi,
that should work this way :
LdapConnection adminConnection = getAdminNetworkConnection(
getLdapServer() );
// change the password
PasswordModifyRequest pwdModifyRequest = new
PasswordModifyRequestImpl();
pwdModifyRequest.setUserIdentity( Strings.getBytesUtf8( <your
DN> ) );
pwdModifyRequest.setNewPassword( Strings.getBytesUtf8( <yoru
password>) );
// Send the request
PasswordModifyResponse pwdModifyResponse = (
PasswordModifyResponse ) adminConnection.extended( pwdModifyRequest );
assertEquals( ResultCodeEnum.SUCCESS,
pwdModifyResponse.getLdapResult().getResultCode() );
On 29/11/2020 17:59, Travis Spencer wrote:
I am migrating some client code from Apache LDAP API 1.0.3 to 2.0.1.
The migration guide[1] has helped a lot. It was enough to migrate
almost all code except for a bit that did an extended password
modification. Specifically, I had this code:
/*01*/class MyGoodClass
/*02*/{
/*03*/ private final PasswordPolicyDecorator passwordPolicyDecorator;
/*04*/ private final LdapConnectionPool connectionPool;
/*05*/
/*06*/ public MyGoodClass(LdapConnectionPool connectionPool) {
/*07*/ this.connectionPool = connectionPool;
/*08*/ passwordPolicyDecorator = new
PasswordPolicyDecorator(connectionPool.getLdapApiService());
/*09*/ }
/*10*/
/*11*/ public ExtendedResponse modifyPasswordUsingExtension(Dn
userDn, String newPassword, String oldPassword)
/*12*/ throws LdapException
/*13*/ {
/*14*/ LdapConnection connection = connectionPool.getConnection();
/*15*/ PasswordModifyRequest setPasswordRequest =
(PasswordModifyRequest) connection.getCodecService()
/*16*/
.newExtendedRequest(PasswordModifyRequest.EXTENSION_OID, null);
/*17*/
/*18*/
setPasswordRequest.setUserIdentity(Asn1StringUtils.getBytesUtf8(userDn.toString()));
/*19*/
setPasswordRequest.setNewPassword(Asn1StringUtils.getBytesUtf8(newPassword));
/*20*/
/*21*/ if (oldPassword != null)
/*22*/ {
/*23*/ connection.bind(userDn, oldPassword);
/*24*/
/*25*/
setPasswordRequest.setOldPassword(Asn1StringUtils.getBytesUtf8(oldPassword));
/*26*/ }
/*27*/
/*28*/ setPasswordRequest.addControl(passwordPolicyDecorator);
/*29*/
/*30*/ return connection.extended(setPasswordRequest);
/*31*/ }
/*32*/}
What should this be in 2.0.1?
IINM, lines 15 and 16 should be migrated to this:
PasswordModifyFactory factory = new
PasswordModifyFactory(connection.getCodecService());
PasswordModifyRequest setPasswordRequest = factory.newRequest();
What about the field `passwordPolicyDecorator' on line 3 and its use
on line 28? That class seems to have been deleted in
b23123d84764f1289016df7c7184d208f5fff75c.
Should I use `PasswordPolicyResponseImpl' instead of
`PasswordPolicyDecorator' on line 8 simply?
TIA!
[1] https://directory.apache.org/api/migration-guide.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]