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?