if ( pretty ) {
rc = pretty( attr->a_desc->ad_type->sat_syntax,
&attr->a_vals[i], &pval, NULL );
+
} else {
rc = validate( attr->a_desc->ad_type->sat_syntax,
&attr->a_vals[i] );
}
if ( rc != LDAP_SUCCESS ) {
- attr->a_nvals = NULL;
- attr_free( attr );
- goto next_attr;
+ /* check if, by chance, it's an undefined objectClass */
+ if ( attr->a_desc == slap_schema.si_ad_objectClass &&
+ oc_bvfind_undef( &attr->a_vals[i] ) != NULL )
+ {
+ ber_dupbv( &pval, &attr->a_vals[i] );
+
+ } else {
+ attr->a_nvals = NULL;
+ attr_free( attr );
+ goto next_attr;
+ }
}
if ( pretty ) {
retry:
rc = ldap_search_ext_s( lc->lc_ld, ndn->bv_val, LDAP_SCOPE_BASE, filter,
- gattr, 0, NULL, NULL, LDAP_NO_LIMIT,
+ at ? gattr : NULL, 0, NULL, NULL, LDAP_NO_LIMIT,
LDAP_NO_LIMIT, &result );
if ( rc != LDAP_SUCCESS ) {
if ( rc == LDAP_SERVER_DOWN && do_retry ) {
return( NULL );
}
+static LDAP_SLIST_HEAD(OCUList, slap_object_class) oc_undef_list
+ = LDAP_SLIST_HEAD_INITIALIZER(&oc_undef_list);
+
+ObjectClass *
+oc_bvfind_undef( struct berval *ocname )
+{
+ ObjectClass *oc = oc_bvfind( ocname );
+
+ if ( oc ) {
+ return oc;
+ }
+
+ LDAP_SLIST_FOREACH( oc, &oc_undef_list, soc_next ) {
+ int d = oc->soc_cname.bv_len - ocname->bv_len;
+
+ if ( d ) {
+ continue;
+ }
+
+ if ( strcasecmp( oc->soc_cname.bv_val, ocname->bv_val ) == 0 ) {
+ break;
+ }
+ }
+
+ if ( oc ) {
+ return oc;
+ }
+
+ oc = ch_malloc( sizeof( ObjectClass ) + ocname->bv_len + 1 );
+ memset( oc, 0, sizeof( ObjectClass ) );
+
+ oc->soc_cname.bv_len = ocname->bv_len;
+ oc->soc_cname.bv_val = (char *)&oc[ 1 ];
+ AC_MEMCPY( oc->soc_cname.bv_val, ocname->bv_val, ocname->bv_len );
+
+ LDAP_SLIST_NEXT( oc, soc_next ) = NULL;
+ LDAP_SLIST_INSERT_HEAD( &oc_undef_list, oc, soc_next );
+
+ return oc;
+}
+
static int
oc_create_required(
ObjectClass *soc,
if (o->soc_allowed) ldap_memfree(o->soc_allowed);
ldap_objectclass_free((LDAPObjectClass *)o);
}
+
+ while( !LDAP_SLIST_EMPTY(&oc_undef_list) ) {
+ o = LDAP_SLIST_FIRST(&oc_undef_list);
+ LDAP_SLIST_REMOVE_HEAD(&oc_undef_list, soc_next);
+
+ ch_free( (ObjectClass *)o );
+ }
}
static int
goto cleanup_attr;
}
- if ( (*ap)->a_desc->ad_type->sat_no_user_mod ) {
+ if ( (*ap)->a_desc->ad_type->sat_no_user_mod
+ && (*ap)->a_desc->ad_type != slap_schema.si_at_undefined )
+ {
goto next_attr;
}
"is not defined in schema\n",
fname, lineno, dst );
+ mapping[0].m_dst_oc = oc_bvfind_undef( &mapping[0].m_dst );
+ if ( mapping[0].m_dst_oc == NULL ) {
+ fprintf( stderr, "%s: line %d: unable to mimic destination objectClass '%s'\n",
+ fname, lineno, dst );
+ return 1;
+ }
+
+#if 0
mapping[0].m_dst_oc = ch_malloc( sizeof( ObjectClass ) );
memset( mapping[0].m_dst_oc, 0, sizeof( ObjectClass ) );
mapping[0].m_dst_oc->soc_cname = mapping[0].m_dst;
mapping[0].m_flags |= RWMMAP_F_FREE_DST;
+#endif
}
mapping[1].m_src_oc = mapping[0].m_dst_oc;
}
}
- 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;