American counterterrorism and intelligence officials have said that some members of Ansar al-Shariah, the group that carried out the attack on the diplomatic mission in Benghazi, had connections to al-Qaida in the Islamic Maghreb, one of the militant groups now holding northern Mali.