- if ( rc == EXIT_SUCCESS && update_ctxcsn && !dryrun && sid != SLAP_SYNC_SID_MAX + 1 ) {
- ctxcsn_id = be->be_dn2id_get( be, be->be_nsuffix );
- if ( ctxcsn_id == NOID ) {
- fprintf( stderr, "%s: context entry is missing\n", progname );
- rc = EXIT_FAILURE;
- } else {
- ctxcsn_e = be->be_entry_get( be, ctxcsn_id );
- if ( ctxcsn_e != NULL ) {
- attr = attr_find( ctxcsn_e->e_attrs, slap_schema.si_ad_contextCSN );
- if ( attr ) {
- int i;
-
- for ( i = 0; !BER_BVISNULL( &attr->a_vals[ i ] ); i++ ) {
- struct berval nsid;
-
- rc = mr_csnsid->smr_normalize( SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
- NULL, NULL, &attr->a_nvals[ i ], &nsid, NULL );
-
- /* must succeed, since it passed
- * validation/normalization */
- assert( rc == LDAP_SUCCESS );
-
- rc = lutil_atoulx( &sid, nsid.bv_val, 16 );
- ber_memfree( nsid.bv_val );
-
- if ( rc ) {
- Debug( LDAP_DEBUG_ANY,
- "%s: unable to extract SID "
- "from #%d contextCSN=%s\n",
- progname, i,
- attr->a_nvals[ i ].bv_val );
- continue;
- }
-
- if ( maxcsn[ sid ].bv_len == 0 ) {
- match = -1;
-
- } else {
- value_match( &match, slap_schema.si_ad_entryCSN,
- slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
- SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
- &maxcsn[ sid ], &attr->a_nvals[i], &text );
- }
-
- if ( match < 0 ) {
- AC_MEMCPY( maxcsn[ sid ].bv_val,
- attr->a_nvals[ i ].bv_val,
- attr->a_nvals[ i ].bv_len );
- maxcsn[ sid ].bv_val[ attr->a_nvals[ i ].bv_len ] = '\0';
- maxcsn[ sid ].bv_len = attr->a_nvals[ i ].bv_len;
- }
- }
-
-#if 0
- if ( attr->a_nvals && attr->a_nvals != attr->a_vals ) {
- ber_bvarray_free( attr->a_nvals );
- }
- ber_bvarray_free( attr->a_vals );
-#endif
-
- attr->a_vals = NULL;
- attr->a_nvals = NULL;
- }