The Maxwell Lagrangian for the gauge field $A_\mu$ is given by,
$$\mathcal L = -\frac{1}{4}F_{\mu\nu}F^{\mu\nu}.$$
The equations of motion are $\partial_\mu F^{\mu\nu} = 0$, supplemented by the Bianchi identity. Taking as an example the case $D=4$, naively one would think we have $4$ degrees of freedom. However, we know photons have only two degrees of freedom, so it must be reduced somehow.
It turns out the component $A_0$ is not dynamical, since we have no kinetic term for it in the Lagrangian. In other words, $A_0$ is fully determined by the other components through,
$$\nabla^2 A_0 + \nabla \cdot \frac{\partial \vec A}{\partial t}=0$$
which has the solution,
$$A_0 (\vec x) = \int d^3 y \frac{1}{4\pi |\vec x - \vec y|}\frac{\partial \vec A (\vec y)}{\partial t}.$$
Just like in general relativity where we have constraints on what initial data surface to specify, we cannot choose our initial $A_0$. So, in general we've gone from $D \to D-1$ independent components. For the case $D=4$, the degrees of freedom are two due to the additional constraint,
$$\nabla \cdot \vec A = 0$$
known as Coulomb gauge. (One should not think of it per se as a constraint, but rather as exploiting a redundancy in the description of the system due to the gauge symmetry.) This bumps us down to two.