Validating Username & password with Active Directory Services

Note: Refer System.DirectoryServices to the project & Import it to code before using

using (DirectoryEntry entry = new DirectoryEntry())
{
    entry.Username = "username";
    entry.Password = "password";
    //Active Directory LDAP server IP to be fetched from configuration file
    entry.Path = "LDAP://10.200.2.101";

    DirectorySearcher searcher = new DirectorySearcher(entry);

    try
    {
        searcher.FindOne();
        Console.WriteLine("username & password are valid");
    }
    catch (Exception ex)
    {
        Console.WriteLine("username or password is wrong");
    }

    Console.ReadKey();
}