+typedef struct findcookie {
+ ID fid;
+ struct berval fdn;
+} findcookie;
+
+static int
+findbase_cb( Operation *op, SlapReply *rs )
+{
+ slap_callback *sc = op->o_callback;
+
+ if ( rs->sr_type == REP_SEARCH && rs->sr_err == LDAP_SUCCESS ) {
+ findcookie *fc = sc->sc_private;
+ fc->fid = rs->sr_entry->e_id;
+ ber_dupbv_x( &fc->fdn, &rs->sr_entry->e_nname, op->o_tmpmemctx );
+ }
+ return LDAP_SUCCESS;
+}
+
+static int
+syncprov_findbase( Operation *op, syncops *ss, findcookie *fc )
+{
+ slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
+ syncprov_info_t *si = on->on_bi.bi_private;
+
+ slap_callback cb;
+ Operation fop;
+ SlapReply frs = { REP_RESULT };
+ int rc;
+
+ fop = *op;
+
+ cb.sc_response = findbase_cb;
+ cb.sc_private = fc;
+
+ fop.o_callback = &cb;
+ fop.o_tag = LDAP_REQ_SEARCH;
+ fop.ors_scope = LDAP_SCOPE_BASE;
+ fop.ors_deref = ss->s_op->ors_deref;
+ fop.ors_slimit = 1;
+ fop.ors_tlimit = SLAP_NO_LIMIT;
+ fop.ors_attrs = slap_anlist_no_attrs;
+ fop.ors_attrsonly = 1;
+ fop.ors_filter = ss->s_op->ors_filter;
+ fop.ors_filterstr = ss->s_op->ors_filterstr;
+
+ fop.o_req_ndn = ss->s_op->o_req_ndn;
+
+ rc = fop.o_bd->be_search( &fop, &frs );
+
+ if ( fc->fid == ss->s_eid ) return LDAP_SUCCESS;
+
+ /* If entryID has changed, then the base of this search has
+ * changed. Invalidate the psearch.
+ */
+ return LDAP_NO_SUCH_OBJECT;
+}