在windows Form程序中使用。这段代码如下:
        private void Authenticate(string username,string password)
        {
            
            try                                                          
            {
                DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");              //设置活动目录为本机
                DirectoryEntry ChangerUser = AD.Children.Find(username ,"user");                                                                  
                //ChangerUser.Invoke("ChangePassword", new object[] { password, password });
                UserFullNameStr=ChangerUser.InvokeGet("FullName").ToString();
                UserDescriptionStr = ChangerUser.InvokeGet("Description").ToString();
                ChangerUser.CommitChanges();
                this.Close();
            }
            catch
            {
                MessageBox.Show("用户名/密码错误,请重新输入","登录错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                DialogResult = DialogResult.None;
                count = count + 1;
                if (count == FailCount)
                {
                    this.Close();
                    LoginWaring = true;
                }
            }
        }问题:我验证密码是采用的修改密码的方式间接获得,有没有更好的办法?还有就是当当前系统用户权限不为administrator时,则此程序似乎无法访问Active Directory,抛出异常为访问拒绝,否则没有问题,自己觉得应该为权限的问题,请问如何解决?需要在普通权限下进行用户身份鉴定 ,谢谢。