- slap_compose_sync_cookie( NULL, &mc, &maxcsn, -1, -1 );
-
- if ( SLAP_LASTMOD(be) && replica_promotion ) {
- if ( provider_subentry || update_ctxcsn == SLAP_TOOL_CTXCSN_BATCH ||
- !LDAP_SLIST_EMPTY( &consumer_subentry )) {
- build_new_dn( &ctxcsn_ndn, &be->be_nsuffix[0],
- (struct berval *)&slap_ldapsync_cn_bv, NULL );
- ctxcsn_id = be->be_dn2id_get( be, &ctxcsn_ndn );
-
- if ( ctxcsn_id == NOID ) {
- ctxcsn_e = slap_create_context_csn_entry( be, &maxcsn );
- if ( !dryrun ) {
- ctxcsn_id = be->be_entry_put( be, ctxcsn_e, &bvtext );
- if( ctxcsn_id == NOID ) {
- fprintf( stderr, "%s: could not add ctxcsn subentry\n",
- progname);
- rc = EXIT_FAILURE;
- }
- if ( verbose ) {
- fprintf( stderr, "added: \"%s\" (%08lx)\n",
- ctxcsn_e->e_dn, (long) ctxcsn_id );
- }
- } else {
- if ( verbose ) {
- fprintf( stderr, "(dry) added: \"%s\"\n", ctxcsn_e->e_dn );
- }
- }
- entry_free( ctxcsn_e );
- } else {
- ret = be->be_id2entry_get( be, ctxcsn_id, &ctxcsn_e );
- if ( ret == LDAP_SUCCESS ) {
- attr = attr_find( ctxcsn_e->e_attrs,
- slap_schema.si_ad_contextCSN );
- AC_MEMCPY( attr->a_vals[0].bv_val, maxcsn.bv_val, maxcsn.bv_len );
- attr->a_vals[0].bv_val[maxcsn.bv_len] = '\0';
- attr->a_vals[0].bv_len = maxcsn.bv_len;
- if ( !dryrun ) {
- ctxcsn_id = be->be_entry_modify( be, ctxcsn_e, &bvtext );
- if( ctxcsn_id == NOID ) {
- fprintf( stderr, "%s: could not modify ctxcsn "
- "subentry\n", progname);
- rc = EXIT_FAILURE;
- }
- if ( verbose ) {
- fprintf( stderr, "modified: \"%s\" (%08lx)\n",
- ctxcsn_e->e_dn, (long) ctxcsn_id );
- }
- } else {
- if ( verbose ) {
- fprintf( stderr, "(dry) modified: \"%s\"\n",
- ctxcsn_e->e_dn );
- }
- }
- } else {
- fprintf( stderr, "%s: could not modify ctxcsn subentry\n",
- progname);
- rc = EXIT_FAILURE;
- }
- }
- }
- } else if ( SLAP_LASTMOD(be) && replica_demotion &&
- ( update_ctxcsn == SLAP_TOOL_CTXCSN_BATCH ||
- provider_subentry )) {
-
- ber_dupbv( &slap_syncrepl_bv, (struct berval *) &slap_syncrepl_bvc );
- ber_dupbv( &slap_syncrepl_cn_bv,
- (struct berval *) &slap_syncrepl_cn_bvc );
-
- if ( replica_id_list == NULL ) {
- replica_id_list = ch_calloc( 2, sizeof( int ));
- replica_id_list[0] = 0;
- replica_id_list[1] = -1;
- }