public static bool ValidateUser(string username, string domain, string password) { int ret = LogonUser(username, domain, password); // ERROR_PASSWORD_EXPIRED 1330 // ERROR_PASSWORD_MUST_CHANGE 1907 // ERROR_PASSWORD_CHANGE_REQUIRED 1938 if (new int[] { 0, 1330, 1907, 1938 }.Any(a => a == ret)) { return true; } return false; }