static bool pdb_samba_dsdb_id_to_sid(struct pdb_methods *m, struct unixid *id,
				     struct dom_sid *sid)
{
	struct pdb_samba_dsdb_state *state = talloc_get_type_abort(
		m->private_data, struct pdb_samba_dsdb_state);
	NTSTATUS status;
	struct id_map id_map;
	struct id_map *id_maps[2];
	TALLOC_CTX *tmp_ctx = talloc_stackframe();
	if (!tmp_ctx) {
		return false;
	}

	id_map.xid = *id;
	id_maps[0] = &id_map;
	id_maps[1] = NULL;

	status = idmap_xids_to_sids(state->idmap_ctx, tmp_ctx, id_maps);
	if (!NT_STATUS_IS_OK(status)) {
		talloc_free(tmp_ctx);
		return false;
	}

	if (id_map.xid.type != ID_TYPE_NOT_SPECIFIED) {
		id->type = id_map.xid.type;
	}
	*sid = *id_map.sid;
	talloc_free(tmp_ctx);
	return true;
}
static bool pdb_samba_dsdb_id_to_sid(struct pdb_methods *m, struct unixid *id,
				     struct dom_sid *sid)
{
	struct pdb_samba_dsdb_state *state = talloc_get_type_abort(
		m->private_data, struct pdb_samba_dsdb_state);
	NTSTATUS status;
	struct id_map id_map;
	struct id_map *id_maps[2];
	TALLOC_CTX *tmp_ctx = talloc_stackframe();
	if (!tmp_ctx) {
		return false;
	}

	id_map.xid = *id;
	id_maps[0] = &id_map;
	id_maps[1] = NULL;

	status = idmap_xids_to_sids(state->idmap_ctx, tmp_ctx, id_maps);
	if (!NT_STATUS_IS_OK(status)) {
		talloc_free(tmp_ctx);
		return false;
	}

	if (id_map.xid.type != ID_TYPE_NOT_SPECIFIED) {
		id->type = id_map.xid.type;
	}
	*sid = *id_map.sid;
	talloc_free(tmp_ctx);
	return true;
}