Commit 8ab94f4a authored by Howard Chu's avatar Howard Chu
Browse files

Import compare fix from HEAD

parent 3d152101
......@@ -57,8 +57,9 @@ ldap_back_compare(
{
struct ldapinfo *li = (struct ldapinfo *) be->be_private;
struct ldapconn *lc;
struct berval mapped_oc, mapped_at;
struct berval mapped_at, mapped_val;
struct berval mdn = { 0, NULL };
int freeval = 0;
lc = ldap_back_getconn(li, conn, op);
if (!lc || !ldap_back_dobind( lc, op ) ) {
......@@ -101,25 +102,68 @@ ldap_back_compare(
#endif /* !ENABLE_REWRITE */
if ( ava->aa_desc == slap_schema.si_ad_objectClass ) {
ldap_back_map(&li->oc_map, &ava->aa_desc->ad_cname, &mapped_oc,
ldap_back_map(&li->oc_map, &ava->aa_value, &mapped_val,
BACKLDAP_MAP);
if (mapped_oc.bv_val == NULL || mapped_oc.bv_val[0] == '\0') {
if (mapped_val.bv_val == NULL || mapped_val.bv_val[0] == '\0') {
return( -1 );
}
mapped_at = ava->aa_desc->ad_cname;
} else {
ldap_back_map(&li->at_map, &ava->aa_value, &mapped_at,
ldap_back_map(&li->at_map, &ava->aa_desc->ad_cname, &mapped_at,
BACKLDAP_MAP);
if (mapped_at.bv_val == NULL || mapped_at.bv_val[0] == '\0') {
return( -1 );
}
if (ava->aa_desc->ad_type->sat_syntax ==
slap_schema.si_syn_distinguishedName) {
#ifdef ENABLE_REWRITE
switch ( rewrite_session( li->rwinfo, "bindDn", ava->aa_value.bv_val, conn, &mapped_val.bv_val ) ) {
case REWRITE_REGEXEC_OK:
if ( mapped_val.bv_val == NULL ) {
mapped_val.bv_val = ( char * )ava->aa_value.bv_val;
} else {
freeval = 1;
}
#ifdef NEW_LOGGING
LDAP_LOG( BACK_LDAP, DETAIL1,
"[rw] bindDn (dnAttr): \"%s\" -> \"%s\"\n", ava->aa_value.bv_val, mapped_val.bv_val, 0 );
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"[rw] bindDn (dnAttr): \"%s\" -> \"%s\"\n", ava->aa_value.bv_val, mapped_val.bv_val, 0 );
#endif /* !NEW_LOGGING */
break;
case REWRITE_REGEXEC_UNWILLING:
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
NULL, "Operation not allowed", NULL, NULL );
return( -1 );
case REWRITE_REGEXEC_ERR:
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "Rewrite error", NULL, NULL );
return( -1 );
}
#else /* !ENABLE_REWRITE */
ldap_back_dn_massage( li, &ava->aa_value, &mapped_val, 0, 1 );
if ( mapped_val.bv_val == NULL ) {
mapped_val = ava->aa_value;
} else {
freeval = 1;
}
#endif /* !ENABLE_REWRITE */
}
}
ldap_compare_s( lc->ld, mdn.bv_val, mapped_oc.bv_val, mapped_at.bv_val );
ldap_compare_s( lc->ld, mdn.bv_val, mapped_at.bv_val, mapped_val.bv_val );
if ( mdn.bv_val != dn->bv_val ) {
free( mdn.bv_val );
}
if ( freeval ) {
free( mapped_val.bv_val );
}
return( ldap_back_op_result( lc, op ) );
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment