2 * Copyright (c) 1995 Regents of the University of Michigan.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of Michigan at Ann Arbor. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
17 #include <ac/socket.h>
30 int rc = LDAP_SUCCESS;
32 Debug( LDAP_DEBUG_TRACE, "do_compare\n", 0, 0, 0 );
34 if( op->o_bind_in_progress ) {
35 Debug( LDAP_DEBUG_ANY, "do_compare: SASL bind in progress.\n",
37 send_ldap_result( conn, op, LDAP_SASL_BIND_IN_PROGRESS, NULL,
38 "SASL bind in progress" );
39 return LDAP_SASL_BIND_IN_PROGRESS;
43 * Parse the compare request. It looks like this:
45 * CompareRequest := [APPLICATION 14] SEQUENCE {
46 * entry DistinguishedName,
49 * value AttributeValue
54 if ( ber_scanf( op->o_ber, "{a{ao}}", &ndn, &ava.ava_type,
55 &ava.ava_value ) == LBER_ERROR ) {
56 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
57 send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL, "" );
61 if( ( rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
64 Debug( LDAP_DEBUG_ANY, "do_compare: get_ctrls failed\n", 0, 0, 0 );
68 value_normalize( ava.ava_value.bv_val, attr_syntax( ava.ava_type ) );
70 Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
71 ndn, ava.ava_type, ava.ava_value.bv_val );
73 ndn = dn_normalize_case( ndn );
75 Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d CMP dn=\"%s\" attr=\"%s\"\n",
76 conn->c_connid, op->o_opid, ndn, ava.ava_type, 0 );
79 * We could be serving multiple database backends. Select the
80 * appropriate one, or send a referral to our "referral server"
81 * if we don't hold it.
83 if ( (be = select_backend( ndn )) == NULL ) {
87 send_ldap_result( conn, op, rc = LDAP_PARTIAL_RESULTS, NULL,
92 /* alias suffix if approp */
93 ndn = suffixAlias( ndn, op, be );
95 if ( be->be_compare ) {
96 (*be->be_compare)( be, conn, op, ndn, &ava );
98 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM, NULL,
99 "Function not implemented" );