Advertisement
parabola949

Untitled

Oct 18th, 2011
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. static List<string> _targets = new List<string>();
  2.         static List<string> _offline = new List<string>();
  3.         public enum status
  4.         {
  5.             offline, logged, cleared
  6.         }
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Finding all computers in Active Directory...");
  10.             _targets = getComputers();
  11.             string user = "xxxxxxxx";
  12.             while (true)
  13.             {
  14.                 doSearch(_targets, user);
  15.                 _targets = _offline;
  16.                 _offline.Clear();
  17.             }
  18.         }
  19.  
  20.         static void doSearch(List<string> targets, string userName)
  21.         {
  22.             Console.Clear();
  23.             int count = 0;
  24.             Console.WriteLine("Searching each computer for ******....");
  25.             foreach (string target in targets)
  26.             {
  27.                 if (PCisOnline(target))
  28.                 {
  29.                     if (hasLoggedOn(target, userName))
  30.                     {
  31.                         Console.WriteLine("***" + target + "***\n" + count + "\\" + _targets.Count);
  32.                         Log(target, status.logged);
  33.                     }
  34.                     else
  35.                     {
  36.                         Log(target, status.cleared);
  37.                     }
  38.                 }
  39.                 else
  40.                 {
  41.                     Console.WriteLine("*" + target + "\n" + count + "\\" + _targets.Count);
  42.                     _offline.Add(target);
  43.                     Log(target, status.offline);
  44.                 }
  45.                 count++;
  46.             }
  47.         }
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement