I can check if an account is a member in an AD group but is there a way to tell if an account belongs to an OU? I would like to search by OU instead of by AD group and I am not sure if that's possible. Below is how I search for an AD group.
string myADSPath="LDAP://onecity/CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com";
if (DirectoryEntry.Exists(myADSPath))
{
Console.WriteLine("In the group");
}
else
{
Console.WriteLine("Couldn't get in the group");
}