]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_prep.c
add authzSyntax for authzTo/authzFrom attributes; add X-ORDERED 'VALUES' if support...
[openldap] / servers / slapd / schema_prep.c
index 0af3f42a57c0567b12e7bc68d34a1ad783bfa71c..2b2d8b1e371a4594d479ee97625eec19b7044052 100644 (file)
@@ -1,8 +1,17 @@
-/* schema_init.c - init builtin schema */
+/* schema_prep.c - load builtin schema */
 /* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2005 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
  */
 
 #include "portable.h"
@@ -14,8 +23,6 @@
 #include <ac/socket.h>
 
 #include "slap.h"
-#include "ldap_pvt.h"
-#include "ldap_pvt_uc.h"
 
 #define OCDEBUG 0
 
@@ -23,20 +30,173 @@ int schema_init_done = 0;
 
 struct slap_internal_schema slap_schema;
 
+static int
+oidValidate(
+       Syntax *syntax,
+       struct berval *in )
+{
+       struct berval val = *in;
+
+       if( val.bv_len == 0 ) {
+               /* disallow empty strings */
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       if( DESC_LEADCHAR( val.bv_val[0] ) ) {
+               val.bv_val++;
+               val.bv_len--;
+               if ( val.bv_len == 0 ) return LDAP_SUCCESS;
+
+               while( DESC_CHAR( val.bv_val[0] ) ) {
+                       val.bv_val++;
+                       val.bv_len--;
+
+                       if ( val.bv_len == 0 ) return LDAP_SUCCESS;
+               }
+
+       } else {
+               int sep = 0;
+               while( OID_LEADCHAR( val.bv_val[0] ) ) {
+                       val.bv_val++;
+                       val.bv_len--;
+
+                       if ( val.bv_val[-1] != '0' ) {
+                               while ( OID_LEADCHAR( val.bv_val[0] )) {
+                                       val.bv_val++;
+                                       val.bv_len--;
+                               }
+                       }
+
+                       if( val.bv_len == 0 ) {
+                               if( sep == 0 ) break;
+                               return LDAP_SUCCESS;
+                       }
+
+                       if( !OID_SEPARATOR( val.bv_val[0] )) break;
+
+                       sep++;
+                       val.bv_val++;
+                       val.bv_len--;
+               }
+       }
+
+       return LDAP_INVALID_SYNTAX;
+}
+
+
 static int objectClassPretty(
        struct slap_syntax *syntax,
        struct berval * in,
        struct berval * out,
        void *ctx )
 {
-       ObjectClass *oc = oc_bvfind( in );
+       ObjectClass *oc;
 
-       if( oc != NULL ) {
-               ber_dupbv_x( out, &oc->soc_cname, ctx );
-       } else {
-               ber_dupbv_x( out, in, ctx );
+       if( oidValidate( NULL, in )) return LDAP_INVALID_SYNTAX;
+
+       oc = oc_bvfind( in );
+       if( oc == NULL ) return LDAP_INVALID_SYNTAX;
+
+       ber_dupbv_x( out, &oc->soc_cname, ctx );
+       return LDAP_SUCCESS;
+}
+
+static int
+attributeTypeMatch(
+       int *matchp,
+       slap_mask_t flags,
+       Syntax *syntax,
+       MatchingRule *mr,
+       struct berval *value,
+       void *assertedValue )
+{
+       struct berval *a = (struct berval *) assertedValue;
+       AttributeType *at = at_bvfind( value );
+       AttributeType *asserted = at_bvfind( a );
+
+       if( asserted == NULL ) {
+               if( OID_LEADCHAR( *a->bv_val ) ) {
+                       /* OID form, return FALSE */
+                       *matchp = 1;
+                       return LDAP_SUCCESS;
+               }
+
+               /* desc form, return undefined */
+               return LDAP_INVALID_SYNTAX;
        }
 
+       if ( at == NULL ) {
+               /* unrecognized stored value */
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       *matchp = ( asserted != at );
+       return LDAP_SUCCESS;
+}
+
+static int
+matchingRuleMatch(
+       int *matchp,
+       slap_mask_t flags,
+       Syntax *syntax,
+       MatchingRule *mr,
+       struct berval *value,
+       void *assertedValue )
+{
+       struct berval *a = (struct berval *) assertedValue;
+       MatchingRule *mrv = mr_bvfind( value );
+       MatchingRule *asserted = mr_bvfind( a );
+
+       if( asserted == NULL ) {
+               if( OID_LEADCHAR( *a->bv_val ) ) {
+                       /* OID form, return FALSE */
+                       *matchp = 1;
+                       return LDAP_SUCCESS;
+               }
+
+               /* desc form, return undefined */
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       if ( mrv == NULL ) {
+               /* unrecognized stored value */
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       *matchp = ( asserted != mrv );
+       return LDAP_SUCCESS;
+}
+
+static int
+objectClassMatch(
+       int *matchp,
+       slap_mask_t flags,
+       Syntax *syntax,
+       MatchingRule *mr,
+       struct berval *value,
+       void *assertedValue )
+{
+       struct berval *a = (struct berval *) assertedValue;
+       ObjectClass *oc = oc_bvfind( value );
+       ObjectClass *asserted = oc_bvfind( a );
+
+       if( asserted == NULL ) {
+               if( OID_LEADCHAR( *a->bv_val ) ) {
+                       /* OID form, return FALSE */
+                       *matchp = 1;
+                       return LDAP_SUCCESS;
+               }
+
+               /* desc form, return undefined */
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       if ( oc == NULL ) {
+               /* unrecognized stored value */
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       *matchp = ( asserted != oc );
        return LDAP_SUCCESS;
 }
 
@@ -61,12 +221,12 @@ objectSubClassMatch(
                }
 
                /* desc form, return undefined */
-               return SLAPD_COMPARE_UNDEFINED;
+               return LDAP_INVALID_SYNTAX;
        }
 
        if ( oc == NULL ) {
                /* unrecognized stored value */
-               return SLAPD_COMPARE_UNDEFINED;
+               return LDAP_INVALID_SYNTAX;
        }
 
        if( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( flags ) ) {
@@ -96,7 +256,7 @@ static int objectSubClassIndexer(
        }
 
        /* over allocate */
-       ocvalues = sl_malloc( sizeof( struct berval ) * (noc+16), ctx );
+       ocvalues = slap_sl_malloc( sizeof( struct berval ) * (noc+16), ctx );
 
        /* copy listed values (and termination) */
        for( i=0; i<noc; i++ ) {
@@ -130,15 +290,15 @@ static int objectSubClassIndexer(
                        }
 
                        if( !found ) {
-                               ocvalues = sl_realloc( ocvalues,
+                               ocvalues = slap_sl_realloc( ocvalues,
                                        sizeof( struct berval ) * (noc+2), ctx );
 
                                assert( k == noc );
 
                                ocvalues[noc] = sup->soc_cname;
 
-                               assert( ocvalues[noc].bv_val );
-                               assert( ocvalues[noc].bv_len );
+                               assert( ocvalues[noc].bv_val != NULL );
+                               assert( ocvalues[noc].bv_len != 0 );
 
                                noc++;
 
@@ -151,7 +311,7 @@ static int objectSubClassIndexer(
        rc = octetStringIndexer( use, mask, syntax, mr,
                prefix, ocvalues, keysp, ctx );
 
-       sl_free( ocvalues, ctx );
+       slap_sl_free( ocvalues, ctx );
        return rc;
 }
 
@@ -161,7 +321,9 @@ static ObjectClassSchemaCheckFN rootDseObjectClass;
 static ObjectClassSchemaCheckFN aliasObjectClass;
 static ObjectClassSchemaCheckFN referralObjectClass;
 static ObjectClassSchemaCheckFN subentryObjectClass;
+#ifdef LDAP_DYNAMIC_OBJECTS
 static ObjectClassSchemaCheckFN dynamicObjectClass;
+#endif
 
 static struct slap_schema_oc_map {
        char *ssom_name;
@@ -210,13 +372,17 @@ static struct slap_schema_oc_map {
                        "matchingRuleUse ) )",
                subentryObjectClass, SLAP_OC_OPERATIONAL,
                offsetof(struct slap_internal_schema, si_oc_subschema) },
-#ifdef LDAP_DEVEL
+#ifdef LDAP_COLLECTIVE_ATTRIBUTES
        { "collectiveAttributeSubentry", "( 2.5.17.2 "
                        "NAME 'collectiveAttributeSubentry' "
+                       "DESC 'RFC3671: collective attribute subentry' "
                        "AUXILIARY )",
                subentryObjectClass,
                SLAP_OC_COLLECTIVEATTRIBUTESUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
-               offsetof(struct slap_internal_schema, si_oc_collectiveAttributeSubentry) },
+               offsetof( struct slap_internal_schema,
+                       si_oc_collectiveAttributeSubentry) },
+#endif
+#ifdef LDAP_DYNAMIC_OBJECTS
        { "dynamicObject", "( 1.3.6.1.4.1.1466.101.119.2 "
                        "NAME 'dynamicObject' "
                        "DESC 'RFC2589: Dynamic Object' "
@@ -235,14 +401,14 @@ static struct slap_schema_oc_map {
                        "DESC 'Persistent Info for SyncRepl Consumer' "
                        "AUXILIARY "
                        "MAY syncreplCookie )",
-               0, SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
+               0, SLAP_OC_SYNCCONSUMERSUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
                offsetof(struct slap_internal_schema, si_oc_syncConsumerSubentry) },
        { "syncProviderSubentry", "( 1.3.6.1.4.1.4203.666.3.6 "
                        "NAME 'syncProviderSubentry' "
                        "DESC 'Persistent Info for SyncRepl Producer' "
                        "AUXILIARY "
                        "MAY contextCSN )",
-               0, SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
+               0, SLAP_OC_SYNCPROVIDERSUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
                offsetof(struct slap_internal_schema, si_oc_syncProviderSubentry) },
 
        { NULL, NULL, NULL, 0, 0 }
@@ -253,7 +419,9 @@ static AttributeTypeSchemaCheckFN aliasAttribute;
 static AttributeTypeSchemaCheckFN referralAttribute;
 static AttributeTypeSchemaCheckFN subentryAttribute;
 static AttributeTypeSchemaCheckFN administrativeRoleAttribute;
+#ifdef LDAP_DYNAMIC_OBJECTS
 static AttributeTypeSchemaCheckFN dynamicAttribute;
+#endif
 
 static struct slap_schema_ad_map {
        char *ssam_name;
@@ -274,7 +442,7 @@ static struct slap_schema_ad_map {
                        "EQUALITY objectIdentifierMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
                NULL, SLAP_AT_FINAL,
-               NULL, objectClassPretty,
+               oidValidate, objectClassPretty,
                NULL, NULL, objectSubClassMatch,
                        objectSubClassIndexer, objectSubClassFilter,
                offsetof(struct slap_internal_schema, si_ad_objectClass) },
@@ -285,8 +453,8 @@ static struct slap_schema_ad_map {
                        "EQUALITY objectIdentifierMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
-               NULL, objectClassPretty,
+               NULL, SLAP_AT_MANAGEABLE,
+               oidValidate, objectClassPretty,
                NULL, NULL, objectSubClassMatch,
                        objectSubClassIndexer, objectSubClassFilter,
                offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) },
@@ -296,7 +464,7 @@ static struct slap_schema_ad_map {
                        "ORDERING generalizedTimeOrderingMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_MANAGEABLE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
@@ -306,7 +474,7 @@ static struct slap_schema_ad_map {
                        "ORDERING generalizedTimeOrderingMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_MANAGEABLE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
@@ -315,7 +483,7 @@ static struct slap_schema_ad_map {
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_MANAGEABLE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_creatorsName) },
@@ -324,7 +492,7 @@ static struct slap_schema_ad_map {
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_MANAGEABLE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_modifiersName) },
@@ -333,7 +501,7 @@ static struct slap_schema_ad_map {
                        "EQUALITY booleanMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_DYNAMIC,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_hasSubordinates) },
@@ -342,13 +510,14 @@ static struct slap_schema_ad_map {
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE "
                        "NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_DYNAMIC,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
-#ifdef LDAP_DEVEL
+#ifdef LDAP_COLLECTIVE_ATTRIBUTES
        { "collectiveAttributeSubentries", "( 2.5.18.12 "
                        "NAME 'collectiveAttributeSubentries' "
+                       "DESC 'RFC3671: collective attribute subentries' "
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
                        "NO-USER-MODIFICATION USAGE directoryOperation )",
@@ -357,6 +526,7 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_collectiveSubentries) },
        { "collectiveExclusions", "( 2.5.18.7 NAME 'collectiveExclusions' "
+                       "DESC 'RFC3671: collective attribute exclusions' "
                        "EQUALITY objectIdentifierMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
                        "USAGE directoryOperation )",
@@ -366,10 +536,20 @@ 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|SLAP_AT_DYNAMIC,
+               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 octetStringMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
+                       "EQUALITY UUIDMatch "
+                       "ORDERING UUIDOrderingMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.2.6 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
@@ -377,9 +557,9 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_entryUUID) },
        { "entryCSN", "( 1.3.6.1.4.1.4203.666.1.7 NAME 'entryCSN' "
                        "DESC 'change sequence number of the entry content' "
-                       "EQUALITY octetStringMatch "
-                       "ORDERING octetStringOrderingMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
+                       "EQUALITY CSNMatch "
+                       "ORDERING CSNOrderingMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
@@ -387,15 +567,16 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_entryCSN) },
        { "namingCSN", "( 1.3.6.1.4.1.4203.666.1.13 NAME 'namingCSN' "
                        "DESC 'change sequence number of the entry naming (RDN)' "
-                       "EQUALITY octetStringMatch "
-                       "ORDERING octetStringOrderingMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
+                       "EQUALITY CSNMatch "
+                       "ORDERING CSNOrderingMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
                        "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_namingCSN) },
 
+#ifdef LDAP_SUPERIOR_UUID
        { "superiorUUID", "( 1.3.6.1.4.1.4203.666.1.11 NAME 'superiorUUID' "   
                        "DESC 'UUID of the superior entry' "
                        "EQUALITY octetStringMatch "
@@ -405,25 +586,15 @@ static struct slap_schema_ad_map {
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_superiorUUID) },
-
-       /* LDAP cache specific operational attribute */
-       { "queryid", "( 1.3.6.1.4.1.4203.666.1.12 NAME 'queryid' "
-                       "DESC 'list of queries the entry belongs to' "
-                       "EQUALITY octetStringMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
-                       "NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, SLAP_AT_HIDE,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL, 
-               offsetof(struct slap_internal_schema, si_ad_queryid) },
+#endif
 
        { "syncreplCookie", "( 1.3.6.1.4.1.4203.666.1.23 "
                        "NAME 'syncreplCookie' "
                        "DESC 'syncrepl Cookie for shadow copy' "
                        "EQUALITY octetStringMatch "
                        "ORDERING octetStringOrderingMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
-                       "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
+                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 "
+                       "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
@@ -432,15 +603,28 @@ static struct slap_schema_ad_map {
        { "contextCSN", "( 1.3.6.1.4.1.4203.666.1.25 "
                        "NAME 'contextCSN' "
                        "DESC 'the largest committed CSN of a context' "
-                       "EQUALITY octetStringMatch "
-                       "ORDERING octetStringOrderingMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
-                       "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
+                       "EQUALITY CSNMatch "
+                       "ORDERING CSNOrderingMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
+                       "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_contextCSN) },
 
+#ifdef LDAP_SYNC_TIMESTAMP
+       { "syncTimestamp", "( 1.3.6.1.4.1.4203.666.1.26 NAME 'syncTimestamp' "
+                       "DESC 'Time which object was replicated' "
+                       "EQUALITY generalizedTimeMatch "
+                       "ORDERING generalizedTimeOrderingMatch "
+                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
+                       "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
+               NULL, 0,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_syncTimestamp) },
+#endif
+
        /* root DSE attributes */
        { "altServer", "( 1.3.6.1.4.1.1466.101.120.6 NAME 'altServer' "
                        "DESC 'RFC2252: alternative servers' "
@@ -509,6 +693,16 @@ static struct slap_schema_ad_map {
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_monitorContext) },
+       { "configContext", "( 1.3.6.1.4.1.4203.666.11.1.1 "
+                       "NAME 'configContext' "
+                       "DESC 'config context' "
+                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
+                       "SINGLE-VALUE NO-USER-MODIFICATION "
+                       "USAGE dSAOperation )",
+               rootDseAttribute, SLAP_AT_HIDE,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_configContext) },
        { "vendorName", "( 1.3.6.1.1.4 NAME 'vendorName' "
                        "DESC 'RFC3045: name of implementation vendor' "
                        "EQUALITY caseExactMatch "
@@ -563,32 +757,32 @@ static struct slap_schema_ad_map {
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.16 USAGE directoryOperation )",
                subentryAttribute, SLAP_AT_HIDE,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL,
+               oidValidate, NULL,
+               NULL, NULL, objectClassMatch, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_ditContentRules) },
        { "matchingRules", "( 2.5.21.4 NAME 'matchingRules' "
                        "DESC 'RFC2252: matching rules' "
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.30 USAGE directoryOperation )",
                subentryAttribute, 0,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL,
+               oidValidate, NULL,
+               NULL, NULL, matchingRuleMatch, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_matchingRules) },
        { "attributeTypes", "( 2.5.21.5 NAME 'attributeTypes' "
                        "DESC 'RFC2252: attribute types' "
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.3 USAGE directoryOperation )",
                subentryAttribute, 0,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL,
+               oidValidate, NULL,
+               NULL, NULL, attributeTypeMatch, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
        { "objectClasses", "( 2.5.21.6 NAME 'objectClasses' "
                        "DESC 'RFC2252: object classes' "
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.37 USAGE directoryOperation )",
                subentryAttribute, 0,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL,
+               oidValidate, NULL,
+               NULL, NULL, objectClassMatch, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_objectClasses) },
        { "nameForms", "( 2.5.21.7 NAME 'nameForms' "
                        "DESC 'RFC2252: name forms ' "
@@ -603,8 +797,8 @@ static struct slap_schema_ad_map {
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.31 USAGE directoryOperation )",
                subentryAttribute, 0,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL,
+               oidValidate, NULL,
+               NULL, NULL, matchingRuleMatch, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_matchingRuleUse) },
 
        { "ldapSyntaxes", "( 1.3.6.1.4.1.1466.101.120.16 NAME 'ldapSyntaxes' "
@@ -655,21 +849,39 @@ static struct slap_schema_ad_map {
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_children) },
-       { "saslAuthzTo", "( 1.3.6.1.4.1.4203.666.1.8 "
-                       "NAME 'saslAuthzTo' "
-                       "DESC 'SASL proxy authorization targets' "
+
+       /* access control externals */
+       { "authzTo", "( 1.3.6.1.4.1.4203.666.1.8 "
+                       "NAME ( 'authzTo' 'saslAuthzTo' ) "
+                       "DESC 'proxy authorization targets' "
+#ifdef SLAP_AUTHZ_SYNTAX
+                       "EQUALITY authzMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.2.7 "
+#else /* ! SLAP_AUTHZ_SYNTAX */
                        "EQUALITY caseExactMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
+#endif /* ! SLAP_AUTHZ_SYNTAX */
+#ifdef SLAP_ORDERED_PRETTYNORM
+                       "X-ORDERED 'VALUES' "
+#endif /* SLAP_ORDERED_PRETTYNORM */
                        "USAGE distributedOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_saslAuthzTo) },
-       { "saslAuthzFrom", "( 1.3.6.1.4.1.4203.666.1.9 "
-                       "NAME 'saslAuthzFrom' "
-                       "DESC 'SASL proxy authorization sources' "
+       { "authzFrom", "( 1.3.6.1.4.1.4203.666.1.9 "
+                       "NAME ( 'authzFrom' 'saslAuthzFrom' ) "
+                       "DESC 'proxy authorization sources' "
+#ifdef SLAP_AUTHZ_SYNTAX
+                       "EQUALITY authzMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.2.7 "
+#else /* ! SLAP_AUTHZ_SYNTAX */
                        "EQUALITY caseExactMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
+#endif /* ! SLAP_AUTHZ_SYNTAX */
+#ifdef SLAP_ORDERED_PRETTYNORM
+                       "X-ORDERED 'VALUES' "
+#endif /* SLAP_ORDERED_PRETTYNORM */
                        "USAGE distributedOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
@@ -682,13 +894,13 @@ static struct slap_schema_ad_map {
                        "EQUALITY OpenLDAPaciMatch "
                        "SYNTAX 1.3.6.1.4.1.4203.666.2.1 "
                        "USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_HIDE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_aci) },
 #endif
 
-#ifdef LDAP_DEVEL
+#ifdef LDAP_DYNAMIC_OBJECTS
        { "entryTtl", "( 1.3.6.1.4.1.1466.101.119.3 NAME 'entryTtl' "
                        "DESC 'RFC2589: entry time-to-live' "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE "
@@ -733,6 +945,15 @@ static struct slap_schema_ad_map {
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_cn) },
+       { "uid", "( 0.9.2342.19200300.100.1.1 NAME ( 'uid' 'userid' ) "
+                       "DESC 'RFC1274: user identifier' "
+                       "EQUALITY caseIgnoreMatch "
+                       "SUBSTR caseIgnoreSubstringsMatch "
+                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} )",
+               NULL, 0,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_uid) },
        { "userPassword", "( 2.5.4.35 NAME 'userPassword' "
                        "DESC 'RFC2256/2307: password of user' "
                        "EQUALITY octetStringMatch "
@@ -742,6 +963,15 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_userPassword) },
 
+       { "labeledURI", "( 1.3.6.1.4.1.250.1.57 NAME 'labeledURI' "
+                       "DESC 'RFC2079: Uniform Resource Identifier with optional label' "
+                       "EQUALITY caseExactMatch "
+                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
+               NULL, 0,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_labeledURI) },
+
 #ifdef SLAPD_AUTHPASSWD
        { "authPassword", "( 1.3.6.1.4.1.4203.1.3.4 "
                        "NAME 'authPassword' "
@@ -761,7 +991,7 @@ static struct slap_schema_ad_map {
                subschemaAttribute, 0,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
-               offsetof(struct slap_internal_schema, si_ad_authPassword) },
+               offsetof(struct slap_internal_schema, si_ad_authPasswordSchemes) },
 #endif
 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
        { "krbName", "( 1.3.6.1.4.1.250.1.32 "
@@ -775,6 +1005,25 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_krbName) },
 #endif
+
+       { "description", "( 2.5.4.13 NAME 'description' "
+                       "DESC 'RFC2256: descriptive information' "
+                       "EQUALITY caseIgnoreMatch "
+                       "SUBSTR caseIgnoreSubstringsMatch "
+                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )",
+               NULL, 0,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_description) },
+
+       { "seeAlso", "( 2.5.4.34 NAME 'seeAlso' "
+                       "DESC 'RFC2256: DN of related object' "
+                       "SUP distinguishedName )",
+               NULL, 0,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_seeAlso) },
+
        { NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 }
 };
 
@@ -782,12 +1031,13 @@ static AttributeType slap_at_undefined = {
        { "1.1.1", NULL, NULL, 1, NULL,
                NULL, NULL, NULL, NULL,
                0, 0, 0, 1, 3, NULL }, /* LDAPAttributeType */
-       { sizeof("UNDEFINED")-1, "UNDEFINED" }, /* cname */
+       BER_BVC("UNDEFINED"), /* cname */
        NULL, /* sup */
        NULL, /* subtypes */
        NULL, NULL, NULL, NULL, /* matching rules routines */
        NULL, /* syntax (this may need to be defined) */
-       (AttributeTypeSchemaCheckFN *) 0, /* schema check function */
+       NULL, /* schema check function */
+       NULL, /* oidmacro */
        SLAP_AT_ABSTRACT|SLAP_AT_FINAL, /* mask */
        { NULL }, /* next */
        NULL /* attribute description */
@@ -806,6 +1056,14 @@ static struct slap_schema_mr_map {
                offsetof(struct slap_internal_schema, si_mr_caseExactSubstringsMatch) },
        { "distinguishedNameMatch",
                offsetof(struct slap_internal_schema, si_mr_distinguishedNameMatch) },
+       { "dnSubtreeMatch",
+               offsetof(struct slap_internal_schema, si_mr_dnSubtreeMatch) },
+       { "dnOneLevelMatch",
+               offsetof(struct slap_internal_schema, si_mr_dnOneLevelMatch) },
+       { "dnSubordinateMatch",
+               offsetof(struct slap_internal_schema, si_mr_dnSubordinateMatch) },
+       { "dnSuperiorMatch",
+               offsetof(struct slap_internal_schema, si_mr_dnSuperiorMatch) },
        { "integerMatch",
                offsetof(struct slap_internal_schema, si_mr_integerMatch) },
        { "integerFirstComponentMatch",
@@ -829,6 +1087,22 @@ static struct slap_schema_syn_map {
                offsetof(struct slap_internal_schema, si_syn_integer) },
        { "1.3.6.1.4.1.1466.115.121.1.40",
                offsetof(struct slap_internal_schema, si_syn_octetString) },
+       { "1.3.6.1.4.1.1466.115.121.1.3",
+               offsetof(struct slap_internal_schema, si_syn_attributeTypeDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.16",
+               offsetof(struct slap_internal_schema, si_syn_ditContentRuleDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.54",
+               offsetof(struct slap_internal_schema, si_syn_ldapSyntaxDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.30",
+               offsetof(struct slap_internal_schema, si_syn_matchingRuleDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.31",
+               offsetof(struct slap_internal_schema, si_syn_matchingRuleUseDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.35",
+               offsetof(struct slap_internal_schema, si_syn_nameFormDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.37",
+               offsetof(struct slap_internal_schema, si_syn_objectClassDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.17",
+               offsetof(struct slap_internal_schema, si_syn_ditStructureRuleDesc) },
        { NULL, 0 }
 };
 
@@ -892,7 +1166,7 @@ slap_schema_load( void )
                                return LDAP_OTHER;
                        }
 
-                       code = at_add( at, &err );
+                       code = at_add( at, 0, NULL, &err );
                        if ( code ) {
                                fprintf( stderr, "slap_schema_load: AttributeType "
                                        "\"%s\": %s: \"%s\"\n",
@@ -948,8 +1222,7 @@ slap_schema_load( void )
                        }
 
                        /* install custom rule routines */
-                       if( ( (*adp)->ad_type->sat_equality != NULL &&
-                                       syntax == (*adp)->ad_type->sat_equality->smr_syntax ) ||
+                       if( syntax != NULL ||
                                ad_map[i].ssam_mr_convert ||
                                ad_map[i].ssam_mr_normalize ||
                                ad_map[i].ssam_mr_match ||
@@ -959,7 +1232,7 @@ slap_schema_load( void )
                                MatchingRule *mr = ch_malloc( sizeof( MatchingRule ) );
                                *mr = *(*adp)->ad_type->sat_equality;
 
-                               if ( syntax == mr->smr_syntax ) {
+                               if ( syntax != NULL ) {
                                        mr->smr_syntax = (*adp)->ad_type->sat_syntax;
                                }
                                if ( ad_map[i].ssam_mr_convert ) {
@@ -978,6 +1251,7 @@ slap_schema_load( void )
                                        mr->smr_filter = ad_map[i].ssam_mr_filter;
                                }
 
+                               /* FIXME: no-one will free this at exit */
                                (*adp)->ad_type->sat_equality = mr;
                        }
                }
@@ -1006,7 +1280,7 @@ slap_schema_load( void )
                                return LDAP_OTHER;
                        }
 
-                       code = oc_add(oc,0,&err);
+                       code = oc_add(oc,0,NULL,&err);
                        if ( code ) {
                                fprintf( stderr, "slap_schema_load: ObjectClass "
                                        "\"%s\": %s: \"%s\"\n",
@@ -1039,7 +1313,7 @@ slap_schema_load( void )
                }
        }
 
-       slap_at_undefined.sat_syntax = slap_schema.si_syn_distinguishedName;
+       slap_at_undefined.sat_syntax = slap_schema.si_syn_octetString;
        slap_schema.si_at_undefined = &slap_at_undefined;
 
        return LDAP_SUCCESS;
@@ -1147,6 +1421,7 @@ static int subentryObjectClass (
        return LDAP_SUCCESS;
 }
 
+#ifdef LDAP_DYNAMIC_OBJECTS
 static int dynamicObjectClass (
        Backend *be,
        Entry *e,
@@ -1165,6 +1440,7 @@ static int dynamicObjectClass (
 
        return LDAP_SUCCESS;
 }
+#endif /* LDAP_DYNAMIC_OBJECTS */
 
 static int rootDseAttribute (
        Backend *be,
@@ -1287,6 +1563,7 @@ static int administrativeRoleAttribute (
        return LDAP_OBJECT_CLASS_VIOLATION;
 }
 
+#ifdef LDAP_DYNAMIC_OBJECTS
 static int dynamicAttribute (
        Backend *be,
        Entry *e,
@@ -1312,3 +1589,4 @@ static int dynamicAttribute (
 
        return LDAP_SUCCESS;
 }
+#endif /* LDAP_DYNAMIC_OBJECTS */