]> git.sur5r.net Git - openldap/commitdiff
Initial entryDN implementation.
authorKurt Zeilenga <kurt@openldap.org>
Tue, 7 Sep 2004 05:00:33 +0000 (05:00 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 7 Sep 2004 05:00:33 +0000 (05:00 +0000)
Need to implement filter support (for entryDN and subschemaSubentry).
Fixed hasSubordinate assert() bug in entry filters

servers/slapd/backend.c
servers/slapd/compare.c
servers/slapd/filterentry.c
servers/slapd/operational.c
servers/slapd/proto-slap.h
servers/slapd/result.c
servers/slapd/schema_prep.c
servers/slapd/slap.h

index 50478f33e8c986d5182f7ab6f20173ed9e997220..e01cc20ac85c928ef52a4c765a6724c4cee78d3c 100644 (file)
@@ -1573,14 +1573,21 @@ int backend_operational(
         * add them to the attribute list
         */
        if ( SLAP_OPATTRS( rs->sr_attr_flags ) || ( op->ors_attrs &&
-               ad_inlist( slap_schema.si_ad_subschemaSubentry, op->ors_attrs )) ) {
-               *ap = slap_operational_subschemaSubentry( op->o_bd );
+               ad_inlist( slap_schema.si_ad_entryDN, op->ors_attrs )))
+       {
+               *ap = slap_operational_entryDN( rs->sr_entry );
+               ap = &(*ap)->a_next;
+       }
 
+       if ( SLAP_OPATTRS( rs->sr_attr_flags ) || ( op->ors_attrs &&
+               ad_inlist( slap_schema.si_ad_subschemaSubentry, op->ors_attrs )))
+       {
+               *ap = slap_operational_subschemaSubentry( op->o_bd );
                ap = &(*ap)->a_next;
        }
 
-       if ( ( SLAP_OPATTRS( rs->sr_attr_flags ) || op->ors_attrs ) && op->o_bd &&
-               op->o_bd->be_operational != NULL )
+       if (( SLAP_OPATTRS( rs->sr_attr_flags ) || op->ors_attrs ) &&
+               op->o_bd && op->o_bd->be_operational != NULL )
        {
                Attribute       *a;
                
@@ -1604,17 +1611,23 @@ static void init_group_pblock( Operation *op, Entry *target,
        Entry *e, struct berval *op_ndn, AttributeDescription *group_at )
 {
        slapi_int_pblock_set_operation( op->o_pb, op );
-       slapi_pblock_set( op->o_pb, SLAPI_X_GROUP_ENTRY, (void *)e );
-       slapi_pblock_set( op->o_pb, SLAPI_X_GROUP_OPERATION_DN, (void *)op_ndn->bv_val );
-       slapi_pblock_set( op->o_pb, SLAPI_X_GROUP_ATTRIBUTE, (void *)group_at->ad_cname.bv_val );
-       slapi_pblock_set( op->o_pb, SLAPI_X_GROUP_TARGET_ENTRY, (void *)target );
+
+       slapi_pblock_set( op->o_pb,
+               SLAPI_X_GROUP_ENTRY, (void *)e );
+       slapi_pblock_set( op->o_pb,
+               SLAPI_X_GROUP_OPERATION_DN, (void *)op_ndn->bv_val );
+       slapi_pblock_set( op->o_pb,
+               SLAPI_X_GROUP_ATTRIBUTE, (void *)group_at->ad_cname.bv_val );
+       slapi_pblock_set( op->o_pb,
+               SLAPI_X_GROUP_TARGET_ENTRY, (void *)target );
 }
 
 static int call_group_preop_plugins( Operation *op )
 {
        int rc;
 
-       rc = slapi_int_call_plugins( op->o_bd, SLAPI_X_PLUGIN_PRE_GROUP_FN, op->o_pb );
+       rc = slapi_int_call_plugins( op->o_bd,
+               SLAPI_X_PLUGIN_PRE_GROUP_FN, op->o_pb );
        if ( rc < 0 ) {
                if (( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE,
                        (void *)&rc ) != 0 ) || rc == LDAP_SUCCESS )
index 47fff95598a34a27f638ad96f56ab9d55b218ebe..7a47daff6d6fc778df6e68d0d1607b53a40c4e34 100644 (file)
@@ -265,16 +265,23 @@ fe_op_compare( Operation *op, SlapReply *rs )
 #endif /* defined( LDAP_SLAPI ) */
 
        op->orc_ava = &ava;
-       if ( ava.aa_desc == slap_schema.si_ad_hasSubordinates
-                       && op->o_bd->be_has_subordinates )
+       if ( ava.aa_desc == slap_schema.si_ad_entryDN ) {
+               send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
+                       "entryDN compare not supported" );
+
+       } else if ( ava.aa_desc == slap_schema.si_ad_subschemaSubentry ) {
+               send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
+                       "subschemaSubentry compare not supported" );
+
+       } else if ( ava.aa_desc == slap_schema.si_ad_hasSubordinates
+               && op->o_bd->be_has_subordinates )
        {
                int     rc, hasSubordinates = LDAP_SUCCESS;
 
-               rc = be_entry_get_rw( op, &op->o_req_ndn, NULL, NULL,
-                               0, &entry );
+               rc = be_entry_get_rw( op, &op->o_req_ndn, NULL, NULL, 0, &entry );
                if ( rc == 0 && entry ) {
                        rc = op->o_bd->be_has_subordinates( op, entry,
-                                       &hasSubordinates );
+                               &hasSubordinates );
                        be_entry_release_r( op, entry );
                }
 
@@ -292,11 +299,11 @@ fe_op_compare( Operation *op, SlapReply *rs )
                send_ldap_result( op, rs );
 
                if ( rs->sr_err == LDAP_COMPARE_TRUE ||
-                               rs->sr_err == LDAP_COMPARE_FALSE )
+                       rs->sr_err == LDAP_COMPARE_FALSE )
                {
                        rs->sr_err = LDAP_SUCCESS;
                }
-       
+
        } else if ( op->o_bd->be_compare ) {
                op->o_bd->be_compare( op, rs );
 
index d881e28c1ff1177eccf32697f25491ddf90903bc..bd4b195ca47e282bcad416dcc93bbe87b49d9983 100644 (file)
@@ -352,6 +352,36 @@ test_ava_filter(
                return LDAP_INSUFFICIENT_ACCESS;
        }
 
+       if ( ava->aa_desc == slap_schema.si_ad_hasSubordinates 
+               && op && op->o_bd && op->o_bd->be_has_subordinates )
+       {
+               int     hasSubordinates;
+               struct berval   hs;
+
+               /* No other match is allowed */
+               if( type != LDAP_FILTER_EQUALITY ) return LDAP_OTHER;
+               
+               if ( op->o_bd->be_has_subordinates( op, e, &hasSubordinates ) !=
+                       LDAP_SUCCESS )
+               {
+                       return LDAP_OTHER;
+               }
+
+               if ( hasSubordinates == LDAP_COMPARE_TRUE ) {
+                       hs = slap_true_bv;
+
+               } else if ( hasSubordinates == LDAP_COMPARE_FALSE ) {
+                       hs = slap_false_bv;
+
+               } else {
+                       return LDAP_OTHER;
+               }
+
+               if ( bvmatch( &ava->aa_value, &hs ) ) return LDAP_COMPARE_TRUE;
+               return LDAP_COMPARE_FALSE;
+       }
+
+
        for(a = attrs_find( e->e_attrs, ava->aa_desc );
                a != NULL;
                a = attrs_find( a->a_next, ava->aa_desc ) )
@@ -379,9 +409,7 @@ test_ava_filter(
                        mr = NULL;
                }
 
-               if( mr == NULL ) {
-                       continue;
-               }
+               if( mr == NULL ) continue;
 
                for ( bv = a->a_nvals; bv->bv_val != NULL; bv++ ) {
                        int ret;
@@ -410,38 +438,7 @@ test_ava_filter(
                }
        }
 
-       if ( ava->aa_desc == slap_schema.si_ad_hasSubordinates 
-               && op && op->o_bd && op->o_bd->be_has_subordinates )
-       {
-               int             hasSubordinates;
-               struct berval   hs;
-
-               /*
-                * No other match should be allowed ...
-                */
-               assert( type == LDAP_FILTER_EQUALITY );
-               
-               if ( op->o_bd->be_has_subordinates( op, e, &hasSubordinates ) !=
-                       LDAP_SUCCESS )
-               {
-                       return LDAP_OTHER;
-               }
-
-               if ( hasSubordinates == LDAP_COMPARE_TRUE ) {
-                       hs = slap_true_bv;
-
-               } else if ( hasSubordinates == LDAP_COMPARE_FALSE ) {
-                       hs = slap_false_bv;
-
-               } else {
-                       return LDAP_OTHER;
-               }
-
-               if ( bvmatch( &ava->aa_value, &hs ) ) return LDAP_COMPARE_TRUE;
-               return LDAP_COMPARE_FALSE;
-       }
-
-       return( LDAP_COMPARE_FALSE );
+       return LDAP_COMPARE_FALSE;
 }
 
 
index d66d54b0937592dfd761bacad698d456b6ee6a0e..4838b11739385dc0567b297e8d02d33b3663745c 100644 (file)
@@ -48,18 +48,37 @@ slap_operational_subschemaSubentry( Backend *be )
        return a;
 }
 
+Attribute *
+slap_operational_entryDN( Entry *e )
+{
+       Attribute       *a;
+
+       a = ch_malloc( sizeof( Attribute ) );
+       a->a_desc = slap_schema.si_ad_entryDN;
+
+       a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
+       ber_dupbv( a->a_vals, &e->e_name );
+       a->a_vals[1].bv_len = 0;
+       a->a_vals[1].bv_val = NULL;
+
+       a->a_nvals = ch_malloc( 2 * sizeof( struct berval ) );
+       ber_dupbv( a->a_nvals, &e->e_nname );
+       a->a_nvals[1].bv_len = 0;
+       a->a_nvals[1].bv_val = NULL;
+
+       a->a_next = NULL;
+       a->a_flags = 0;
+
+       return a;
+}
+
 Attribute *
 slap_operational_hasSubordinate( int hs )
 {
        Attribute       *a;
        struct berval   val;
 
-       if ( hs ) {
-               val = slap_true_bv;
-
-       } else {
-               val = slap_false_bv;
-       }
+       val = hs ? slap_true_bv : slap_false_bv;
 
        a = ch_malloc( sizeof( Attribute ) );
        a->a_desc = slap_schema.si_ad_hasSubordinates;
index d9684e4d15e1468fdf31c8f0e9f2576401cabcf3..f05259524bc9a482faefe4f6ca397d19e8fea08e 100644 (file)
@@ -907,6 +907,7 @@ LDAP_SLAPD_F (Operation *) slap_op_pop LDAP_P(( Operation **olist ));
  * operational.c
  */
 LDAP_SLAPD_F (Attribute *) slap_operational_subschemaSubentry( Backend *be );
+LDAP_SLAPD_F (Attribute *) slap_operational_entryDN( Entry *e );
 LDAP_SLAPD_F (Attribute *) slap_operational_hasSubordinate( int has );
 
 /*
index 69ec2f4740bf55cb2d4f2b8cb49962b9dee99080..b80743871ecdb128621bf0ddddd4ffc27c14a84f 100644 (file)
@@ -693,8 +693,9 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
        
        rs->sr_type = REP_SEARCH;
 
-       /* eventually will loop through generated operational attributes */
-       /* only subschemaSubentry and numSubordinates are implemented */
+       /* eventually will loop through generated operational attribute types
+        * currently implemented types include:
+        *      entryDN, subschemaSubentry, and hasSubordinates */
        /* NOTE: moved before overlays callback circling because
         * they may modify entry and other stuff in rs */
        /* check for special all operational attributes ("+") type */
index e1c09e1daa8a757e951e77b2688e381324e7781d..8ac8f3ae80190e011697f0b57e8c74076578f68d 100644 (file)
@@ -528,6 +528,15 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_collectiveExclusions) },
 #endif
 
+       { "entryDN", "( 1.3.6.1.4.1.4203.666.1.33 NAME 'entryDN' "   
+                       "DESC 'DN of the entry' "
+                       "EQUALITY distinguishedNameMatch "
+                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
+                       "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
+               NULL, SLAP_AT_HIDE,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_entryDN) },
        { "entryUUID", "( 1.3.6.1.4.1.4203.666.1.6 NAME 'entryUUID' "   
                        "DESC 'UUID of the entry' "
                        "EQUALITY UUIDMatch "
@@ -559,6 +568,7 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_namingCSN) },
 
+#if 0
        { "superiorUUID", "( 1.3.6.1.4.1.4203.666.1.11 NAME 'superiorUUID' "   
                        "DESC 'UUID of the superior entry' "
                        "EQUALITY octetStringMatch "
@@ -568,6 +578,7 @@ static struct slap_schema_ad_map {
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_superiorUUID) },
+#endif
 
        { "syncreplCookie", "( 1.3.6.1.4.1.4203.666.1.23 "
                        "NAME 'syncreplCookie' "
index cab135a846f045d390a30fbc310c025989dae3f2..8cc963126a1eb1505f4bd000a1d55208c0aaf99e 100644 (file)
@@ -797,10 +797,10 @@ struct slap_internal_schema {
        AttributeDescription *si_ad_subschemaSubentry;
        AttributeDescription *si_ad_collectiveSubentries;
        AttributeDescription *si_ad_collectiveExclusions;
+       AttributeDescription *si_ad_entryDN;
        AttributeDescription *si_ad_entryUUID;
        AttributeDescription *si_ad_entryCSN;
        AttributeDescription *si_ad_namingCSN;
-       AttributeDescription *si_ad_superiorUUID;
 
        AttributeDescription *si_ad_dseType;
        AttributeDescription *si_ad_syncreplCookie;