Deducing that a locally ringed space is a scheme I would like to know if the following is true: Let $\mathscr{F}$ and $\mathscr{G}$ be two sheaves on a topological space $X$ and let $\varphi:\mathscr{F}\rightarrow\mathscr{G}$ be a morphism such that


*

*$(X,\mathscr{F})$ is an affine scheme and $(X,\mathscr{G})$ is a locally ringed space;

*$(Id_X,\varphi)$ is a morphism of locally ringed spaces such that $\varphi(X)$ is injective and each $\varphi_x:\mathscr{F}_x\rightarrow\mathscr{G}_x$ is surjective.
Then $\varphi$ is an isomorphism.
I know that this statement is true if we assume that $(X,\mathscr{G})$ is a scheme (Hartshorne, Chap 2, Exersise 3.11 b). 
 A: I claim that the question is equivalent to the following nontrivial(?) cohomological question (and since I have no idea how to solve this, I make this answer CW):

If $X=\mathrm{Spec}(A)$ is an affine scheme, $I \subseteq \mathcal{O}_X$ is an ideal (not assumed to be quasi-coherent) such that $H^0(X,I)=H^1(X,I)=0$ and $\mathrm{supp}(\mathcal{O}_X/I)=X$, does this imply that $I=0$ ?

Some generalities first. Let $X$ be a locally ringed space. A morphism into $X$ is called a closed immersion if it is a homeomorphism onto its image, which is closed, and surjective on stalks. If $I \subseteq \mathcal{O}_X$ is an ideal, then its zero set $V(I) := \{x \in X : I_x \subseteq \mathfrak{m}_x\} = \mathrm{supp}(\mathcal{O}_X/I)$ is a closed subset of $X$. If $i : V(I) \to X$ denotes the inclusion map, then $i^{-1} (\mathcal{O}_X/I)$ endows $V(I)$ with the structure of a locally ringed space and $i$ becomes a morphism of locally ringed spaces, which is in fact a closed immersion. Conversely, every closed immersion $i : Y \to X$ has a vanishing ideal $I(Y) := \ker i^\#$. It is easy to check that this gives an anti-equivalence of partial orders between closed immersions into $X$ and ideals of $\mathcal{O}_X$ (and one can show that if $X$ is a scheme, then $I$ is quasi-coherent if and only if $V(I)$ is a scheme).
In your question, $f : Y \to X$ is a morphism of locally ringed spaces, which is a homeomorphism, surjective on stalks, and injective on global sections. Besides, $X$ is an affine scheme. Now we ask if $f$ is an isomorphism. Observe that $f$ is a closed immersion, hence corresponds to an ideal $I \subseteq \mathcal{O}_X$. The condition that $f$ is a homeomorphism means that $V(I)=X$ as sets, or equivalently that $\mathcal{O}_X/I$ has support $X$. We have an exact sequence of cohomology groups
$0 \to H^0(X,I) \to H^0(X,\mathcal{O}_X) \to H^0(X,\mathcal{O}_X/I) \to H^1(X,I) \to H^1(X,\mathcal{O}_X)=0.$
We know that $f^\#$, or equivalently that $\mathcal{O}_X \to \mathcal{O}_X/I$ is an isomorphism on global sections. It follows that $H^0(X,I)=0$ and $H^1(X,I)=0$.

Here is a first observation about $I$, coming from $\mathrm{supp}(\mathcal{O}_X/I)=X$. For every quasi-compact open subset $U \subseteq X$ the ideal $\Gamma(U,I) \subseteq \Gamma(U,\mathcal{O}_X)$ consists of nilpotent elements. In fact, we may assume that $U$ is basic open, therefore affine, say $U=\mathrm{Spec}(B)$. If $s \in \Gamma(U,I)$, then $s/1 \in \mathfrak{m}_q = \mathfrak{q} B_{\mathfrak{q}}$ for every prime ideal $\mathfrak{q} \subseteq B$, which means $s \in \mathfrak{q}$. Hence, $s$ lies in $\bigcap_{\mathfrak{q}} \mathfrak{q} = \mathrm{rad}(B)$. Therefore:

$I \subseteq \mathrm{rad}(\mathcal{O}_X)$

Now assume that $\mathrm{rad}(A)$ is nilpotent (for example when $A$ is noetherian), say $\mathrm{rad}(A)^n=0$, or equivalently $R^n=0$ for $R:=\mathrm{rad}(\mathcal{O}_X)$. Now the standard trick is to look at the filtration $0=R^n \subseteq R^{n-1} \subseteq \dotsc \subseteq R \subseteq \mathcal{O}_X$ and intersect it with $I$, and try to show by induction that $I \subseteq R^k$.
