using System; using System.DirectoryServices; namespace ConsoleApplication1 { internal class Program { private static void Main(string[] args) { string name = "jim green"; // RDN format string logonName = @"xxx/jgreen"; //pre windows 2000 format Console.WriteLine(IsUserValid(name, "the-password")); Console.WriteLine(IsUserValid(logonName, "the-password")); Console.ReadLine(); } public static bool IsUserValid(string name, string pwd) { DirectoryEntry rootEntry = new DirectoryEntry("LDAP://xxx.com", name.ToLower(), pwd,AuthenticationTypes.ServerBind); try { // Bind to the native object to force authentication Object nativeObject = rootEntry.NativeObject; return true; } catch (Exception ex) { Console.WrITeLine(ex); return false; } } } }