Beispiel #1
0
        private void SearchCriteria(object param)
        {
            MyParams objMyParam =(MyParams)param;
            DirectoryEntry root = null;
            DirectoryEntries parent = null;

            if ( objMyParam.type == SearchType.Machines)
            {
                if (MachineDiscoveryStart != null)
                {
                    logger.Info("DiscoveryStart event raised");
                    MachineDiscoveryStart(this, null);
                }
                logger.Info("Starting the background thread for scanning machines");
            }
            else
            {
                if (DomainDiscoveryStart != null)
                {
                    DomainDiscoveryStart(this, null);
                }
            }

            try
            {
                using (root = new DirectoryEntry("WinNT:"))
                {
                    parent = root.Children;
                    foreach (DirectoryEntry complist in parent)
                    {
                        if (objMyParam.type == SearchType.Machines)
                        {
                            if (objMyParam.criteria.Equals(complist.Name, StringComparison.OrdinalIgnoreCase) || objMyParam.criteria == "*")
                                SearchComputers(complist.Name);
                        }
                        else
                        {
                            if (DomainFound != null)
                            {
                                DomainDetailsArgs objDomainArgs = new DomainDetailsArgs();
                                objDomainArgs.DomainName = complist.Name;
                                DomainFound(this, objDomainArgs);
                            }
                        }
                    }
                    parent = null;
                }
            }
            catch (Exception e)
            {
                logger.Info("Exception occured in machine retrival <"+e.Message+">");
            }
            finally
            {
                if (objMyParam.type == SearchType.Machines)
                {
                    logger.Info("Finally raise the DiscoveryComplete event for startCompleteScan");
                    if (MachineDiscoveryComplete != null)
                    {
                        MachineDiscoveryComplete(this, null);
                    }
                }
                else
                {
                    if (DomainDiscoveryComplete != null)
                    {
                        DomainDiscoveryComplete(this, null);
                    }
                }
            }
        }
Beispiel #2
0
 void Instance_DomainFound(object sender, DomainDetailsArgs args)
 {
     this.cbDomainName.SafeControlInvoke
     (
         cbDomainName =>
         {
             cbDomainName.Items.Add(args.DomainName);
         }
     );
 }
Beispiel #3
0
 /// <summary>
 /// Callback called when the domain found event is raised by nethelper
 /// </summary>
 /// <param name="sender">nethelper object</param>
 /// <param name="args">DomainDetailsArgs class contains the domain details</param>
 void netHelper_DomainFound(object sender, DomainDetailsArgs args)
 {
     if (DomainFound != null)
     {
         DomainFound(this, args);
     }
 }