A calculation of the entropy of static, electrically charged, black holes with spherical, toroidal, and hyperbolic-compact and oriented horizons, in D spacetime dimensions, is performed. These black holes live in an anti-de Sitter spacetime, i.e., a spacetime with negative cosmological constant. To find the entropy, the approach developed by Solodukhin is followed. The method consists in a redefinition of the variables in the metric, by considering the radial coordinate as a scalar field. Then one performs a 2+(D-2) dimensional reduction, where the (D-2) dimensions are in the angular coordinates, obtaining a 2-dimensional effective scalar field theory. This theory is a conformal theory in an infinitesimally small vicinity of the horizon. The corresponding conformal symmetry will then have conserved charges, associated with its infinitesimal conformal generators, which will generate a classical Poisson algebra of the Virasoro type. Shifting the charges and replacing Poisson brackets by commutators, one recovers the usual form of the Virasoro algebra, obtaining thus the level zero conserved charge eigenvalue L-0, and a nonzero central charge c. The entropy is then obtained via the Cardy formula.