static int extended_store_replace(struct extended_dn_context *ac,
TALLOC_CTX *callback_mem_ctx,
+ struct ldb_dn *self_dn,
struct ldb_val *plain_dn,
bool is_delete,
const struct dsdb_attribute *schema_attr)
return LDB_ERR_INVALID_DN_SYNTAX;
}
+ if (self_dn != NULL) {
+ ret = ldb_dn_compare(self_dn, os->dsdb_dn->dn);
+ if (ret == 0) {
+ /*
+ * If this is a reference to the object
+ * itself during an 'add', we won't
+ * be able to find the object.
+ */
+ talloc_free(os);
+ return LDB_SUCCESS;
+ }
+ }
+
if (is_delete && !ldb_dn_has_extended(os->dsdb_dn->dn)) {
/* NO need to figure this DN out, this element is
* going to be deleted anyway, and becuase it's not
/* Re-calculate el */
el = &ac->new_req->op.add.message->elements[i];
for (j = 0; j < el->num_values; j++) {
- ret = extended_store_replace(ac, ac->new_req, &el->values[j],
+ ret = extended_store_replace(ac, ac->new_req,
+ req->op.add.message->dn,
+ &el->values[j],
false, schema_attr);
if (ret != LDB_SUCCESS) {
return ret;
* input of an extended DN */
bool is_delete = (LDB_FLAG_MOD_TYPE(el->flags) == LDB_FLAG_MOD_DELETE);
- ret = extended_store_replace(ac, ac->new_req, &el->values[j],
+ ret = extended_store_replace(ac, ac->new_req,
+ NULL, /* self_dn to be ignored */
+ &el->values[j],
is_delete, schema_attr);
if (ret != LDB_SUCCESS) {
talloc_free(ac);