title: GetAuthorizationGroups returns more groups than my user is in
body: <p>i found <a href="https://stackoverflow.com/questions/5309988/how-to-get-the-groups-of-a-user-in-active-directory-c-asp-net">this</a> post to get the security groups of a user.</p>
  
  <p>I had to change it a bit so it looks like this:</p>
  
  <pre><code>public List&lt;GroupPrincipal&gt; GetGroups(string userName, string userPassword, string userDomain)
      {
          List&lt;GroupPrincipal&gt; result = new List&lt;GroupPrincipal&gt;();
  
          // establish domain context
          PrincipalContext yourDomain = new PrincipalContext(ContextType.Domain, userDomain, userName, userPassword);
  
          // find your user
          UserPrincipal user = UserPrincipal.FindByIdentity(yourDomain, IdentityType.SamAccountName, userName);
  
          // if found - grab its groups
          if (user != null)
          {
              PrincipalSearchResult&lt;Principal&gt; groups = user.GetAuthorizationGroups();
  
              // iterate over all groups
              foreach (Principal p in groups)
              {
                  // make sure to add only group principals
                  if (p is GroupPrincipal)
                  {
                      result.Add((GroupPrincipal)p);
                  }
              }
          }
  
          return result;
      }
  </code></pre>
  
  <p>Unfortunately I now get every security group in the AD and not only the ones the user is in. 
  My user is in 10 groups but it returns 71.
  I had to submit username and password or else I would not be allowed to look up the groups. It is an administrative account on a different domain so I couldn't use the current credentials.</p>
  
  <p>If you need more info please let me know.</p>
  
  <p>Greetings and thanks in advance
  IG</p>