public bool updateDomainControllers(DomainCollection domains) { ConfiguredDomainControllersList.Clear(); UnconfiguredDomainControllersList.Clear(); UnreachableDomainControllersList.Clear(); AllDomainControllers.Clear(); bool retVal = true; try { foreach (Domain domain in domains) { DomainControllerCollection dcCollection = domain.FindAllDiscoverableDomainControllers(); foreach (DomainController dc in dcCollection) { try { AllDomainControllers.Add(dc); if (checkSystemReachable(dc.IPAddress)) { if (checkRegKey(dc.IPAddress)) { ConfiguredDomainControllersList.Add(dc.Name); } else { UnconfiguredDomainControllersList.Add(dc.Name); } } else { UnreachableDomainControllersList.Add(dc.Name); } } catch (Exception e) { UnconfiguredDomainControllersList.Add(e.ToString()); } } } } catch (Exception ex) { UnconfiguredDomainControllersList.Add("Error Retrieving Domain Controllers"); ConfiguredDomainControllersList.Add("Error Retrieving Domain Controllers"); retVal = false; } return(retVal); }
public void updateDomainControllers() { ConfiguredDomainControllersList.Clear(); UnconfiguredDomainControllersList.Clear(); try { Forest forest = Forest.GetCurrentForest(); DomainCollection domCollection = forest.Domains; foreach (Domain domain in domCollection) { DomainControllerCollection dcCollection = domain.FindAllDiscoverableDomainControllers(); foreach (DomainController dc in dcCollection) { try { if (checkSystemReachable(dc.IPAddress)) { AllDomainControllers.Add(dc); if (checkRegKey(dc.IPAddress)) { ConfiguredDomainControllersList.Add(dc.Name); } else { UnconfiguredDomainControllersList.Add(dc.Name); } } } catch (Exception e) { UnconfiguredDomainControllersList.Add(e.ToString()); } } } } catch (Exception ex) { UnconfiguredDomainControllersList.Add("Error Retrieving Domain Controllers"); ConfiguredDomainControllersList.Add("Error Retrieving Domain Controllers"); } }