]> git.sur5r.net Git - openldap/commitdiff
fix compare; more manageDSAit cleanup
authorPierangelo Masarati <ando@openldap.org>
Thu, 20 Jan 2005 00:17:52 +0000 (00:17 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 20 Jan 2005 00:17:52 +0000 (00:17 +0000)
servers/slapd/back-sql/compare.c
servers/slapd/back-sql/delete.c
servers/slapd/back-sql/modify.c
servers/slapd/back-sql/modrdn.c
servers/slapd/back-sql/search.c

index 3a87819622cc2122ac8c2773799a50495227cb02..4783714f148bd393ec4e1f429d5c9d1822911dc0 100644 (file)
@@ -36,8 +36,8 @@ backsql_compare( Operation *op, SlapReply *rs )
        Attribute               *a = NULL;
        backsql_srch_info       bsi = { 0 };
        int                     rc;
-       AttributeName           anlist[2],
-                               *anlistp = NULL;
+       int                     manageDSAit = get_manageDSAit( op );
+       AttributeName           anlist[2];
 
        Debug( LDAP_DEBUG_TRACE, "==>backsql_compare()\n", 0, 0, 0 );
 
@@ -56,13 +56,6 @@ backsql_compare( Operation *op, SlapReply *rs )
        anlist[ 0 ].an_desc = op->oq_compare.rs_ava->aa_desc;
        BER_BVZERO( &anlist[ 1 ].an_name );
 
-       /*
-        * Try to get attr as dynamic operational
-        */
-       if ( !is_at_operational( op->oq_compare.rs_ava->aa_desc->ad_type ) ) {
-               anlistp = anlist;
-       }
-
        /*
         * Get the entry
         */
@@ -70,9 +63,28 @@ backsql_compare( Operation *op, SlapReply *rs )
        rc = backsql_init_search( &bsi, &op->o_req_ndn,
                        LDAP_SCOPE_BASE, 
                        SLAP_NO_LIMIT, SLAP_NO_LIMIT,
-                       (time_t)(-1), NULL, dbh, op, rs, anlistp,
+                       (time_t)(-1), NULL, dbh, op, rs, anlist,
                        ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) );
-       if ( rc != LDAP_SUCCESS ) {
+       switch ( rc ) {
+       case LDAP_SUCCESS:
+               break;
+
+       case LDAP_REFERRAL:
+               if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) )
+               {
+                       rs->sr_err = LDAP_SUCCESS;
+                       rs->sr_text = NULL;
+                       rs->sr_matched = NULL;
+                       if ( rs->sr_ref ) {
+                               ber_bvarray_free( rs->sr_ref );
+                               rs->sr_ref = NULL;
+                       }
+                       break;
+               }
+               /* fallthru */
+
+       default:
                Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
                        "could not retrieve compareDN ID - no such entry\n", 
                        0, 0, 0 );
@@ -89,10 +101,10 @@ backsql_compare( Operation *op, SlapReply *rs )
 
        if ( is_at_operational( op->oq_compare.rs_ava->aa_desc->ad_type ) ) {
                SlapReply       nrs = { 0 };
+               Attribute       **ap;
 
-               e.e_attrs = NULL;
-               ber_dupbv( &e.e_name, &bsi.bsi_base_id.eid_dn );
-               ber_dupbv( &e.e_nname, &bsi.bsi_base_id.eid_ndn );
+               for ( ap = &e.e_attrs; *ap; ap = &(*ap)->a_next )
+                       ;
 
                nrs.sr_attrs = anlist;
                nrs.sr_entry = &e;
@@ -104,17 +116,7 @@ backsql_compare( Operation *op, SlapReply *rs )
                        goto return_results;
                }
                
-               e.e_attrs = nrs.sr_operational_attrs;
-
-       } else {
-               rc = backsql_id2entry( &bsi, &bsi.bsi_base_id );
-               if ( rc != LDAP_SUCCESS ) {
-                       Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
-                               "error %d in backsql_id2entry() "
-                               "- compare failed\n", rc, 0, 0 );
-                       rs->sr_err = rc;
-                       goto return_results;
-               }
+               *ap = nrs.sr_operational_attrs;
        }
 
        if ( ! access_allowed( op, &e, op->oq_compare.rs_ava->aa_desc,
index 35648c5f9e67ddd135d8712a7ba9022c860f7c7f..470b762fd9dc9405555a40859e56d98e659117c6 100644 (file)
@@ -123,9 +123,8 @@ backsql_delete( Operation *op, SlapReply *rs )
                break;
 
        case LDAP_REFERRAL:
-               if ( !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
-                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname )
-                               && manageDSAit )
+               if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) )
                {
                        rs->sr_err = LDAP_SUCCESS;
                        rs->sr_text = NULL;
index 07d1135a2cd2030abf819617af325692dddc6e54..8f5be4fc39039b382320b21d9a09bdd3d9cd6f0b 100644 (file)
@@ -74,9 +74,8 @@ backsql_modify( Operation *op, SlapReply *rs )
                break;
 
        case LDAP_REFERRAL:
-               if ( !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
-                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname )
-                               && manageDSAit )
+               if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) )
                {
                        rs->sr_err = LDAP_SUCCESS;
                        rs->sr_text = NULL;
index d9b2d4d922184cf719f118ad9c1a559e194b2da0..a1578e565d8749d6c399feea9a62c11211a6f858 100644 (file)
@@ -83,9 +83,8 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                break;
 
        case LDAP_REFERRAL:
-               if ( !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
-                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname )
-                               && manageDSAit )
+               if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) )
                {
                        rs->sr_err = LDAP_SUCCESS;
                        rs->sr_text = NULL;
@@ -464,9 +463,8 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                        break;
 
                case LDAP_REFERRAL:
-                       if ( !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
-                                       dn_match( &new_ndn, &bsi.bsi_e->e_nname )
-                                       && manageDSAit )
+                       if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+                                       dn_match( &new_ndn, &bsi.bsi_e->e_nname ) )
                        {
                                rs->sr_err = LDAP_SUCCESS;
                                rs->sr_text = NULL;
index 9ec5ab3176ae79beef7d9277bf62612475d09288..e99842c67f9bbc6a3190cbc0de3c64f167d6514d 100644 (file)
@@ -1845,9 +1845,8 @@ backsql_search( Operation *op, SlapReply *rs )
                break;
 
        case LDAP_REFERRAL:
-               if ( !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
-                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname )
-                               && manageDSAit )
+               if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) )
                {
                        rs->sr_err = LDAP_SUCCESS;
                        rs->sr_text = NULL;