title: Create PrincipalContext using windows authentication
body: <p>I'm creating a PrincipalContext object for retrieving a user's groups from our AD database (we use these then for authentication to various parts of the site).</p>
  
  <p>This used to be done using forms authentication, so the code looked something like this</p>
  
  <pre><code>PrincipalContext pc =
      new PrincipalContext(ContextType.Domain, "domain.com", username, password);
  
  UserPrincipal usp =
      UserPrincipal.FindByIdentity(pc, IdentityType.Guid, user.Guid.ToString());
  
  foreach (var group in usp.GetGroups())
  {
      // Add group to collection
  }
  </code></pre>
  
  <p>However, we recently switched to windows authentication, and I no longer have access to the user's password.</p>
  
  <p>How can I search the AD database using the current user's credentials? I've tried using impersonation, but it throws an <code>An operations error occurred</code> error on the <code>FindByIdentity</code> line. If I forget about authentication all together I'm limited in the number of groups that are returned.</p>