DSolve[-(((-1 + n)*n + a*Cos[x]^2)*y[x]) + Cos[x]^2*Derivative[2][y][x] == 0,y[x],x]