Exact solution for the distribution of transmission eigenvalues in a disordered wire and comparison with random-matrix theory