goto done;
#if defined( SLAPD_SCHEMA_DN )
- } else if ( strcasecmp( e->e_ndn, SLAPD_SCHEMA_DN ) == 0 ) {
+ } else if ( bvmatch( &e->e_nname, &global_schemandn ) ) {
send_ldap_result( conn, op, rc = LDAP_ALREADY_EXISTS,
NULL, "subschema subentry already exists",
NULL, NULL );
#ifdef SLAPD_SCHEMA_DN
if ( opattrs || ( attrs &&
ad_inlist( slap_schema.si_ad_subschemaSubentry, attrs )) ) {
- *ap = slap_operational_subschemaSubentry();
+ *ap = slap_operational_subschemaSubentry( be );
ap = &(*ap)->a_next;
}
#endif
goto cleanup;
}
- } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
+#ifdef SLAPD_SCHEMA_DN
+ } else if ( bvmatch( &ndn, &global_schemandn ) ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ARGS,
"do_compare: dn (%s) attr(%s) value (%s)\n",
rc = 0;
goto cleanup;
}
+#endif /* SLAPD_SCHEMA_DN */
}
if( entry ) {
#ifdef SLAPD_SCHEMA_DN
- } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
+ } else if ( bvmatch( &ndn, &global_schemandn ) ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_delete: conn %d: "
"Attempt to delete subschema subentry.\n", conn->c_connid, 0, 0 );
goto cleanup;
#if defined( SLAPD_SCHEMA_DN )
- } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
+ } else if ( bvmatch( &ndn, &global_schemandn ) ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
"do_modify: attempt to modify subschema subentry.\n" , 0, 0, 0 );
--- /dev/null
+/* operational.c - routines to deal with on-the-fly operational attrs */
+/*
+ * Copyright 2001-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include "slap.h"
+
+/*
+ * helpers for on-the-fly operational attribute generation
+ */
+
+#ifdef SLAPD_SCHEMA_DN
+Attribute *
+slap_operational_subschemaSubentry( Backend *be )
+{
+ Attribute *a;
+
+ /* The backend wants to take care of it */
+ if ( be && be->be_schemadn.bv_val )
+ return NULL;
+
+ a = ch_malloc( sizeof( Attribute ) );
+ a->a_desc = slap_schema.si_ad_subschemaSubentry;
+
+ a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
+ ber_dupbv( a->a_vals, &global_schemadn );
+ a->a_vals[1].bv_val = NULL;
+
+ a->a_next = NULL;
+ a->a_flags = 0;
+
+ return a;
+}
+#endif /* SLAPD_SCHEMA_DN */
+
+Attribute *
+slap_operational_hasSubordinate( int hs )
+{
+ Attribute *a;
+
+ a = ch_malloc( sizeof( Attribute ) );
+ a->a_desc = slap_schema.si_ad_hasSubordinates;
+
+ a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
+ ber_str2bv( hs ? "TRUE" : "FALSE",
+ hs ? sizeof("TRUE")-1 : sizeof("FALSE")-1,
+ 1, a->a_vals );
+ a->a_vals[1].bv_val = NULL;
+
+ a->a_next = NULL;
+ a->a_flags = 0;
+
+ return a;
+}
+
*/
#define dn_match(dn1, dn2) ( ber_bvcmp((dn1), (dn2)) == 0 )
-#define bvmatch(bv1, bv2) ( ((bv1)->bv_len == (bv2)->bv_len) && (memcmp((bv1)->bv_val, (bv2)->bv_val, (bv1)->bv_len) == 0) )
+#define bvmatch(bv1, bv2) ( ((bv1)->bv_len == (bv2)->bv_len) && memcmp((bv1)->bv_val, (bv2)->bv_val, (bv1)->bv_len) == 0 )
LDAP_SLAPD_V( const struct berval ) slap_empty_bv;
/*
* operational.c
*/
-LDAP_SLAPD_F (Attribute *) slap_operational_subschemaSubentry( void );
+LDAP_SLAPD_F (Attribute *) slap_operational_subschemaSubentry( Backend *be );
LDAP_SLAPD_F (Attribute *) slap_operational_hasSubordinate( int has );
/*
LDAP_SLAPD_V (struct berval) default_search_base;
LDAP_SLAPD_V (struct berval) default_search_nbase;
+#ifdef SLAPD_SCHEMA_DN
+LDAP_SLAPD_V (struct berval) global_schemadn;
+LDAP_SLAPD_V (struct berval) global_schemandn;
+#endif
+
LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) num_sent_mutex;
LDAP_SLAPD_V (unsigned long) num_bytes_sent;
LDAP_SLAPD_V (unsigned long) num_pdu_sent;
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
e->e_attrs = NULL;
- ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1, &e->e_name);
- (void) dnNormalize2( NULL, &e->e_name, &e->e_nname );
+ /* backend-specific schema info should be created by the
+ * backend itself
+ */
+ ber_dupbv( &e->e_name, &global_schemadn );
+ ber_dupbv( &e->e_nname, &global_schemandn );
e->e_private = NULL;
vals[0].bv_val = "subentry";
{
int rc;
AttributeDescription *desc = NULL;
- struct berval rdn = { sizeof(SLAPD_SCHEMA_DN)-1,
- SLAPD_SCHEMA_DN };
+ struct berval rdn = global_schemadn;
vals[0].bv_val = strchr( rdn.bv_val, '=' );
if( vals[0].bv_val == NULL ) {
}
#if defined( SLAPD_SCHEMA_DN )
- else if ( strcasecmp( nbase.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
+ else if ( bvmatch( &nbase, &global_schemandn ) ) {
/* check restrictions */
rc = backend_check_restrictions( NULL, conn, op, NULL, &text ) ;
if( rc != LDAP_SUCCESS ) {
BerVarray be_suffix; /* the DN suffixes of data in this backend */
BerVarray be_nsuffix; /* the normalized DN suffixes in this backend */
BerVarray be_suffixAlias; /* pairs of DN suffix aliases and deref values */
+#ifdef SLAPD_SCHEMA_DN
+ struct berval be_schemadn; /* per-backend subschema subentry DN */
+ struct berval be_schemandn; /* normalized subschema DN */
+#endif
struct berval be_rootdn; /* the magic "root" name (DN) for this db */
struct berval be_rootndn; /* the magic "root" normalized name (DN) for this db */
struct berval be_rootpw; /* the magic "root" password for this db */
}
Attribute *
-slap_operational_subschemaSubentry( void )
+slap_operational_subschemaSubentry( Backend *be )
{
return NULL;
}