/* schema_check.c - routines to enforce schema definitions */
/* $OpenLDAP$ */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
int
entry_schema_check(
- Entry *e, Attribute *oldattrs,
+ Backend *be,
+ Entry *e,
+ Attribute *oldattrs,
const char** text,
char *textbuf, size_t textlen )
{
AttributeDescription *ad_objectClass
= slap_schema.si_ad_objectClass;
int extensible = 0;
+ int subentry = is_entry_subentry( e );
+ int collectiveSubentry = 0;
+
+ if( subentry) collectiveSubentry = is_entry_collectiveAttributeSubentry( e );
*text = textbuf;
- /* check single-valued attrs for multiple values */
+ /* misc attribute checks */
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
+ const char *type = a->a_desc->ad_cname.bv_val;
+
/* there should be at least one value */
assert( a->a_vals );
assert( a->a_vals[0].bv_val != NULL );
+ if( a->a_desc->ad_type->sat_check ) {
+ int rc = (a->a_desc->ad_type->sat_check)(
+ be, e, a, text, textbuf, textlen );
+ if( rc != LDAP_SUCCESS ) {
+ return rc;
+ }
+ }
+
+ if( !collectiveSubentry && is_at_collective( a->a_desc->ad_type ) ) {
+ snprintf( textbuf, textlen,
+ "'%s' can only appear in collectiveAttributeSubentry",
+ type );
+ return LDAP_OBJECT_CLASS_VIOLATION;
+ }
+
/* if single value type, check for multiple values */
if( is_at_single_value( a->a_desc->ad_type ) &&
a->a_vals[1].bv_val != NULL )
{
- char *type = a->a_desc->ad_cname.bv_val;
-
snprintf( textbuf, textlen,
"attribute '%s' cannot have multiple values",
type );
if( sc == NULL ) {
snprintf( textbuf, textlen,
"unrecognized structuralObjectClass '%s'",
- aoc->a_vals[0].bv_val );
+ asc->a_vals[0].bv_val );
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_INFO,
if( sc->soc_kind != LDAP_SCHEMA_STRUCTURAL ) {
snprintf( textbuf, textlen,
"structuralObjectClass '%s' is not STRUCTURAL",
- aoc->a_vals[0].bv_val );
+ asc->a_vals[0].bv_val );
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_INFO,
assert( aoc->a_vals != NULL );
assert( aoc->a_vals[0].bv_val != NULL );
- rc = structural_class( aoc->a_vals, &nsc, text, textbuf, textlen );
+ rc = structural_class( aoc->a_vals, &nsc, &oc, text, textbuf, textlen );
if( rc != LDAP_SUCCESS ) {
return rc;
} else if ( nsc.bv_len == 0 ) {
*text = textbuf;
- oc = oc_bvfind( &nsc );
if ( oc == NULL ) {
snprintf( textbuf, textlen,
"unrecognized objectClass '%s'",
- aoc->a_vals[i].bv_val );
+ aoc->a_vals[0].bv_val );
return LDAP_OBJECT_CLASS_VIOLATION;
} else if ( sc != oc ) {
#endif
return LDAP_OBJECT_CLASS_VIOLATION;
+ }
- } else if ( oc->soc_kind == LDAP_SCHEMA_ABSTRACT ) {
+ if ( oc->soc_check ) {
+ int rc = (oc->soc_check)( be, e, oc,
+ text, textbuf, textlen );
+ if( rc != LDAP_SUCCESS ) {
+ return rc;
+ }
+ }
+
+ if ( oc->soc_kind == LDAP_SCHEMA_ABSTRACT ) {
/* object class is abstract */
if ( oc != slap_schema.si_oc_top &&
!is_object_subclass( oc, sc ))
int oc_check_allowed(
AttributeType *at,
- BVarray ocl,
+ BerVarray ocl,
ObjectClass *sc )
{
int i, j;
* Determine the structural object class from a set of OIDs
*/
int structural_class(
- BVarray ocs,
+ BerVarray ocs,
struct berval *scbv,
+ ObjectClass **scp,
const char **text,
char *textbuf, size_t textlen )
{
}
}
+ if( scp )
+ *scp = sc;
+
if( sc == NULL ) {
*text = "no structural object classes provided";
return LDAP_OBJECT_CLASS_VIOLATION;
return LDAP_OBJECT_CLASS_VIOLATION;
}
- return structural_class( ocmod->sml_bvalues, sc,
+ return structural_class( ocmod->sml_bvalues, sc, NULL,
text, textbuf, textlen );
}