#include "ldap_pvt.h"
int is_object_subclass(
- ObjectClass *sub,
- ObjectClass *sup )
+ ObjectClass *sup,
+ ObjectClass *sub )
{
int i;
if( sub == NULL || sup == NULL ) return 0;
-#if 0
+#if 1
Debug( LDAP_DEBUG_TRACE, "is_object_subclass(%s,%s) %d\n",
- sub->soc_oid, sup->soc_oid, sup == sub );
+ sup->soc_oid, sub->soc_oid, sup == sub );
#endif
if( sup == sub ) {
return 1;
}
- if( sup->soc_sups == NULL ) {
+ if( sub->soc_sups == NULL ) {
return 0;
}
- for( i=0; sup->soc_sups[i] != NULL; i++ ) {
- if( is_object_subclass( sub, sup->soc_sups[i] ) ) {
+ for( i=0; sub->soc_sups[i] != NULL; i++ ) {
+ if( is_object_subclass( sup, sub->soc_sups[i] ) ) {
return 1;
}
}
}
if( set_flags && ( e->e_ocflags & SLAP_OC__END )) {
- return (e->e_ocflags & oc->soc_flags);
+ return (e->e_ocflags & oc->soc_flags) ? 1 : 0;
}
/*
oc_create_required(
ObjectClass *soc,
char **attrs,
+ int *op,
const char **err )
{
char **attrs1;
*err = *attrs1;
return SLAP_SCHERR_ATTR_NOT_FOUND;
}
+
+ if( is_at_operational( sat )) (*op)++;
+
if ( at_find_in_list(sat, soc->soc_required) < 0) {
if ( at_append_to_list(sat, &soc->soc_required) ) {
*err = *attrs1;
oc_create_allowed(
ObjectClass *soc,
char **attrs,
+ int *op,
const char **err )
{
char **attrs1;
*err = *attrs1;
return SLAP_SCHERR_ATTR_NOT_FOUND;
}
+
+ if( is_at_operational( sat )) (*op)++;
+
if ( at_find_in_list(sat, soc->soc_required) < 0 &&
at_find_in_list(sat, soc->soc_allowed) < 0 ) {
if ( at_append_to_list(sat, &soc->soc_allowed) ) {
oc_add_sups(
ObjectClass *soc,
char **sups,
+ int *op,
const char **err )
{
int code;
return SLAP_SCHERR_CLASS_BAD_USAGE;
}
- if ( add_sups )
+ if( soc->soc_flags & SLAP_OC_OPERATIONAL ) (*op)++;
+
+ if ( add_sups ) {
soc->soc_sups[nsups] = soc1;
+ }
- code = oc_add_sups( soc, soc1->soc_sup_oids, err );
+ code = oc_add_sups( soc, soc1->soc_sup_oids, op, err );
if ( code ) return code;
- code = oc_create_required( soc, soc1->soc_at_oids_must, err );
+ code = oc_create_required( soc, soc1->soc_at_oids_must, op, err );
if ( code ) return code;
- code = oc_create_allowed( soc, soc1->soc_at_oids_may, err );
+ code = oc_create_allowed( soc, soc1->soc_at_oids_may, op, err );
if ( code ) return code;
nsups++;
{
*err = soc->soc_oid;
ldap_memfree(oir);
- return SLAP_SCHERR_DUP_CLASS;
+ return SLAP_SCHERR_CLASS_DUP;
}
/* FIX: temporal consistency check */
{
*err = *names;
ldap_memfree(oir);
- return SLAP_SCHERR_DUP_CLASS;
+ return SLAP_SCHERR_CLASS_DUP;
}
/* FIX: temporal consistency check */
int
oc_add(
LDAPObjectClass *oc,
+ int user,
const char **err
)
{
ObjectClass *soc;
int code;
+ int op = 0;
if ( oc->oc_names != NULL ) {
int i;
{
/* structural object classes implicitly inherit from 'top' */
static char *top_oids[] = { SLAPD_TOP_OID, NULL };
- code = oc_add_sups( soc, top_oids, err );
+ code = oc_add_sups( soc, top_oids, &op, err );
} else {
- code = oc_add_sups( soc, soc->soc_sup_oids, err );
+ code = oc_add_sups( soc, soc->soc_sup_oids, &op, err );
}
if ( code != 0 ) return code;
- code = oc_create_required( soc, soc->soc_at_oids_must, err );
+ code = oc_create_required( soc, soc->soc_at_oids_must, &op, err );
if ( code != 0 ) return code;
- code = oc_create_allowed( soc, soc->soc_at_oids_may, err );
+ code = oc_create_allowed( soc, soc->soc_at_oids_may, &op, err );
if ( code != 0 ) return code;
+ if( user && op ) return SLAP_SCHERR_CLASS_BAD_SUP;
+
code = oc_insert(soc,err);
return code;
}
if ( ldap_objectclass2bv( &oc->soc_oclass, vals ) == NULL ) {
return -1;
}
+
+ if( oc->soc_flags & SLAP_OC_HIDE ) continue;
+
#if 0
Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n",
(long) vals[0].bv_len, vals[0].bv_val, 0 );