Question: I am trying to retrieve `SamAccountName`,`Surname`,`GivenName` for users within a particular ADGroup using:

```
        PrincipalContext principalContext = new PrincipalContext(ContextType.Domain);
        GroupPrincipal group = GroupPrincipal.FindByIdentity(principalContext, adgroup);

        foreach (Principal principal in group.Members)
        {
            samName = principal.SamAccountName;
            surName = principal.SurName;   <-- Intellisense gives error
            givenName = principal.GivenName;   <-- Intellisense gives error
        }

```

As I step thru the code and add watches in Visual Studio for the above, they display the correct information, but `principal.Surname` and `principal.GivenName` give the following error at compile:

'Principal' does not contain a definition for '\_\_\_\_' and no extension method can be found

Can someone explain why I can see the information when using codebreaks in the IDE and hover over the `principal` variable, but cannot access the attribute in the code?

Answer: 
`SurName` and `GivenName` are not public properties of type `Principal` according to the [docs](https://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.principal(v=vs.110).aspx)

It looks like you need the `UserPrincipal` class to expose those properties, see the UserPrincipal [documentation](https://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.userprincipal(v=vs.110).aspx)

I cannot verify 100% right now, but I think if you change

```
foreach (Principal principal in group.Members)

```

to 

```
foreach (UserPrincipal principal in group.Members)

```

it should work
The Principal class does not have a property Surname or GivenName
<https://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.principal(v=vs.110).aspx>