On the basis of a combination of X-ray photoelectron spectroscopy and synchrotron-based X-ray emission spectroscopy, we present a detailed characterization of the chemical structure of CdS:O thin films that can be employed as a substitute for CdS layers in thin-film solar cells. It is possible to analyze the local chemical environment of the probed elements, in particular sulfur, hence allowing insights into the species-specific composition of the films and their surfaces. A detailed quantification of the observed sulfur environments (i.e., sulfide, sulfate, and an intermediate oxide) as a function of oxygen content is presented, allowing a deliberate optimization of CdS:O thin films for their use as alternative buffer layers in thin-film photovoltaic devices.