C# Active Directory PrincipalContext / UserPrincipal.IsMemberOf error

My first guess would be: that user account you're running this code under doesn't have the necessary permissions to query Active Directory.

To fix this, basically you need to change your constructor from this:

PrincipalContext ADDomain = new PrincipalContext(ContextType.Domain);

(establishes a connection to AD with the current, default credentials this code is running under)

to this:

PrincipalContext ADDomain = 
   new PrincipalContext(ContextType.Domain, "DOMAIN", useraccount, password);

and provide a username and password for a user account that you know has sufficient privileges to query Active Directory.