1

DBA から、私のアプリケーションの 1 つが実際に LDAP サーバーの 1 つを停止させていると報告を受けました。コードを何度か調べましたが、LDAP にアクセスする回数を制限する方法がわかりません。そこで、実際にデータを取得する方法を調べて、より良い方法があるかどうかを確認することにしました。私が使用している実際のデータ モデルを開発したわけではありません。また、System.DirectoryServices.Protocols ライブラリが何であるかもわかりません。

.NET LDAP プロバイダーの使用に詳しい方からアドバイスをいただければ幸いです。LDAPサーバーでエントリを検索するために使用している関数は次のとおりです。

    <DirectoryServicesPermission(SecurityAction.LinkDemand, Unrestricted:=True)> _
    Public Overloads Shared Function GetSearchResultEntry(ByVal connection As LdapConnection, ByVal searchDirectoryPath As String, ByVal filter As String, _
                                          ByVal attributes As String(), ByVal scope As Protocols.SearchScope) As SearchResultEntry

        If connection Is Nothing Then
            Throw New ArgumentNullException("connection", "An ldap connection must be provided in order to search for a directory.")
        End If

        If Strings.IsNullOrBlank(searchDirectoryPath) Then
            Throw New ArgumentException("A directory path must be provided in order to search for a directory.", "searchDirectoryPath")
        End If

        If Strings.IsNullOrBlank(filter) Then
            Throw New ArgumentException("A search filter must be provided in order to search for a directory.", "filter")
        End If

        Dim resp As SearchResponse = CType(connection.SendRequest(New SearchRequest(searchDirectoryPath, filter, scope, attributes)), SearchResponse)

        If resp.Entries.Count > 0 Then
            Return resp.Entries(0)
        End If

        Return Nothing

    End Function

.NET LDAP プロバイダーが少し遅い可能性はありますか? 誰かが自分のショップでどのように LDAP をヒットしているかを示すコード例をいくつか持っていれば、それは素晴らしいことです。

とにかく、助けてくれてありがとう。

ありがとう、
CM

4

1 に答える 1

1

2つのこと:

  1. あなたは1つのエントリだけを気にします。そのコードは、特定のクエリのすべての結果を返すように見えます。単一結果のクエリスタイルを探し回ってみてください。
  2. それができない場合、この特定のビットをサーバー上で簡単にコード化するためにできることがたくさんあるとは思えません。結果をキャッシュすることで、この関数をあまり頻繁に呼び出せない方法があるかどうかがわかるかもしれません。
于 2008-12-08T22:48:39.990 に答える