internal void FindComputers(ActiveDirectorySearchParams searchParams)
 {
     if (!this.IsRunning) // nothing is running
     {
         this.cancelationPending = false;
         this.IsRunning = true;
         ThreadPool.QueueUserWorkItem(new WaitCallback(StartScan), searchParams);
     }
 }
Exemple #2
0
 internal void FindComputers(ActiveDirectorySearchParams searchParams)
 {
     if (!this.IsRunning) // nothing is running
     {
         this.cancelationPending = false;
         this.IsRunning          = true;
         ThreadPool.QueueUserWorkItem(new WaitCallback(StartScan), searchParams);
     }
 }
Exemple #3
0
        private static DirectorySearcher CreateSearcher(DirectoryEntry entry, ActiveDirectorySearchParams searchParams)
        {
            var searcher = new DirectorySearcher(entry);

            searcher.Asynchronous = true;
            searcher.Filter       = searchParams.Filter;
            searcher.SearchRoot   = new DirectoryEntry("LDAP://" + searchParams.Searchbase);
            searcher.PageSize     = searchParams.PageSize;
            return(searcher);
        }
Exemple #4
0
 private void SearchComputers(ActiveDirectorySearchParams searchParams)
 {
     using (DirectoryEntry entry = new DirectoryEntry(string.Format("LDAP://{0}", searchParams.Domain)))
     {
         using (DirectorySearcher searcher = CreateSearcher(entry, searchParams))
         {
             using (SearchResultCollection found = searcher.FindAll())
             {
                 this.ImportResults(searchParams, found);
             }
         }
     }
 }
Exemple #5
0
 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);
     }
 }
Exemple #6
0
 private void ScanADButton_Click(object sender, EventArgs e)
 {
     if (!this.adClient.IsRunning)
     {
         this.bsComputers.Clear();
         var searchParams = new ActiveDirectorySearchParams(this.domainTextbox.Text,
                                                            this.ldapFilterTextbox.Text, this.searchbaseTextbox.Text);
         adClient.FindComputers(searchParams);
         this.lblProgressStatus.Text = "Contacting domain...";
         this.SwitchToRunningMode();
     }
     else
     {
         adClient.Stop();
         this.lblProgressStatus.Text = "Canceling scan...";
     }
 }
 private void ScanADButton_Click(object sender, EventArgs e)
 {
     if (!this.adClient.IsRunning)
     {
         this.bsComputers.Clear();
         var searchParams = new ActiveDirectorySearchParams(this.domainTextbox.Text,
             this.ldapFilterTextbox.Text, this.searchbaseTextbox.Text);
         adClient.FindComputers(searchParams);
         this.lblProgressStatus.Text = "Contacting domain...";
         this.SwitchToRunningMode();
     }
     else
     {
         adClient.Stop();
         this.lblProgressStatus.Text = "Canceling scan...";
     }
 }
 private static DirectorySearcher CreateSearcher(DirectoryEntry entry, ActiveDirectorySearchParams searchParams)
 {
     var searcher = new DirectorySearcher(entry);
     searcher.Asynchronous = true;
     searcher.Filter = searchParams.Filter;
     searcher.SearchRoot = new DirectoryEntry("LDAP://"+searchParams.Searchbase);
     searcher.PageSize = searchParams.PageSize;
     return searcher;
 }
 private void SearchComputers(ActiveDirectorySearchParams searchParams)
 {
     using (DirectoryEntry entry = new DirectoryEntry(string.Format("LDAP://{0}", searchParams.Domain)))
     {
         using (DirectorySearcher searcher = CreateSearcher(entry, searchParams))
         {
             using (SearchResultCollection found = searcher.FindAll())
             {
                 this.ImportResults(searchParams, found);
             }
         }
     }
 }
 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);
     }
 }