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>
32 Debug( LDAP_DEBUG_TRACE, "do_compare\n", 0, 0, 0 );
35 * Parse the compare request. It looks like this:
37 * CompareRequest := [APPLICATION 14] SEQUENCE {
38 * entry DistinguishedName,
41 * value AttributeValue
46 if ( ber_scanf( op->o_ber, "{a{ao}}", &ndn, &ava.ava_type,
47 &ava.ava_value ) == LBER_ERROR ) {
48 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
49 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
52 value_normalize( ava.ava_value.bv_val, attr_syntax( ava.ava_type ) );
54 Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
55 ndn, ava.ava_type, ava.ava_value.bv_val );
57 ndn = dn_normalize_case( ndn );
59 Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d CMP dn=\"%s\" attr=\"%s\"\n",
60 conn->c_connid, op->o_opid, ndn, ava.ava_type, 0 );
63 * We could be serving multiple database backends. Select the
64 * appropriate one, or send a referral to our "referral server"
65 * if we don't hold it.
67 if ( (be = select_backend( ndn )) == NULL ) {
71 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
76 /* alias suffix if approp */
77 ndn = suffixAlias( ndn, op, be );
78 dn_normalize_case( ndn );
80 if ( be->be_compare != NULL ) {
81 (*be->be_compare)( be, conn, op, ndn, &ava );
83 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
84 "Function not implemented" );