1

Active Directory を使用して、企業イントラネットの ASP.NET Web サイトにログインするユーザーを認証しています。次のコード行で「ハンドルが無効です」というエラーが発生します。

Dim entry As DirectoryEntry = New DirectoryEntry(path, domainAndUsername, Password)

認証に使用しているコードは次のとおりです。Dim entry As DirectoryEntry = New DirectoryEntry(path, domainAndUsername, Password)

    Try
        'Bind to the native AdsObject to force authentication.          

        Dim obj As Object = entry.NativeObject
        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 = CType(result.Properties("cn")(0), String)

    Catch ex As Exception
        Throw New Exception("Error authenticating user. " & ex.Message)
    End Try

この例外を追跡するにはどうすればよいですか? Visual Studio はそれが CryptographicException であると言います

ありがとう

4

1 に答える 1