1 /* schema.c - routines to manage schema definitions */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/string.h>
14 #include <ac/socket.h>
20 #if defined( SLAPD_SCHEMA_DN )
23 schema_info( Entry **entry, const char **text )
25 AttributeDescription *ad_structuralObjectClass
26 = slap_schema.si_ad_structuralObjectClass;
27 AttributeDescription *ad_objectClass
28 = slap_schema.si_ad_objectClass;
31 struct berval vals[2];
33 vals[1].bv_val = NULL;
35 e = (Entry *) ch_calloc( 1, sizeof(Entry) );
38 /* backend-specific schema info should be created by the
41 ber_dupbv( &e->e_name, &global_schemadn );
42 ber_dupbv( &e->e_nname, &global_schemandn );
45 vals[0].bv_val = "subentry";
46 vals[0].bv_len = sizeof("subentry")-1;
47 attr_merge( e, ad_structuralObjectClass, vals );
49 vals[0].bv_val = "top";
50 vals[0].bv_len = sizeof("top")-1;
51 attr_merge( e, ad_objectClass, vals );
53 vals[0].bv_val = "subentry";
54 vals[0].bv_len = sizeof("subentry")-1;
55 attr_merge( e, ad_objectClass, vals );
57 vals[0].bv_val = "subschema";
58 vals[0].bv_len = sizeof("subschema")-1;
59 attr_merge( e, ad_objectClass, vals );
61 vals[0].bv_val = "extensibleObject";
62 vals[0].bv_len = sizeof("extensibleObject")-1;
63 attr_merge( e, ad_objectClass, vals );
67 AttributeDescription *desc = NULL;
68 struct berval rdn = global_schemadn;
69 vals[0].bv_val = strchr( rdn.bv_val, '=' );
71 if( vals[0].bv_val == NULL ) {
72 *text = "improperly configured subschema subentry";
77 vals[0].bv_len = rdn.bv_len - (vals[0].bv_val - rdn.bv_val);
78 rdn.bv_len -= vals[0].bv_len + 1;
80 rc = slap_bv2ad( &rdn, &desc, text );
82 if( rc != LDAP_SUCCESS ) {
84 *text = "improperly configured subschema subentry";
88 attr_merge( e, desc, vals );
91 if ( syn_schema_info( e )
92 || mr_schema_info( e )
93 || mru_schema_info( e )
94 || at_schema_info( e )
95 || oc_schema_info( e ) )
97 /* Out of memory, do something about it */
99 *text = "out of memory";