- e = change;
- fprintf( fp, "changetype: add\n" );
- ldap_pvt_thread_mutex_lock( &entry2str_mutex );
- tmp = entry2str( e, &len, 0 );
- while ( (tmp = strchr( tmp, '\n' )) != NULL ) {
- tmp++;
- if ( ! isspace( (unsigned char) *tmp ) )
- break;
+ for ( a = op->ora_e->e_attrs ; a != NULL; a=a->a_next ) {
+ if ( ri && ri->ri_attrs ) {
+ int is_in = ad_inlist( a->a_desc, ri->ri_attrs );
+
+ /* skip if:
+ * 1) the attribute is not in the list,
+ * and it's not an exclusion list
+ * 2) the attribute is in the list
+ * and it's an exclusion list,
+ * and either the objectClass attribute
+ * has already been dealt with or
+ * this is not the objectClass attr
+ */
+ if ( ( !is_in && !ri->ri_exclude )
+ || ( ( is_in && ri->ri_exclude )
+ && ( !ocs || a->a_desc != slap_schema.si_ad_objectClass ) ) )
+ {
+ continue;
+ }
+
+ /* If the list includes objectClass names,
+ * only include those classes in the
+ * objectClass attribute
+ */
+ if ( ocs && a->a_desc == slap_schema.si_ad_objectClass ) {
+ int i;
+
+ if ( ocs == -1 ) ocs = 0;
+
+ for ( i=0; a->a_vals[i].bv_val; i++ ) {
+ int match = 0;
+ for ( an = ri->ri_attrs; an->an_name.bv_val; an++ ) {
+ if ( an->an_oc ) {
+ struct berval bv = an->an_name;
+
+ ocs = 1;
+ match |= an->an_oc_exclude;
+
+ switch ( bv.bv_val[ 0 ] ) {
+ case '@':
+ case '+':
+ case '!':
+ bv.bv_val++;
+ bv.bv_len--;
+ break;
+ }
+
+ if ( a->a_vals[i].bv_len == bv.bv_len
+ && !strcasecmp(a->a_vals[i].bv_val,
+ bv.bv_val ) )
+ {
+ match = !an->an_oc_exclude;
+ break;
+ }
+ }
+ }
+ if ( !ocs ) break;
+
+ match ^= ri->ri_exclude;
+ if ( match ) {
+ if ( dohdr ) {
+ rephdr( ri, op, fp, now );
+ fprintf( fp, "changetype: add\n" );
+ dohdr = 0;
+ }
+ vals[0] = a->a_nvals[i];
+ print_vals( fp, &a->a_desc->ad_cname, vals );
+ }
+ }
+ if ( ocs ) continue;
+ }
+ }
+ if ( dohdr ) {
+ rephdr( ri, op, fp, now );
+ fprintf( fp, "changetype: add\n" );
+ dohdr = 0;
+ }
+ print_vals( fp, &a->a_desc->ad_cname, a->a_vals );