]> git.sur5r.net Git - openldap/commitdiff
Initial dontUseCopy implementation
authorKurt Zeilenga <kurt@openldap.org>
Tue, 22 Aug 2006 20:24:36 +0000 (20:24 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 22 Aug 2006 20:24:36 +0000 (20:24 +0000)
Needs to be extended to compare

servers/slapd/controls.c
servers/slapd/search.c

index 431d97a36facee06dff651e581b6fd616dad495c..48a2640156409a3e12d180d841aea5fe7e16e295 100644 (file)
@@ -177,7 +177,7 @@ static struct slap_control control_defs[] = {
 #ifdef SLAP_DONTUSECOPY
        { LDAP_CONTROL_DONTUSECOPY,
                (int)offsetof(struct slap_control_ids, sc_dontUseCopy),
-               SLAP_CTRL_INTROGATE|SLAP_CTRL_HIDE,
+               SLAP_CTRL_GLOBAL|SLAP_CTRL_INTROGATE|SLAP_CTRL_HIDE,
                NULL, NULL,
                parseDontUseCopy, LDAP_SLIST_ENTRY_INITIALIZER(next) },
 #endif
@@ -864,7 +864,7 @@ static int parseDontUseCopy (
                return LDAP_PROTOCOL_ERROR;
        }
 
-       if ( ctrl->ldctl_iscritical != SLAP_CONTROL_CRITICAL ) {
+       if ( !ctrl->ldctl_iscritical ) {
                rs->sr_text = "dontUseCopy criticality of FALSE not allowed";
                return LDAP_PROTOCOL_ERROR;
        }
index 97ca38283c2e231f6afac5af82f240c07cc0a5bd..b6eb2832f4c952b9401a359d40a242cc609656d1 100644 (file)
@@ -349,9 +349,28 @@ fe_op_search( Operation *op, SlapReply *rs )
                goto return_results;
        }
 
-       /* actually do the search and send the result(s) */
-       if ( op->o_bd->be_search ) {
+       if ( SLAP_SHADOW(op->o_bd) && get_dontUseCopy(op) ) {
+               /* don't use shadow copy */
+               BerVarray defref = op->o_bd->be_update_refs
+                       ? op->o_bd->be_update_refs : default_referral;
+
+               if( defref != NULL ) {
+                       rs->sr_ref = referral_rewrite( defref,
+                               NULL, &op->o_req_dn, op->ors_scope );
+                       if( !rs->sr_ref) rs->sr_ref = defref;
+                       rs->sr_err = LDAP_REFERRAL;
+                       send_ldap_result( op, rs );
+
+                       if (rs->sr_ref != defref) ber_bvarray_free( rs->sr_ref );
+
+               } else {
+                       send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
+                               "copy not used; no referral information available" );
+               }
+
+       } else if ( op->o_bd->be_search ) {
                if ( limits_check( op, rs ) == 0 ) {
+                       /* actually do the search and send the result(s) */
                        (op->o_bd->be_search)( op, rs );
                }
                /* else limits_check() sends error */