Connect to AD using something like this:
var username = "your username";
var password = "your password";
var domain = "your domain";
var ctx = new PrincipalContext(ContextType.Domain, domain, username, password);
and then perform the operations using the PrincipalContext object.
Best regards
Espen Harlinn