static int objectguid_modify(struct ldb_module *module, struct ldb_request *req)
{
	struct ldb_context *ldb;
	struct ldb_request *down_req;
	struct ldb_message *msg;
	struct ldb_message_element *el;
	int ret;
	time_t t = time(NULL);
	uint64_t seq_num;
	struct og_context *ac;

	ldb = ldb_module_get_ctx(module);

	ldb_debug(ldb, LDB_DEBUG_TRACE, "objectguid_modify_record\n");

	/* do not manipulate our control entries */
	if (ldb_dn_is_special(req->op.mod.message->dn)) {
		return ldb_next_request(module, req);
	}

	el = ldb_msg_find_element(req->op.mod.message, "objectGUID");
	if (el != NULL) {
		ldb_set_errstring(ldb,
				  "objectguid: objectGUID must not be specified!");
		return LDB_ERR_CONSTRAINT_VIOLATION;
	}

	ac = talloc(req, struct og_context);
	if (ac == NULL) {
		return ldb_oom(ldb);
	}
	ac->module = module;
	ac->req = req;

	/* we have to copy the message as the caller might have it as a const */
	msg = ldb_msg_copy_shallow(ac, req->op.mod.message);
	if (msg == NULL) {
		return ldb_operr(ldb);
	}

	if (add_time_element(msg, "whenChanged", t) != LDB_SUCCESS) {
		return ldb_operr(ldb);
	}

	/* Get a sequence number from the backend */
	ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num);
	if (ret == LDB_SUCCESS) {
		if (add_uint64_element(ldb, msg, "uSNChanged",
				       seq_num) != LDB_SUCCESS) {
			return ldb_operr(ldb);
		}
	}

	ret = ldb_build_mod_req(&down_req, ldb, ac,
				msg,
				req->controls,
				req, dsdb_next_callback,
				req);
	LDB_REQ_SET_LOCATION(down_req);
	if (ret != LDB_SUCCESS) {
		return ret;
	}

	/* go on with the call chain */
	return ldb_next_request(module, down_req);
}
static int objectguid_modify(struct ldb_module *module, struct ldb_request *req)
{
	struct ldb_context *ldb;
	struct ldb_request *down_req;
	struct ldb_message *msg;
	struct ldb_message_element *el;
	int ret;
	time_t t = time(NULL);
	uint64_t seq_num;
	struct og_context *ac;

	ldb = ldb_module_get_ctx(module);

	ldb_debug(ldb, LDB_DEBUG_TRACE, "objectguid_modify_record\n");

	 
	if (ldb_dn_is_special(req->op.mod.message->dn)) {
		return ldb_next_request(module, req);
	}

	el = ldb_msg_find_element(req->op.mod.message, "objectGUID");
	if (el != NULL) {
		ldb_set_errstring(ldb,
				  "objectguid: objectGUID must not be specified!");
		return LDB_ERR_CONSTRAINT_VIOLATION;
	}

	ac = talloc(req, struct og_context);
	if (ac == NULL) {
		return ldb_oom(ldb);
	}
	ac->module = module;
	ac->req = req;

	 
	msg = ldb_msg_copy_shallow(ac, req->op.mod.message);
	if (msg == NULL) {
		return ldb_operr(ldb);
	}

	if (add_time_element(msg, "whenChanged", t) != LDB_SUCCESS) {
		return ldb_operr(ldb);
	}

	 
	ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num);
	if (ret == LDB_SUCCESS) {
		if (add_uint64_element(ldb, msg, "uSNChanged",
				       seq_num) != LDB_SUCCESS) {
			return ldb_operr(ldb);
		}
	}

	ret = ldb_build_mod_req(&down_req, ldb, ac,
				msg,
				req->controls,
				req, dsdb_next_callback,
				req);
	LDB_REQ_SET_LOCATION(down_req);
	if (ret != LDB_SUCCESS) {
		return ret;
	}

	 
	return ldb_next_request(module, down_req);
}