用网上流行的ADHelper.cs,存在一个问题如果,帐号不同,但姓名相同时,密码是对的用public static LoginResult LoginByAccount(string sAMAccountName, string password),还是会认为密码不对。我看了一下,他验证的时候要转换成用用户姓名进行验证:DirectoryEntry entry = new DirectoryEntry(ADPath, userName, password, AuthenticationTypes.None);如果sAMAccountName不同而username相同时这种方式验证肯定不对。请告手指点一下怎么解决这个问题,刚学习这个东西,不太熟悉

解决方案 »

  1.   

                    de = new DirectoryEntry("LDAP://xxxxxxx" ,UID.Trim(),PWD,AuthenticationTypes.Secure);                // 随便找点什么。
                    ds = new DirectorySearcher(de);
                    ds.Filter = "(samAccountName=" + UID.Trim() + ")";
                    ds.SearchScope = SearchScope.Subtree;                if (ds.FindOne() == null)
                    {
                        return "登录失败。";
                    }
      

  2.   

    UID,用户名的一种写法,就跟PWD是密码的一种写法一样