Authenticate a user’s credentials with this code against a domain. This also works with a domain trust.
static bool AuthenticateUser(string userName, string password, string domain)
{
bool authentic = false;
try
{
DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain,
userName, password);
object nativeObject = entry.NativeObject;
authentic = true;
}
catch (DirectoryServicesCOMException e) { Console.Write(e.Message); }
return authentic;
}