*/
static int replmd_add(struct ldb_module *module, struct ldb_request *req)
{
- struct samldb_msds_intid_persistant *msds_intid_struct;
struct ldb_context *ldb;
struct ldb_control *control;
struct replmd_replicated_request *ac;
if (control) {
control->critical = 0;
}
- if (ldb_dn_compare_base(replmd_private->schema_dn, req->op.add.message->dn) != 0) {
-
- /* Update the usn in the SAMLDB_MSDS_INTID_OPAQUE opaque */
- msds_intid_struct = (struct samldb_msds_intid_persistant *) ldb_get_opaque(ldb, SAMLDB_MSDS_INTID_OPAQUE);
- if (msds_intid_struct) {
- msds_intid_struct->usn = ac->seq_num;
- }
- }
/* go on with the call chain */
return ldb_next_request(module, down_req);
}
static int replmd_modify(struct ldb_module *module, struct ldb_request *req)
{
- struct samldb_msds_intid_persistant *msds_intid_struct;
struct ldb_context *ldb;
struct replmd_replicated_request *ac;
struct ldb_request *down_req;
}
}
- if (!ldb_dn_compare_base(replmd_private->schema_dn, msg->dn)) {
- /* Update the usn in the SAMLDB_MSDS_INTID_OPAQUE opaque */
- msds_intid_struct = (struct samldb_msds_intid_persistant *) ldb_get_opaque(ldb, SAMLDB_MSDS_INTID_OPAQUE);
- if (msds_intid_struct) {
- msds_intid_struct->usn = ac->seq_num;
- }
- }
-
/* go on with the call chain */
return ldb_next_request(module, down_req);
}
msds_intid = generate_random() % 0X3FFFFFFF;
msds_intid += 0x80000000;
msds_intid_struct->msds_intid = msds_intid;
- msds_intid_struct->usn = schema->loaded_usn;
DEBUG(2, ("No samldb_msds_intid_persistant struct, allocating a new one\n"));
} else {
msds_intid = msds_intid_struct->msds_intid;
/* probe id values until unique one is found */
do {
- uint64_t current_usn;
msds_intid++;
if (msds_intid > 0xBFFFFFFF) {
msds_intid = 0x80000001;
}
/*
- * Alternative strategy to a costly (even indexed search) to the
- * database.
- * We search in the schema if we have already this intid (using dsdb_attribute_by_attributeID_id because
- * in the range 0x80000000 0xBFFFFFFFF, attributeID is a DSDB_ATTID_TYPE_INTID).
+ * We search in the schema if we have already this
+ * intid (using dsdb_attribute_by_attributeID_id
+ * because in the range 0x80000000 0xBFFFFFFFF,
+ * attributeID is a DSDB_ATTID_TYPE_INTID).
+ *
* If so generate another random value.
- * If not check if the highest USN in the database for the schema partition is the
- * one that we know.
- * If so it means that's only this ldb context that is touching the schema in the database.
- * If not it means that's someone else has modified the database while we are doing our changes too
- * (this case should be very bery rare) in order to be sure do the search in the database.
+ *
+ * We have to check the DB in case someone else has
+ * modified the database while we are doing our
+ * changes too (this case should be very bery rare) in
+ * order to be sure.
*/
if (dsdb_attribute_by_attributeID_id(schema, msds_intid)) {
msds_intid = generate_random() % 0X3FFFFFFF;
continue;
}
- ret = dsdb_module_load_partition_usn(ac->module, schema_dn,
- ¤t_usn, NULL, NULL);
+
+ ret = dsdb_module_search(ac->module, ac,
+ &ldb_res,
+ schema_dn, LDB_SCOPE_ONELEVEL, NULL,
+ DSDB_FLAG_NEXT_MODULE,
+ ac->req,
+ "(msDS-IntId=%d)", msds_intid);
if (ret != LDB_SUCCESS) {
ldb_debug_set(ldb, LDB_DEBUG_ERROR,
- __location__": Searching for schema USN failed: %s\n",
+ __location__": Searching for msDS-IntId=%d failed - %s\n",
+ msds_intid,
ldb_errstring(ldb));
return ldb_operr(ldb);
}
-
- /* current_usn can be lesser than msds_intid_struct-> if there is
- * uncommited changes.
- */
- if (current_usn > msds_intid_struct->usn) {
- /* oups something has changed, someone/something
- * else is modifying or has modified the schema
- * we'd better check this intid is the database directly
- */
-
- DEBUG(2, ("Schema has changed, searching the database for the unicity of %d\n",
- msds_intid));
-
- ret = dsdb_module_search(ac->module, ac,
- &ldb_res,
- schema_dn, LDB_SCOPE_ONELEVEL, NULL,
- DSDB_FLAG_NEXT_MODULE,
- ac->req,
- "(msDS-IntId=%d)", msds_intid);
- if (ret != LDB_SUCCESS) {
- ldb_debug_set(ldb, LDB_DEBUG_ERROR,
- __location__": Searching for msDS-IntId=%d failed - %s\n",
- msds_intid,
- ldb_errstring(ldb));
- return ldb_operr(ldb);
- }
- id_exists = (ldb_res->count > 0);
- talloc_free(ldb_res);
- } else {
- id_exists = 0;
- }
+ id_exists = (ldb_res->count > 0);
+ talloc_free(ldb_res);
} while(id_exists);
msds_intid_struct->msds_intid = msds_intid;