我根据MSDN的例子写了一个函数来验证登录帐号和密码是否为网域内的帐号密码,但是现在却只能检查到我本机的帐号,网域内别的帐号在我机器上登录却不能通过验证。请各位大虾帮我看看
代码如下:
  Public Function IsAuthenticated(ByVal domain As String, ByVal username As String, ByVal pwd As String) As Boolean
            Dim domainAndUsername As String = domain & "\" & username
            Dim entry As DirectoryEntry = New DirectoryEntry(_path, domainAndUsername, pwd)            Try                'Bind to the native AdsObject to force authentication.
                ' Dim obj As Object = entry                Dim search As DirectorySearcher = New DirectorySearcher(entry)
                search.Filter = "(SAMAccountName=" & username & ")"                search.PropertiesToLoad.Add("cn")
                Dim result As SearchResult = search.FindOne()                If (result Is Nothing) Then
                    Return (False)
                End If                'Update the new path to the user in the directory.
                _path = result.Path
                _filterAttribute = CStr(result.Properties("cn")(0))
            Catch ex As Exception
                'throw new Exception("Error authenticating user. " + ex.Message);
                Return False
                '
            End Try            Return True
        End Function
PS:LDAP路径是正确的。