title: Faster way to find out if a user exists on a system?
body: <p>I have an application that checks to see if a user exists (if not create it) every time it starts. This is done as follows:</p>
  
  <pre><code>bool bUserExists = false;
  DirectoryEntry dirEntryLocalMachine = 
      new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
  
  DirectoryEntries dirEntries = dirEntryLocalMachine.Children;
  
  foreach (DirectoryEntry dirEntryUser in dirEntries)
  {
      bUserExists = dirEntryUser.Name.Equals("UserName", 
          StringComparison.CurrentCultureIgnoreCase);
  
      if (bUserExists)
        break;
  }
  </code></pre>
  
  <p>The problem is on the majority of the systems where it is deployed. This can take 6 - 10 seconds, which is too long ... I need to find a way to reduce this (as much as possible). Is there a <em>better</em> or <em>faster</em> way I can use to verify if a user exists on the system or not?</p>
  
  <p>I know there are other ways to solve this, like have the other applications sleep for 10 seconds, or have this tool send a message when it is ready, etc... But if I can greatly reduce the time it takes to find the user, it would make my life much easier.</p>