title: Determine if a computer in AD has a user logged in
body: <p>I'm trying to receive all computers that are currently connected to AD and which of them who has a user logged on to AD. I've tried with the <code>ComputerPrincipal</code>'s <code>.LastLogon</code> property, but I get a value that is completely off, about a week.</p>
  
  <p>I want to know which computers in AD who's availiable. Is there another method I can use?</p>
  
  <pre><code>PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "192.168.0.101:389", "Administrator", "XXXX");
  
  // define a "query-by-example" principal - here, we search for a ComputerPrincipal 
  ComputerPrincipal qbeComputer = new ComputerPrincipal(ctx);
  
  // create your principal searcher passing in the QBE principal    
  PrincipalSearcher srch = new PrincipalSearcher(qbeComputer);
  
  // find all matches
  foreach (var found in srch.FindAll())
  {
      // do whatever here - "found" is of type "Principal" - it could be user, group, computer.....          
      ComputerPrincipal cp = found as ComputerPrincipal;
  
      if (cp != null)
      {
         string computerName = cp.Name;
         DateTime? lastLogon = new DateTime();
         lastLogon = cp.LastLogon;
         DateTime convertedDate = DateTime.SpecifyKind(DateTime.Parse(cp.LastLogon.ToString()), DateTimeKind.Utc);
  
         var kind = convertedDate.Kind;
         DateTime dt = convertedDate.ToLocalTime();
  
         Response.Write(cp.Name+"   :   "+ dt.ToString()+ "&lt;br /&gt;");
      }
   }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>I want the print-out to be like this:</p>
  
  <p>Computer  1: True
  Computer  2: False
  Computer  3: False
  Computer  4: True</p>
  
  <p>Is it impossible to query a computer if it's currently logged on? I just need an bool, True or False.</p>