A topological insulator doped with random magnetic impurities is studied. The system is modelled by the Kane-Mele model with a random spin exchange between conduction electrons and magnetic dopants. The dynamical mean field theory for disordered systems is used to investigate the electron dynamics. The magnetic long-range order and the topological invariant are calculated within the mean field theory. They reveal a rich phase diagram, where different magnetic long-range orders such as antiferromagnetic or ferromagnetic one can exist in the metallic or insulating phases, depending on electron and magnetic impurity fillings. It is found that insulator only occurs at electron half filling, quarter filling and when electron filling is equal to magnetic impurity filling. However, non-trivial topology is observed only in half-filling antiferromagnetic insulator and quarter-filling ferromagnetic insulator. At electron half filling, the spin Hall conductance is quantized and it is robust against magnetic doping, while at electron quarter filling, magnetic dopants drive the ferromagnetic topological insulator to ferromagnetic metal. The quantum anomalous Hall effect is observed only at electron quarter filling and dense magnetic doping.