static int samldb_generate_next_mapiid(struct samldb_ctx *ac,
				       struct dsdb_schema *schema,
				       int32_t *next_mapiid)
{
	int ret;
	struct ldb_context *ldb;
	struct ldb_dn *schema_dn;
	bool mapiid_used = true;

	/* Windows' generation seems to start about here */
	*next_mapiid = 60000;

	ldb = ldb_module_get_ctx(ac->module);
	schema_dn = ldb_get_schema_basedn(ldb);

	while (mapiid_used) {
		*next_mapiid += 1;
		ret = samldb_check_mapiid_used(ac, schema,
					       schema_dn, ldb,
					       *next_mapiid, &mapiid_used);
		if (ret != LDB_SUCCESS) {
			return ret;
		}
	}

	return LDB_SUCCESS;
}
static int samldb_generate_next_mapiid(struct samldb_ctx *ac,
				       struct dsdb_schema *schema,
				       int32_t *next_mapiid)
{
	int ret;
	struct ldb_context *ldb;
	struct ldb_dn *schema_dn;
	bool mapiid_used = true;

	 
	*next_mapiid = 60000;

	ldb = ldb_module_get_ctx(ac->module);
	schema_dn = ldb_get_schema_basedn(ldb);

	while (mapiid_used) {
		*next_mapiid += 1;
		ret = samldb_check_mapiid_used(ac, schema,
					       schema_dn, ldb,
					       *next_mapiid, &mapiid_used);
		if (ret != LDB_SUCCESS) {
			return ret;
		}
	}

	return LDB_SUCCESS;
}