The Connes-Kasparov conjecture for almost connected groups and for linear p-adic groups