Exchange 2010 Could not delete a DAG

At one point I could not delete a DAG in my lab setup (yes I had been messing around and probably was a little inpatient). I kept getting an error about not being able to contact the domain controller, but all other functions worked fine. I went to adsiedit and deleted the DAG.

I then found i had some issues with the databases. I went to the properties of each database and cleared the msExchMasterServerOrAvailabilityGroup attribute. The when adding these databases to a new DAG I got an error saying I had a corrupt Active Directory object.

I copied the msExchMasterServerOrAvailabilityGroup attribute from a new database, and pasted it into the msExchMasterServerOrAvailabilityGroup attribute of the database I was trying to add to the DAG.

After doing this, the database showed up in the DAG, and I did not have any issues after that managing, deleting or modifying the DAG or the databases.