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

  引用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 值
            }
        }

posted on 2016-09-06 11:45  路上有你F  阅读(918)  评论(0编辑  收藏  举报