I've been trying to retrieve two custom properties that are set on our Active Directory users, but it seems like I keep getting a constant list of Properties (tested over 2 different AD servers)
Assuming the properties I'm trying to fetch are prop1
and prop2
, What am I doing wrong in the following code:
List<String> nProps = new List<string>();
DirectoryEntry directoryEntry = new DirectoryEntry("WinNT://DOM");
foreach (DirectoryEntry child in directoryEntry.Children)
{
// No filtering; ignore schemes that are not User schemes
if (child.SchemaClassName == "User")
{
foreach (var sVar in child.Properties.PropertyNames)
nProps.Add(sVar.ToString());
break;
}
}
nProps
does not contain ANY of my custom properties (not prop1
nor prop2
)
(it does contain other properties, like BadPasswordAttempts, Username, etc)
Any ideas?