From 2d09d18de5f42d62747af8f115c027ea0915e464 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 11 Jan 2002 20:28:05 +0000 Subject: [PATCH] Add collective attribute system schema support. --- servers/slapd/at.c | 5 +---- servers/slapd/proto-slap.h | 2 ++ servers/slapd/schema/README | 4 ++-- servers/slapd/schema/collective.schema | 26 +++++++++++++------------- servers/slapd/schema/cosine.schema | 1 - servers/slapd/schema_check.c | 15 +++++++++++++-- 6 files changed, 31 insertions(+), 22 deletions(-) diff --git a/servers/slapd/at.c b/servers/slapd/at.c index 3bffc75ac5..ed8fd6ef79 100644 --- a/servers/slapd/at.c +++ b/servers/slapd/at.c @@ -332,18 +332,15 @@ at_add( } if ( at->at_collective ) { -#ifdef SLAP_COLLECTIVE if( at->at_usage ) { /* collective attributes cannot be operational */ return SLAP_SCHERR_NOT_SUPPORTED; } + if( at->at_single_value ) { /* collective attributes cannot be single-valued */ return SLAP_SCHERR_NOT_SUPPORTED; } -#else - return SLAP_SCHERR_NOT_SUPPORTED; -#endif } sat = (AttributeType *) ch_calloc( 1, sizeof(AttributeType) ); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 361ddc1afc..5e23ef9830 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -809,6 +809,8 @@ LDAP_SLAPD_F (int) is_entry_objectclass LDAP_P(( is_entry_objectclass((e), slap_schema.si_oc_referral) #define is_entry_subentry(e) \ is_entry_objectclass((e), slap_schema.si_oc_subentry) +#define is_entry_collectiveAttributes(e) \ + is_entry_objectclass((e), slap_schema.si_oc_collectiveAttributes) #define is_entry_dynamicObject(e) \ is_entry_objectclass((e), slap_schema.si_oc_dynamicObject) diff --git a/servers/slapd/schema/README b/servers/slapd/schema/README index be2a2587e6..efafad7128 100644 --- a/servers/slapd/schema/README +++ b/servers/slapd/schema/README @@ -3,6 +3,7 @@ use with slapd(5). File Description ---- ----------- +collective.schema Collective attributes corba.schema Corba Object (RFC 2714) core.schema OpenLDAP "core" cosine.schema COSINE Pilot @@ -13,10 +14,9 @@ microsoft.ext.schema Microsoft (FYI) microsoft.schema Microsoft (FYI) microsoft.std.schema Microsoft (FYI) misc.schema misc (experimental) -nadf.schema North American Directory Forum schema (obsolete) +nadf.schema North American Directory Forum (obsolete) nis.schema Network Information Service openldap.schema OpenLDAP Project (FYI) -vendor.schema Vendor Information (RFC 3045) schema Additional "generally useful" schema definitions can be submitted using the OpenLDAP Issue Tracking System . diff --git a/servers/slapd/schema/collective.schema b/servers/slapd/schema/collective.schema index 989ea8fdd8..2a4f6f3f80 100644 --- a/servers/slapd/schema/collective.schema +++ b/servers/slapd/schema/collective.schema @@ -50,7 +50,7 @@ # The c-l attribute type specifies a locality name for a collection of # entries. # -objectClass ( 2.5.4.7.1 NAME 'c-l' +attributeType ( 2.5.4.7.1 NAME 'c-l' SUP l COLLECTIVE ) # # @@ -59,7 +59,7 @@ objectClass ( 2.5.4.7.1 NAME 'c-l' # The c-st attribute type specifies a state or province name for a # collection of entries. # -objectClass ( 2.5.4.8.1 NAME 'c-st' +attributeType ( 2.5.4.8.1 NAME 'c-st' SUP st COLLECTIVE ) # # @@ -68,7 +68,7 @@ objectClass ( 2.5.4.8.1 NAME 'c-st' # The c-street attribute type specifies a street address for a # collection of entries. # -objectClass ( 2.5.4.9.1 NAME 'c-street' +attributeType ( 2.5.4.9.1 NAME 'c-street' SUP street COLLECTIVE ) # # @@ -77,7 +77,7 @@ objectClass ( 2.5.4.9.1 NAME 'c-street' # The c-o attribute type specifies an organization name for a collection # of entries. # -objectClass ( 2.5.4.10.1 NAME 'c-o' +attributeType ( 2.5.4.10.1 NAME 'c-o' SUP o COLLECTIVE ) # # @@ -86,7 +86,7 @@ objectClass ( 2.5.4.10.1 NAME 'c-o' # The c-ou attribute type specifies an organizational unit name for a # collection of entries. # -objectClass ( 2.5.4.11.1 NAME 'c-ou' +attributeType ( 2.5.4.11.1 NAME 'c-ou' SUP ou COLLECTIVE ) # # @@ -95,7 +95,7 @@ objectClass ( 2.5.4.11.1 NAME 'c-ou' # The c-PostalAddress attribute type specifies a postal address for a # collection of entries. # -objectClass ( 2.5.4.16.1 NAME 'c-PostalAddress' +attributeType ( 2.5.4.16.1 NAME 'c-PostalAddress' SUP postalAddress COLLECTIVE ) # # @@ -104,7 +104,7 @@ objectClass ( 2.5.4.16.1 NAME 'c-PostalAddress' # The c-PostalCode attribute type specifies a postal code for a # collection of entries. # -objectClass ( 2.5.4.17.1 NAME 'c-PostalCode' +attributeType ( 2.5.4.17.1 NAME 'c-PostalCode' SUP postalCode COLLECTIVE ) # # @@ -113,7 +113,7 @@ objectClass ( 2.5.4.17.1 NAME 'c-PostalCode' # The c-PostOfficeBox attribute type specifies a post office box for a # collection of entries. # -objectClass ( 2.5.4.18.1 NAME 'c-PostOfficeBox' +attributeType ( 2.5.4.18.1 NAME 'c-PostOfficeBox' SUP postOfficeBox COLLECTIVE ) # # @@ -122,7 +122,7 @@ objectClass ( 2.5.4.18.1 NAME 'c-PostOfficeBox' # The c-PhysicalDeliveryOfficeName attribute type specifies a physical # delivery office name for a collection of entries. # -objectClass ( 2.5.4.19.1 NAME 'c-PhysicalDeliveryOfficeName' +attributeType ( 2.5.4.19.1 NAME 'c-PhysicalDeliveryOfficeName' SUP physicalDeliveryOfficeName COLLECTIVE ) # # @@ -131,7 +131,7 @@ objectClass ( 2.5.4.19.1 NAME 'c-PhysicalDeliveryOfficeName' # The c-TelephoneNumber attribute type specifies a telephone number for # a collection of entries. # -objectClass ( 2.5.4.20.1 NAME 'c-TelephoneNumber' +attributeType ( 2.5.4.20.1 NAME 'c-TelephoneNumber' SUP telephoneNumber COLLECTIVE ) # # @@ -140,7 +140,7 @@ objectClass ( 2.5.4.20.1 NAME 'c-TelephoneNumber' # The c-TelexNumber attribute type specifies a telex number for a # collection of entries. # -objectClass ( 2.5.4.19.1 NAME 'c-TelexNumber' +attributeType ( 2.5.4.21.1 NAME 'c-TelexNumber' SUP telexNumber COLLECTIVE ) # # @@ -149,7 +149,7 @@ objectClass ( 2.5.4.19.1 NAME 'c-TelexNumber' # The c-FacsimileTelephoneNumber attribute type specifies a facsimile # telephone number for a collection of entries. # -objectClass ( 2.5.4.23.1 NAME 'c-FacsimileTelephoneNumber' +attributeType ( 2.5.4.23.1 NAME 'c-FacsimileTelephoneNumber' SUP facsimileTelephoneNumber COLLECTIVE ) # # @@ -158,5 +158,5 @@ objectClass ( 2.5.4.23.1 NAME 'c-FacsimileTelephoneNumber' # The c-InternationalISDNNumber attribute type specifies an # international ISDN number for a collection of entries. # -objectClass ( 2.5.4.25.1 NAME 'c-InternationalISDNNumber' +attributeType ( 2.5.4.25.1 NAME 'c-InternationalISDNNumber' SUP internationalISDNNumber COLLECTIVE ) diff --git a/servers/slapd/schema/cosine.schema b/servers/slapd/schema/cosine.schema index 783948c948..e23372d115 100644 --- a/servers/slapd/schema/cosine.schema +++ b/servers/slapd/schema/cosine.schema @@ -426,7 +426,6 @@ attributetype ( 0.9.2342.19200300.100.1.22 NAME 'otherMailbox' # distinguishedNameSyntax # ::= {pilotAttributeType 24} # - ## OBSOLETE #attributetype ( 0.9.2342.19200300.100.1.24 NAME 'lastModifiedBy' # DESC 'RFC1274: last modifier, replaced by modifiersName' diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index dc5842c187..5d5aaa82b1 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -45,11 +45,17 @@ entry_schema_check( AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass; int extensible = 0; + int subentry = is_entry_subentry( e ); + int collective = 0; + + if( subentry) collective = is_entry_collectiveAttributes( e ); *text = textbuf; /* 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 ); @@ -62,12 +68,17 @@ entry_schema_check( } } + if( !collective && is_at_collective( a->a_desc->ad_type ) ) { + snprintf( textbuf, textlen, "attribute '%s' " + "may only appear in collectiveAttributes subentry", + 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 ); -- 2.39.5