title: Retrieving specific user details from AD via c#/.Net
body: <p>I am trying to retrieve <code>SamAccountName</code>,<code>Surname</code>,<code>GivenName</code> for users within a particular ADGroup using:</p>
  
  <pre><code>        PrincipalContext principalContext = new PrincipalContext(ContextType.Domain);
          GroupPrincipal group = GroupPrincipal.FindByIdentity(principalContext, adgroup);
  
          foreach (Principal principal in group.Members)
          {
              samName = principal.SamAccountName;
              surName = principal.SurName;   &lt;-- Intellisense gives error
              givenName = principal.GivenName;   &lt;-- Intellisense gives error
          }
  </code></pre>
  
  <p>As I step thru the code and add watches in Visual Studio for the above, they display the correct information, but <code>principal.Surname</code> and <code>principal.GivenName</code> give the following error at compile:</p>
  
  <p>'Principal' does not contain a definition for '____' and no extension method can be found</p>
  
  <p>Can someone explain why I can see the information when  using codebreaks in the IDE and hover over the <code>principal</code> variable, but cannot access the attribute in the code?</p>