首页 > 代码库 > 测试域账户及密码是否正确

测试域账户及密码是否正确

  引用System.DirectoryServices.AccountManagement命名空间,按照如下方法,AD域验证

获取连接PrincipalContext pc = new PrincipalContext(ContextType.Domain, "服务器域名")
验证账号密码pc.ValidateCredentials(Account, password) 

private Boolean Get()
        {
            using (PrincipalContext p = new PrincipalContext(ContextType.Domain,textBox3.Text))
            { 、、
                return p.ValidateCredentials(textBox1.Text, textBox2.Text);//验证域信息是否正确返回Boolean 值
            }
        }

测试域账户及密码是否正确