#define LDAP_CONTROL_SYNC_DONE "1.3.6.1.4.1.4203.666.5.8"
#define LDAP_SYNC_INFO "1.3.6.1.4.1.4203.666.10.2"
-#define LDAP_SYNC_REFRESH_DONE 0
-#define LDAP_SYNC_NEW_COOKIE 1
+#define LDAP_SYNC_NEW_COOKIE 0
+#define LDAP_SYNC_STATE_MODE_DONE 1
+#define LDAP_SYNC_LOG_MODE_DONE 2
+#define LDAP_SYNC_REFRESH_DONE 3
+
+#define LDAP_SYNC_STATE_MODE 0
+#define LDAP_SYNC_LOG_MODE 1
+#define LDAP_SYNC_PERSIST_MODE 2
#define LDAP_SYNC_PRESENT 0
#define LDAP_SYNC_ADD 1
AttributeName *attrs;
#ifdef LDAP_SYNC
- Filter cookief, csnfnot, csnfeq, csnfand, csnfge;
- AttributeAssertion aa_ge, aa_eq;
+ Filter cookief, csnfnot, csnfeq, csnfand, csnfge, omitcsnf, omitcsnfle;
+ AttributeAssertion aa_ge, aa_eq, aa_le;
int entry_count = 0;
#if 0
struct berval entrycsn_bv = { 0, NULL };
if (!IS_PSEARCH) {
#ifdef LDAP_SYNC
if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
+ rs->sr_err = LDAP_SUCCESS;
+ rs->sr_rspoid = LDAP_SYNC_INFO;
+ rs->sr_ctrls = NULL;
+ bdb_send_ldap_intermediate( sop, rs,
+ LDAP_SYNC_STATE_MODE_DONE, &latest_entrycsn_bv );
+
+ /* If changelog is supported, this is where to process it */
+
if ( sop->o_sync_mode & SLAP_SYNC_PERSIST ) {
/* refreshAndPersist mode */
- rs->sr_err = LDAP_SUCCESS;
- rs->sr_rspoid = LDAP_SYNC_INFO;
- rs->sr_ctrls = NULL;
bdb_send_ldap_intermediate( sop, rs,
- LDAP_SYNC_REFRESH_DONE, &latest_entrycsn_bv );
+ LDAP_SYNC_LOG_MODE_DONE, &latest_entrycsn_bv );
} else {
/* refreshOnly mode */
bdb_build_sync_done_ctrl( sop, rs, ctrls,
si->slimit = -1;
si->syncUUID = NULL;
si->syncUUID_ndn = NULL;
+ si->sync_mode = LDAP_SYNC_STATE_MODE;
si->presentlist = NULL;
LDAP_LIST_INIT( &si->nonpresentlist );
struct berval *syncUUID;
struct berval *syncUUID_ndn;
Avlnode *presentlist;
+ int sync_mode;
LDAP_LIST_HEAD(np, nonpresent_entry) nonpresentlist;
} syncinfo_t;
return NULL;
}
+ si->sync_mode = LDAP_SYNC_STATE_MODE;
+
/* Init connection to master */
rc = ldap_initialize( &ld, si->provideruri );
if ( syncCookie.bv_len ) {
syncrepl_updateCookie( si, ld, &op, &psub, &syncCookie);
}
- syncrepl_del_nonpresent( ld, &op );
+ if ( si->sync_mode == LDAP_SYNC_STATE_MODE )
+ syncrepl_del_nonpresent( ld, &op );
if ( ctrl_ber )
ber_free( ctrl_ber, 1 );
goto done;
res_ber = ber_init( retdata );
ber_scanf( res_ber, "{e" /*"}"*/, &syncstate );
- if ( syncstate == LDAP_SYNC_REFRESH_DONE ) {
+ if ( syncstate == LDAP_SYNC_STATE_MODE_DONE ) {
syncrepl_del_nonpresent( ld, &op );
- } else if ( syncstate != LDAP_SYNC_NEW_COOKIE ) {
+ si->sync_mode = LDAP_SYNC_LOG_MODE;
+ } else if ( syncstate == LDAP_SYNC_LOG_MODE_DONE ) {
+ si->sync_mode = LDAP_SYNC_PERSIST_MODE;
+ } else if ( syncstate == LDAP_SYNC_REFRESH_DONE ) {
+ si->sync_mode = LDAP_SYNC_PERSIST_MODE;
+ } else if ( syncstate != LDAP_SYNC_NEW_COOKIE ||
+ syncstate != LDAP_SYNC_LOG_MODE_DONE ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
"do_syncrepl : unknown sync info\n", 0, 0, 0 );
cb.sc_response = null_callback;
cb.sc_private = si;
- if ( rc == LDAP_SUCCESS && si->syncUUID_ndn ) {
+ if ( rc == LDAP_SUCCESS && si->syncUUID_ndn && si->sync_mode != LDAP_SYNC_LOG_MODE ) {
op->o_req_dn = *si->syncUUID_ndn;
op->o_req_ndn = *si->syncUUID_ndn;
op->o_tag = LDAP_REQ_DELETE;
}
case LDAP_SYNC_DELETE :
- /* Already deleted */
+ if ( si->sync_mode == LDAP_SYNC_LOG_MODE ) {
+ op->o_req_dn = *si->syncUUID_ndn;
+ op->o_req_ndn = *si->syncUUID_ndn;
+ op->o_tag = LDAP_REQ_DELETE;
+ rc = be->be_delete( op, &rs );
+ }
+ /* Already deleted otherwise */
return 1;
default :
exit $RC
fi
-echo "Waiting 30 seconds for syncrepl to receive changes..."
-sleep 30
+echo "Waiting 60 seconds for syncrepl to receive changes..."
+sleep 60
echo "Using ldapmodify to modify master directory..."
EOMODS
-echo "Waiting 30 seconds for syncrepl to receive changes..."
-sleep 30
+echo "Waiting 60 seconds for syncrepl to receive changes..."
+sleep 60
echo "Using ldapsearch to read all the entries from the master..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \