private void FireComputerFound(ActiveDirectoryComputer computer) { if (this.ComputerFound != null) { ComputerFound(computer); } }
private void ListComputersThread(object state) { List <ActiveDirectoryComputer> Computers = new List <ActiveDirectoryComputer>(); bool Success = true; string Domain = (string)state; try { using (DirectoryEntry entry = new DirectoryEntry(string.Format("LDAP://{0}", Domain))) { using (DirectorySearcher mySearcher = new DirectorySearcher(entry)) { mySearcher.Filter = ("(objectClass=computer)"); foreach (SearchResult resEnt in mySearcher.FindAll()) { ActiveDirectoryComputer comp = new ActiveDirectoryComputer(); DirectoryEntry computer = resEnt.GetDirectoryEntry(); string name = computer.Name.Replace("CN=", ""); comp.Tags = Domain; if (computer.Properties != null && computer.Properties["name"] != null && computer.Properties["name"].Count > 0) { name = computer.Properties["name"][0].ToString(); } comp.ComputerName = name; if (computer.Properties != null && computer.Properties["operatingSystem"] != null && computer.Properties["operatingSystem"].Count > 0) { comp.Tags += "," + computer.Properties["operatingSystem"][0].ToString(); comp.OperatingSystem = computer.Properties["operatingSystem"][0].ToString(); } if (computer.Properties != null && computer.Properties["distinguishedName"] != null && computer.Properties["distinguishedName"].Count > 0) { string distinguishedName = computer.Properties["distinguishedName"][0].ToString(); if (distinguishedName.Contains("OU=Domain Controllers")) { comp.Tags += ",Domain Controllers"; } } Computers.Add(comp); } } } } catch (Exception exc) { Success = false; Terminals.Logging.Log.Error("Could not list the computers on the domain:" + Domain, exc); } if (OnListComputersDoneDelegate != null) { OnListComputersDoneDelegate(Computers, Success); } }
private void ListComputersThread(object state) { List<ActiveDirectoryComputer> Computers = new List<ActiveDirectoryComputer>(); bool Success = true; string Domain = (string)state; try { using(DirectoryEntry entry = new DirectoryEntry(string.Format("LDAP://{0}", Domain))) { using(DirectorySearcher mySearcher = new DirectorySearcher(entry)) { mySearcher.Filter = ("(objectClass=computer)"); foreach(SearchResult resEnt in mySearcher.FindAll()) { ActiveDirectoryComputer comp = new ActiveDirectoryComputer(); DirectoryEntry computer = resEnt.GetDirectoryEntry(); string name = computer.Name.Replace("CN=", ""); comp.Tags = Domain; if(computer.Properties != null && computer.Properties["name"] != null && computer.Properties["name"].Count > 0) { name = computer.Properties["name"][0].ToString(); } comp.ComputerName = name; if(computer.Properties != null && computer.Properties["operatingSystem"] != null && computer.Properties["operatingSystem"].Count > 0) { comp.Tags += "," + computer.Properties["operatingSystem"][0].ToString(); comp.OperatingSystem = computer.Properties["operatingSystem"][0].ToString(); } if(computer.Properties != null && computer.Properties["distinguishedName"] != null && computer.Properties["distinguishedName"].Count > 0) { string distinguishedName = computer.Properties["distinguishedName"][0].ToString(); if(distinguishedName.Contains("OU=Domain Controllers")) { comp.Tags += ",Domain Controllers"; } } Computers.Add(comp); } } } } catch(Exception exc) { Success = false; Terminals.Logging.Log.Error("Could not list the computers on the domain:" + Domain, exc); } if(OnListComputersDoneDelegate != null) OnListComputersDoneDelegate(Computers, Success); }
private List <FavoriteConfigurationElement> GetFavoritesFromBindingSource(String domain) { List <FavoriteConfigurationElement> favoritesToImport = new List <FavoriteConfigurationElement>(); foreach (DataGridViewRow computerRow in this.gridComputers.SelectedRows) { ActiveDirectoryComputer computer = computerRow.DataBoundItem as ActiveDirectoryComputer; FavoriteConfigurationElement newFavorite = computer.ToFavorite(this.connectionManager, domain); favoritesToImport.Add(newFavorite); } return(favoritesToImport); }
private void OnClientComputerFound(ActiveDirectoryComputer computer) { if (this.InvokeRequired) { this.Invoke(new ComputerFoundDelegate(this.OnClientComputerFound), new object[] { computer }); } else { this.bsComputers.Add(computer); this.lblProgressStatus.Text = String.Format("Scaning... {0} computers found.", this.bsComputers.Count); this.gridComputers.Refresh(); } }
private void ImportResults(ActiveDirectorySearchParams searchParams, SearchResultCollection found) { foreach (SearchResult result in found) { if (this.CancelationPending) { return; } DirectoryEntry computer = result.GetDirectoryEntry(); var comp = ActiveDirectoryComputer.FromDirectoryEntry(searchParams.Domain, computer); this.FireComputerFound(comp); } }
internal static ActiveDirectoryComputer FromDirectoryEntry(String domain, DirectoryEntry computer) { ActiveDirectoryComputer comp = new ActiveDirectoryComputer(); comp.Tags = domain; if (computer.Properties != null) { comp.NameFromEntry(computer); comp.OperationSystemFromEntry(computer); comp.DistinquishedNameFromEntry(computer); } return comp; }
internal static ActiveDirectoryComputer FromDirectoryEntry(String domain, DirectoryEntry computer) { ActiveDirectoryComputer comp = new ActiveDirectoryComputer(); comp.Tags = domain; if (computer.Properties != null) { comp.NameFromEntry(computer); comp.OperationSystemFromEntry(computer); comp.DistinquishedNameFromEntry(computer); } return(comp); }
private void OnClientComputerFound(ActiveDirectoryComputer computer) { if (this.InvokeRequired) { this.Invoke(new ComputerFoundDelegate(this.OnClientComputerFound), new object[] { computer }); } else { this.bsComputers.Add(computer); this.lblProgressStatus.Text = String.Format("Scaning... {0} computers found.", this.bsComputers.Count); this.gridComputers.Refresh(); } }
private void FireComputerFound(ActiveDirectoryComputer computer) { this.ComputerFound?.Invoke(computer); }
private void FireComputerFound(ActiveDirectoryComputer computer) { if (this.ComputerFound != null) ComputerFound(computer); }