  The classical result of Eisenhart states that if a Riemannian metric $g$
admits a Riemannian metric that is not constantly proportional to $g$ and has
the same (parameterized) geodesics as $g$ in a neighborhood of a given point,
then $g$ is a direct product of two Riemannian metrics in this neighborhood. We
introduce a new generic class of step $2$ graded nilpotent Lie algebras, called
$\mathrm{ad}$-surjective, and extend the Eisenhart theorem to sub-Riemannian
metrics on step 2 distributions with $\mathrm{ad}$-surjective Tanaka symbols.
The class of ad-surjective step 2 nilpotent Lie algebras contains a well-known
class of algebras of H-type as a very particular case.
