public static class DirectoryEntryExtensions
{
public static T GetFirstPropValue(this DirectoryEntry entry, string propName) where T : class
{
var pcv = entry.Properties[propName];
return (pcv == null || pcv.Count == 0) ? null : (T)pcv[0];
}
public static IEnumerable GetPropValues(this DirectoryEntry entry, string propName) where T : class
{
var property = entry.Properties[propName];
if (property == null || property.Count == 0)
{
return Enumerable.Empty();
}
return property.Cast();
}
}