Search in sources :

Example 1 with CompareResult

use of com.unboundid.ldap.sdk.CompareResult in project zm-mailbox by Zimbra.

the class UBIDLdapContext method compare.

/**
 * Perform an LDAPv3 compare operation, which may be used to determine whether a specified entry contains a given
 * attribute value.  Compare requests include the DN of the target entry, the name of the target attribute,
 * and the value for which to make the determination.
 *
 * @param  dn The DN of the entry in which the comparison is to be performed.  It must not be {@code null}.
 * @param  attributeName   The name of the target attribute for which the comparison is to be performed.
 *         It must not be {@code null}.
 * @param  assertionValue  The assertion value to verify within the entry.  It must not be {@code null}.
 */
@Override
public boolean compare(final String dn, final String attributeName, final String assertionValue) throws ServiceException {
    CompareRequest compareRequest = new CompareRequest(dn, attributeName, assertionValue);
    CompareResult compareResult;
    try {
        compareResult = UBIDLdapOperation.COMPARE.execute(this, compareRequest);
        // determine whether the compare matched.
        return compareResult.compareMatched();
    } catch (LDAPException le) {
        ZimbraLog.ldap.debug("Compare failed result code='%s' error message='%s'", le.getResultCode(), le.getDiagnosticMessage(), le);
    }
    return false;
}
Also used : CompareRequest(com.unboundid.ldap.sdk.CompareRequest) LDAPException(com.unboundid.ldap.sdk.LDAPException) CompareResult(com.unboundid.ldap.sdk.CompareResult)

Aggregations

CompareRequest (com.unboundid.ldap.sdk.CompareRequest)1 CompareResult (com.unboundid.ldap.sdk.CompareResult)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1