@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class VerifyPasswordExtendedRequest extends ExtendedRequest
NOTE: This class, and other classes within the
com.unboundid.ldap.sdk.unboundidds
package structure, are only
supported for use against Ping Identity, UnboundID, and
Nokia/Alcatel-Lucent 8661 server products. These classes provide support
for proprietary functionality or for external specifications that are not
considered stable or mature enough to be guaranteed to work in an
interoperable way with other types of LDAP servers.
dn
-- The DN of the user for whom to make the determination.
This field is required to be present.
password
-- The password to verify for the user. This field is
required to be present.
permit-verify-password-request
privilege. And by
default, the server will only permit clients to issue verify password
requests over a secure connection.
ResultCode.COMPARE_TRUE
-- All processing completed successfully,
and the provided password was correct for the target user.
ResultCode.COMPARE_FALSE
-- All processing completed
successfully, but the provided password was not correct for the target
user.
ResultCode.NO_SUCH_OBJECT
-- If the entry for the target user
does not exist.
ResultCode.INVALID_DN_SYNTAX
-- If the target user DN cannot be
parsed as a valid DN.
ResultCode.INAPPROPRIATE_AUTHENTICATION
-- If the target user
does not have a password.
ResultCode.INSUFFICIENT_ACCESS_RIGHTS
-- If the requester does
not have the necessary access control permission to issue the request,
or if they do not have the permit-verify-password-request
privilege.
ResultCode.CONFIDENTIALITY_REQUIRED
-- If the client is using an
insecure connection, but the server requires secure communication for the
request.
ResultCode.OTHER
-- If an internal error occurred while
attempting to process the request.
public static boolean isPasswordValidForUser( final LDAPConnection connection, final String targetUserDN, final String passwordToVerify) throws LDAPException { final VerifyPasswordExtendedRequest verifyPasswordRequest = new VerifyPasswordExtendedRequest(targetUserDN, passwordToVerify); LDAPResult verifyPasswordResult; try { verifyPasswordResult = connection.processExtendedOperation(verifyPasswordRequest); } catch (final LDAPException e) { verifyPasswordResult = e.toLDAPResult(); } final ResultCode resultCode = verifyPasswordResult.getResultCode(); if (resultCode == ResultCode.COMPARE_TRUE) { // The provided password is correct for the target user. return true; } else if (resultCode == ResultCode.COMPARE_FALSE) { // The provided password is not correct for the target user. return false; } else { // An error occurred while trying to verify the password. throw new LDAPException(verifyPasswordResult); } }
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
REQUEST_FIELD_DN
The name of the JSON field used to specify the DN of the user for whom
to make the determination.
|
static java.lang.String |
REQUEST_FIELD_PASSWORD
The name of the JSON field used to specify the password for which to make
the determination.
|
static java.lang.String |
VERIFY_PASSWORD_REQUEST_OID
The OID (1.3.6.1.4.1.30221.2.6.72) for the verify password extended
request.
|
TYPE_EXTENDED_REQUEST_OID, TYPE_EXTENDED_REQUEST_VALUE
Constructor and Description |
---|
VerifyPasswordExtendedRequest(ExtendedRequest extendedRequest)
Attempts to decode the provided generic extended request as a verify
password extended request.
|
VerifyPasswordExtendedRequest(java.lang.String dn,
java.lang.String password,
Control... controls)
Creates a new verify password extended request with the provided
information.
|
Modifier and Type | Method and Description |
---|---|
VerifyPasswordExtendedRequest |
duplicate()
Creates a new instance of this LDAP request that may be modified without
impacting this request.
|
VerifyPasswordExtendedRequest |
duplicate(Control[] controls)
Creates a new instance of this LDAP request that may be modified without
impacting this request.
|
java.lang.String |
getDN()
Retrieves the DN of the user for whom to verify the password.
|
java.lang.String |
getExtendedRequestName()
Retrieves the user-friendly name for the extended request, if available.
|
java.lang.String |
getPassword()
Retrieves the password to attempt to verify for the user.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this request to the provided buffer.
|
encodeProtocolOp, getLastMessageID, getOID, getOperationType, getProtocolOpType, getValue, hasValue, process, 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 VERIFY_PASSWORD_REQUEST_OID
@NotNull public static final java.lang.String REQUEST_FIELD_DN
@NotNull public static final java.lang.String REQUEST_FIELD_PASSWORD
public VerifyPasswordExtendedRequest(@NotNull java.lang.String dn, @NotNull java.lang.String password, @Nullable Control... controls)
dn
- The DN of the user for whom to make the determination.
It must not be null
or empty.password
- The password for which to make the determination. It
must not be null
or empty.controls
- An optional set of controls to include in the extended
request. It may be null
or empty if no controls
are needed.public VerifyPasswordExtendedRequest(@NotNull ExtendedRequest extendedRequest) throws LDAPException
extendedRequest
- The generic extended request to decode as a verify
password request. It must not be null
.LDAPException
- If the provided request cannot be decoded as a
verify password request.@NotNull public java.lang.String getDN()
@NotNull public java.lang.String getPassword()
@NotNull public VerifyPasswordExtendedRequest duplicate()
duplicate
in interface ReadOnlyLDAPRequest
duplicate
in class ExtendedRequest
@NotNull public VerifyPasswordExtendedRequest 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.