return status;
}
+struct idmap_autorid_fetch_config_state {
+ TALLOC_CTX *mem_ctx;
+ char *configstr;
+ NTSTATUS status;
+};
+
+static void idmap_autorid_config_parser(TDB_DATA key, TDB_DATA value,
+ void *private_data)
+{
+ struct idmap_autorid_fetch_config_state *state;
+
+ state = (struct idmap_autorid_fetch_config_state *)private_data;
+
+ state->configstr = talloc_zero_array(state->mem_ctx, char, value.dsize+1);
+ if (state->configstr == NULL) {
+ state->status = NT_STATUS_NO_MEMORY;
+ return;
+ }
+
+ memcpy(state->configstr, value.dptr, value.dsize);
+ state->status = NT_STATUS_OK;
+}
+
+NTSTATUS idmap_autorid_getconfigstr(struct db_context *db, TALLOC_CTX *mem_ctx,
+ char **result)
+{
+ TDB_DATA key;
+ NTSTATUS status;
+ struct idmap_autorid_fetch_config_state state;
+
+ if (result == NULL) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ key = string_term_tdb_data(CONFIGKEY);
+
+ if (!dbwrap_exists(db, key)) {
+ DEBUG(1, ("Error: CONFIG entry does not exist\n"));
+ return NT_STATUS_NOT_FOUND;
+ }
+
+ state.mem_ctx = mem_ctx;
+ state.configstr = NULL;
+ state.status = NT_STATUS_OK;
+
+ status = dbwrap_parse_record(db, key, idmap_autorid_config_parser,
+ &state);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Error while retrieving config: %s\n",
+ nt_errstr(status)));
+ return status;
+ }
+
+ if (!NT_STATUS_IS_OK(state.status)) {
+ DEBUG(1, ("Error while retrieving config: %s\n",
+ nt_errstr(state.status)));
+ return state.status;
+ }
+
+ DEBUG(5, ("found CONFIG: %s\n", state.configstr));
+
+ *result = state.configstr;
+ return status;
+}
+
struct autorid_global_config *idmap_autorid_loadconfig(struct db_context *db,
TALLOC_CTX *ctx)
{