I am getting a ADGroup using this code,
using (var context = Utilities.GetPrincipalContext(OU))
using (var gpe = new GroupPrincipalExtension(context, "*"))
using (var ps = new PrincipalSearcher(gpe))
{
foreach (var g in ps.FindAll())
{
Console.WriteLine(g.DisplayName);
}
}
It's giving DisplayName null, because the attribute is available but under another object, here is what I see in LOCAL window when debugging,
Edit
I thought code was self explaining but if it causes confusion, I am trying to get all groups in a specific OU, then trying to get a custom attribute "DisplayName", GroupPrincipalExtension inherits from GroupPrincipal class of system.directoryservices.accountmanagement.
When debugging I can see "g" object has Test.AD.GroupPrincipalExtension (I don't know what to call it ? underline object ? a property ? not sure...) which has DisplayName property.
Because I can't get g.DisplayName
, how can i get following,
g.Test.AD.GroupPrincipalExtension.DisplayName