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>
22 schema_info( Entry **entry, const char **text )
24 AttributeDescription *ad_structuralObjectClass
25 = slap_schema.si_ad_structuralObjectClass;
26 AttributeDescription *ad_objectClass
27 = slap_schema.si_ad_objectClass;
28 AttributeDescription *ad_createTimestamp
29 = slap_schema.si_ad_createTimestamp;
30 AttributeDescription *ad_modifyTimestamp
31 = slap_schema.si_ad_modifyTimestamp;
34 struct berval vals[5];
36 e = (Entry *) ch_calloc( 1, sizeof(Entry) );
39 /* backend-specific schema info should be created by the
42 ber_dupbv( &e->e_name, &global_schemadn );
43 ber_dupbv( &e->e_nname, &global_schemandn );
46 vals[0].bv_val = "subentry";
47 vals[0].bv_len = sizeof("subentry")-1;
48 attr_merge_one( e, ad_structuralObjectClass, vals );
50 vals[0].bv_val = "top";
51 vals[0].bv_len = sizeof("top")-1;
52 vals[1].bv_val = "subentry";
53 vals[1].bv_len = sizeof("subentry")-1;
54 vals[2].bv_val = "subschema";
55 vals[2].bv_len = sizeof("subschema")-1;
56 vals[3].bv_val = "extensibleObject";
57 vals[3].bv_len = sizeof("extensibleObject")-1;
58 vals[4].bv_val = NULL;
59 attr_merge( e, ad_objectClass, vals );
63 AttributeDescription *desc = NULL;
64 struct berval rdn = global_schemadn;
65 vals[0].bv_val = strchr( rdn.bv_val, '=' );
67 if( vals[0].bv_val == NULL ) {
68 *text = "improperly configured subschema subentry";
73 vals[0].bv_len = rdn.bv_len - (vals[0].bv_val - rdn.bv_val);
74 rdn.bv_len -= vals[0].bv_len + 1;
76 rc = slap_bv2ad( &rdn, &desc, text );
78 if( rc != LDAP_SUCCESS ) {
80 *text = "improperly configured subschema subentry";
84 attr_merge_one( e, desc, vals );
89 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
92 * According to RFC 2251:
94 Servers SHOULD provide the attributes createTimestamp and
95 modifyTimestamp in subschema entries, in order to allow clients to
96 maintain their caches of schema information.
98 * to be conservative, we declare schema created
99 * AND modified at server startup time ...
102 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
103 ltm = gmtime( &starttime );
104 lutil_gentime( timebuf, sizeof(timebuf), ltm );
105 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
107 vals[0].bv_val = timebuf;
108 vals[0].bv_len = strlen( timebuf );
110 attr_merge_one( e, ad_createTimestamp, vals );
111 attr_merge_one( e, ad_modifyTimestamp, vals );
114 if ( syn_schema_info( e )
115 || mr_schema_info( e )
116 || mru_schema_info( e )
117 || at_schema_info( e )
118 || oc_schema_info( e )
119 || cr_schema_info( e ) )
121 /* Out of memory, do something about it */
123 *text = "out of memory";