  GRB050904 is the gamma-ray burst with the highest measured redshift. We
performed time resolved X-ray spectroscopy of the late GRB and early afterglow
emission. We find robust evidence for a decrease with time of the soft X-ray
absorbing column. We model the evolution of the column density due to the flash
ionization of the GRB and early afterglow photons. This allows us to constrain
the metallicity and geometry of the absorbing cloud. We conclude that the
progenitor of GRB050904 was a massive star embedded in a dense metal enriched
molecular cloud with Z~0.03 Z_solar. This is the first local measurement of
metallicity in the close environment of a GRB and one of the highest redshift
metallicity measurements. We also find that the dust associated with the cloud
cannot be similar to that of our Galaxy but must be either sizably depleted or
dominated by silicate grains. We discuss the implications of these results for
GRB progenitors and high redshift star formation.
