Here is a little VB.NET function I’ve written that will provide you with the names of all of the domain controllers in your Active Directory domain – note that you need to add a reference to System.DirectoryServices first.
GetDomainControllers() As List
DcList As New List
Using Searcher As New DirectorySearcher(New DirectoryEntry)
Searcher.Filter = "(primaryGroupID=516)"
For Each DC As SearchResult In Searcher.FindAll
EDIT: I just found that there is a much simpler way of doing this! You simply loop through the DomainControllers collection like so:
For Each DC As DirectoryServices.ActiveDirectory.DomainController In DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain.DomainControllers
'You can get all sorts of useful info from the DomainController object
'but here is a simple example of getting the name and IP
MessageBox.Show(DC.Name & " – " & DC.IPAddress)
Hope it is of some use to someone in the future.