useing PrincipalContext c# code example
Example: PrincipalContext c# example
PrincipalContext ctx = new PrincipalContext(contextType, domainname, username,password);
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, userName);