@NotMutable @ThreadSafety(level=NOT_THREADSAFE) public final class PasswordModifyExtendedRequest extends ExtendedRequest
userIdentity
-- This specifies the user for which to change the
password. It should generally be the DN for the target user (although
the specification does indicate that some servers may accept other
values). If no value is provided, then the server will attempt to
change the password for the currently-authenticated user.oldPassword
-- This specifies the current password for the
user. Some servers may require that the old password be provided when
a user is changing his or her own password as an extra level of
verification, but it is generally not necessary when an administrator
is resetting the password for another user.newPassword
-- This specifies the new password to use for the
user. If it is not provided, then the server may attempt to generate a
new password for the user, and in that case it will be included in the
generatedPassword
field of the corresponding
PasswordModifyExtendedResult
. Note that some servers may not
support generating a new password, in which case the client will always
be required to provide it.PasswordModifyExtendedRequest passwordModifyRequest = new PasswordModifyExtendedRequest( "uid=test.user,ou=People,dc=example,dc=com", // The user to update (String) null, // The current password for the user. (String) null); // The new password. null = server will generate PasswordModifyExtendedResult passwordModifyResult; try { passwordModifyResult = (PasswordModifyExtendedResult) connection.processExtendedOperation(passwordModifyRequest); // This doesn't necessarily mean that the operation was successful, since // some kinds of extended operations return non-success results under // normal conditions. } catch (LDAPException le) { // For an extended operation, this generally means that a problem was // encountered while trying to send the request or read the result. passwordModifyResult = new PasswordModifyExtendedResult( new ExtendedResult(le)); } LDAPTestUtils.assertResultCodeEquals(passwordModifyResult, ResultCode.SUCCESS); String serverGeneratedNewPassword = passwordModifyResult.getGeneratedPassword();
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PASSWORD_MODIFY_REQUEST_OID
The OID (1.3.6.1.4.1.4203.1.11.1) for the password modify extended request.
|
TYPE_EXTENDED_REQUEST_OID, TYPE_EXTENDED_REQUEST_VALUE
Constructor and Description |
---|
PasswordModifyExtendedRequest(byte[] newPassword)
Creates a new password modify extended request that will attempt to change
the password of the currently-authenticated user.
|
PasswordModifyExtendedRequest(byte[] oldPassword,
byte[] newPassword)
Creates a new password modify extended request that will attempt to change
the password of the currently-authenticated user.
|
PasswordModifyExtendedRequest(ExtendedRequest extendedRequest)
Creates a new password modify extended request from the provided generic
extended request.
|
PasswordModifyExtendedRequest(java.lang.String newPassword)
Creates a new password modify extended request that will attempt to change
the password of the currently-authenticated user.
|
PasswordModifyExtendedRequest(java.lang.String userIdentity,
byte[] oldPassword,
byte[] newPassword)
Creates a new password modify extended request that will attempt to change
the password for the specified user.
|
PasswordModifyExtendedRequest(java.lang.String userIdentity,
byte[] oldPassword,
byte[] newPassword,
Control[] controls)
Creates a new password modify extended request that will attempt to change
the password for the specified user.
|
PasswordModifyExtendedRequest(java.lang.String oldPassword,
java.lang.String newPassword)
Creates a new password modify extended request that will attempt to change
the password of the currently-authenticated user.
|
PasswordModifyExtendedRequest(java.lang.String userIdentity,
java.lang.String oldPassword,
java.lang.String newPassword)
Creates a new password modify extended request that will attempt to change
the password for the specified user.
|
PasswordModifyExtendedRequest(java.lang.String userIdentity,
java.lang.String oldPassword,
java.lang.String newPassword,
Control[] controls)
Creates a new password modify extended request that will attempt to change
the password for the specified user.
|
Modifier and Type | Method and Description |
---|---|
PasswordModifyExtendedRequest |
duplicate()
Creates a new instance of this LDAP request that may be modified without
impacting this request.
|
PasswordModifyExtendedRequest |
duplicate(Control[] controls)
Creates a new instance of this LDAP request that may be modified without
impacting this request.
|
java.lang.String |
getExtendedRequestName()
Retrieves the user-friendly name for the extended request, if available.
|
java.lang.String |
getNewPassword()
Retrieves the string representation of the new password for this request,
if available.
|
byte[] |
getNewPasswordBytes()
Retrieves the binary representation of the new password for this request,
if available.
|
java.lang.String |
getOldPassword()
Retrieves the string representation of the old password for this request,
if available.
|
byte[] |
getOldPasswordBytes()
Retrieves the binary representation of the old password for this request,
if available.
|
ASN1OctetString |
getRawNewPassword()
Retrieves the raw new password for this request, if available.
|
ASN1OctetString |
getRawOldPassword()
Retrieves the raw old password for this request, if available.
|
java.lang.String |
getUserIdentity()
Retrieves the user identity for this request, if available.
|
PasswordModifyExtendedResult |
process(LDAPConnection connection,
int depth)
Sends this extended request to the directory server over the provided
connection and returns the associated response.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this request to the provided buffer.
|
encodeProtocolOp, getLastMessageID, getOID, getOperationType, getProtocolOpType, getValue, hasValue, responseReceived, toCode, writeTo
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getReferralConnector, getReferralConnectorInternal, getReferralDepth, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setReferralConnector, setReferralDepth, setResponseTimeoutMillis, toString
@NotNull public static final java.lang.String PASSWORD_MODIFY_REQUEST_OID
public PasswordModifyExtendedRequest(@Nullable java.lang.String newPassword)
newPassword
- The new password for the user. It may be null
if the new password should be generated by the
directory server.public PasswordModifyExtendedRequest(@Nullable byte[] newPassword)
newPassword
- The new password for the user. It may be null
if the new password should be generated by the
directory server.public PasswordModifyExtendedRequest(@Nullable java.lang.String oldPassword, @Nullable java.lang.String newPassword)
oldPassword
- The current password for the user. It may be
null
if the directory server does not require
the user's current password for self changes.newPassword
- The new password for the user. It may be null
if the new password should be generated by the
directory server.public PasswordModifyExtendedRequest(@Nullable byte[] oldPassword, @Nullable byte[] newPassword)
oldPassword
- The current password for the user. It may be
null
if the directory server does not require
the user's current password for self changes.newPassword
- The new password for the user. It may be null
if the new password should be generated by the
directory server.public PasswordModifyExtendedRequest(@Nullable java.lang.String userIdentity, @Nullable java.lang.String oldPassword, @Nullable java.lang.String newPassword)
userIdentity
- The string that identifies the user whose password
should be changed. It may or may not be a DN, but if
it is not a DN, then the directory server must be
able to identify the appropriate user from the
provided identifier. It may be null
to
indicate that the password change should be for the
currently-authenticated user.oldPassword
- The current password for the user. It may be
null
if the directory server does not require
the user's current password for self changes.newPassword
- The new password for the user. It may be
null
if the new password should be generated
by the directory server.public PasswordModifyExtendedRequest(@Nullable java.lang.String userIdentity, @Nullable byte[] oldPassword, @Nullable byte[] newPassword)
userIdentity
- The string that identifies the user whose password
should be changed. It may or may not be a DN, but if
it is not a DN, then the directory server must be
able to identify the appropriate user from the
provided identifier. It may be null
to
indicate that the password change should be for the
currently-authenticated user.oldPassword
- The current password for the user. It may be
null
if the directory server does not require
the user's current password for self changes.newPassword
- The new password for the user. It may be
null
if the new password should be generated
by the directory server.public PasswordModifyExtendedRequest(@Nullable java.lang.String userIdentity, @Nullable java.lang.String oldPassword, @Nullable java.lang.String newPassword, @Nullable Control[] controls)
userIdentity
- The string that identifies the user whose password
should be changed. It may or may not be a DN, but if
it is not a DN, then the directory server must be
able to identify the appropriate user from the
provided identifier. It may be null
to
indicate that the password change should be for the
currently-authenticated user.oldPassword
- The current password for the user. It may be
null
if the directory server does not require
the user's current password for self changes.newPassword
- The new password for the user. It may be
null
if the new password should be generated
by the directory server.controls
- The set of controls to include in the request.public PasswordModifyExtendedRequest(@Nullable java.lang.String userIdentity, @Nullable byte[] oldPassword, @Nullable byte[] newPassword, @Nullable Control[] controls)
userIdentity
- The string that identifies the user whose password
should be changed. It may or may not be a DN, but if
it is not a DN, then the directory server must be
able to identify the appropriate user from the
provided identifier. It may be null
to
indicate that the password change should be for the
currently-authenticated user.oldPassword
- The current password for the user. It may be
null
if the directory server does not require
the user's current password for self changes.newPassword
- The new password for the user. It may be
null
if the new password should be generated
by the directory server.controls
- The set of controls to include in the request.public PasswordModifyExtendedRequest(@NotNull ExtendedRequest extendedRequest) throws LDAPException
extendedRequest
- The generic extended request to use to create this
password modify extended request.LDAPException
- If a problem occurs while decoding the request.@Nullable public java.lang.String getUserIdentity()
null
if the
password change should target the currently-authenticated user.@Nullable public java.lang.String getOldPassword()
null
if it was not provided.@Nullable public byte[] getOldPasswordBytes()
null
if it was not provided.@Nullable public ASN1OctetString getRawOldPassword()
null
if it was
not provided.@Nullable public java.lang.String getNewPassword()
null
if it was not provided.@Nullable public byte[] getNewPasswordBytes()
null
if it was not provided.@Nullable public ASN1OctetString getRawNewPassword()
null
if it was
not provided.@NotNull public PasswordModifyExtendedResult process(@NotNull LDAPConnection connection, int depth) throws LDAPException
process
in class ExtendedRequest
connection
- The connection to use to communicate with the directory
server.depth
- The current referral depth for this request. It should
always be one for the initial request, and should only
be incremented when following referrals.LDAPException
- If a problem occurs while sending the request or
reading the response.@NotNull public PasswordModifyExtendedRequest duplicate()
duplicate
in interface ReadOnlyLDAPRequest
duplicate
in class ExtendedRequest
@NotNull public PasswordModifyExtendedRequest duplicate(@Nullable Control[] controls)
duplicate
in interface ReadOnlyLDAPRequest
duplicate
in class ExtendedRequest
controls
- The set of controls to include in the duplicate request.@NotNull public java.lang.String getExtendedRequestName()
getExtendedRequestName
in class ExtendedRequest
public void toString(@NotNull java.lang.StringBuilder buffer)
toString
in interface ProtocolOp
toString
in interface ReadOnlyLDAPRequest
toString
in class ExtendedRequest
buffer
- The buffer to which to append a string representation of
this request.