SearchResultとは? わかりやすく解説

SearchResult クラス

SearchResult クラスは、DirectorySearcher を使用した検索中に返される Active Directory 階層ノードカプセル化ます。

名前空間: System.DirectoryServices
アセンブリ: System.DirectoryServices (system.directoryservices.dll 内)
構文構文

public class SearchResult
public ref class SearchResult
public class SearchResult
public class SearchResult
解説解説

SearchResult クラスインスタンスは、DirectoryEntry クラスインスタンスに非常に似てます。DirectoryEntry クラス新しオブジェクトアクセスするたびに Active Directory 階層から情報取得しますが、SearchResultデータDirectorySearcher クラス実行したクエリ返す SearchResultCollection の中で先に利用できる点が大きな違いです。クエリの DirectorySearcher.PropertiesToLoad コレクション指定したプロパティだけが、SearchResult使用できます

使用例使用例

目的パスを持つ新しDirectoryEntry オブジェクト作成し、FindOne メソッド使用して検索実行する例を次に示します。この例では、検索実行した後、GetDirectoryEntry メソッド使用して検索結果示されるライブ ディレクトリ エントリ取得します

Imports System
Imports System.DirectoryServices
Imports Microsoft.VisualBasic

Public Class MySample
   Public Shared Sub Main()
      Dim myLDAPPath As String
 = ""
      Try
         ' Create a 'DirectoryEntry' object to search.
         Console.WriteLine("Enter the path ( Ex : 'LDAP://MyServer')")
         myLDAPPath = Console.ReadLine()
         Dim mySearchRoot As New
 DirectoryEntry(myLDAPPath)
         
         Dim myDirectorySearcher As New
 DirectorySearcher(mySearchRoot)
         
         ' Get the first entry of the search.
         Dim mySearchResult As SearchResult
 = myDirectorySearcher.FindOne()
         If Not (mySearchResult Is
 Nothing) Then
            ' Get the 'DirectoryEntry' that corresponds to 'mySearchResult'.
            Dim myDirectoryEntry As DirectoryEntry
 = mySearchResult.GetDirectoryEntry()
            Console.WriteLine(ControlChars.Newline + "The name of
 the 'myDirectoryEntry' " + _
                        "directory entry that corresponds to the
 " + _
                        "'mySearchResult' search result is : {0}"
 + _
                        ControlChars.Newline, myDirectoryEntry.Name)
            Dim mySearchResultPath As String
 = mySearchResult.Path
            Console.WriteLine("The path for the 'mySearchResult'
 search result is : {0}" + _
                              ControlChars.Newline, mySearchResultPath)
            ' Get the properties of the 'mySearchResult'.
            Dim myResultPropColl As ResultPropertyCollection
            myResultPropColl = mySearchResult.Properties
            Console.WriteLine("The properties of the 'mySearchResult'
 are :")
            Dim myKey As String
            For Each myKey In
  myResultPropColl.PropertyNames
               Dim tab1 As String
 = "    "
               Console.WriteLine(myKey + " = ")
               Dim myCollection As Object
               For Each myCollection In
  myResultPropColl(myKey)
                  Console.WriteLine(tab1 + myCollection)
               Next myCollection
            Next myKey
            myDirectoryEntry.Dispose()
            mySearchRoot.Dispose()
         Else
            Console.WriteLine("The '" + myLDAPPath + "'
 path not found.")
         End If
      Catch e As Exception
         Console.WriteLine("The '" + myLDAPPath + "'
 path not found.")
         Console.WriteLine("Exception : " & e.Message)
      End Try
   End Sub 'Main
End Class 'MySample
using System;
using System.DirectoryServices;

public class MySample
{
    public static void Main()
    {
        string myLDAPPath = "";
        try
        {
            // Create a 'DirectoryEntry' object to search.
            Console.WriteLine("Enter the path ( Ex : 'LDAP://MyServer')");
            myLDAPPath = Console.ReadLine();

            DirectoryEntry mySearchRoot = new DirectoryEntry(myLDAPPath);
            DirectorySearcher myDirectorySearcher = 
                    new DirectorySearcher(mySearchRoot);

            // Get the first entry of the search.
            SearchResult mySearchResult = myDirectorySearcher.FindOne();

            if ( mySearchResult != null )
            {
                // Get the 'DirectoryEntry' that
 corresponds to 'mySearchResult'.
                DirectoryEntry myDirectoryEntry = 
                mySearchResult.GetDirectoryEntry();
                Console.WriteLine("\nThe name of the 'myDirectoryEntry'
 " +
                        "directory entry that corresponds to the
 " +
                        "'mySearchResult' search result is : {0}\n"
,
                        myDirectoryEntry.Name);
                string mySearchResultPath = mySearchResult.Path;
                Console.WriteLine("The path for the 'mySearchResult'
 search "
                        + "result is : {0}\n", mySearchResultPath);

                // Get the properties of the
 'mySearchResult'.
                ResultPropertyCollection myResultPropColl;
                myResultPropColl = mySearchResult.Properties;
                Console.WriteLine("The properties of the "
 + 
                        "'mySearchResult' are :");

                foreach( string myKey in myResultPropColl.PropertyNames)
                {
                    string tab = "    ";
                    Console.WriteLine(myKey + " = ");
                    foreach( Object myCollection in
 myResultPropColl[myKey])
                    {
                        Console.WriteLine(tab + myCollection);
                    }
                }
                mySearchRoot.Dispose();
                myDirectoryEntry.Dispose();
            }
            else
            {
                Console.WriteLine("The '" + myLDAPPath + "'
 path not found.");
            }
        }
        catch(Exception e)
        {
            Console.WriteLine("The '" + myLDAPPath + "'
 path not found.");
            Console.WriteLine("Exception : " + e.Message);
        }
    }

}
#using <mscorlib.dll>
#using <System.dll>
#using <System.Directoryservices.dll>

using namespace System;
using namespace System::Collections;
using namespace System::DirectoryServices;
using namespace stdcli::language;

int main() 
{
    String^ myLDAPPath = "";
    try 
    {
        // Create a 'DirectoryEntry' object to search.
        Console::WriteLine("Enter the path ( Ex : 'LDAP://MyServer')");
        myLDAPPath = Console::ReadLine();
        DirectoryEntry^ mySearchRoot = gcnew DirectoryEntry(myLDAPPath);

        DirectorySearcher^ myDirectorySearcher = gcnew DirectorySearcher(mySearchRoot);

        // Get the first entry of the search.
        SearchResult^ mySearchResult = myDirectorySearcher->FindOne();
        if (mySearchResult) 
        {
            // Get the 'DirectoryEntry' that corresponds
 to 'mySearchResult'.
            DirectoryEntry^ myDirectoryEntry = mySearchResult->GetDirectoryEntry();
            Console::WriteLine(
                String::Concat("\nThe name of
 the 'myDirectoryEntry' ",
                "directory entry that corresponds to the "
,
                "'mySearchResult' search result is : {0}\n")
,
                myDirectoryEntry->Name);

            String^ mySearchResultPath = mySearchResult->Path;
            Console::WriteLine("The path for the 'mySearchResult'
 search result is :
                    {0}\n", mySearchResultPath);

            // Get the properties of the 'mySearchResult'.
            ResultPropertyCollection^ myResultPropColl = mySearchResult->Properties;
            Console::WriteLine("The properties of the 'mySearchResult'
 are :");
            IEnumerator^ myEnum = myResultPropColl->PropertyNames->GetEnumerator();
            while (myEnum->MoveNext()) 
            {
                String^ myKey = safe_cast<String^>(myEnum->Current);
                Console::WriteLine("{0} = ", myKey);
                IEnumerator^ myEnum = myResultPropColl->Item[myKey]->GetEnumerator();
                while (myEnum->MoveNext()) 
                {
                    Console::WriteLine("\t{0}", myEnum->Current);
                }
            }
            myDirectoryEntry->Dispose();
            mySearchRoot->Dispose(); 
        } 
        else 
        {
            Console::WriteLine("The '{0}' path not found.",
 myLDAPPath);
        }
    } 
    catch (Exception^ e) 
    {
        Console::WriteLine("The '{0}' path not found.",  myLDAPPath);
        Console::WriteLine("Exception : {0}", e->Message);
    }
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
  • DirectoryServicesPermission  LinkDemand
継承階層継承階層
System.Object
  System.DirectoryServices.SearchResult
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

SearchResult プロパティ


SearchResult メソッド


SearchResult メンバ

SearchResult クラスは、DirectorySearcher を使用した検索中に返される Active Directory 階層ノードカプセル化ます。

SearchResult データ型公開されるメンバを以下の表に示します


パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Path SearchResultパス取得します
パブリック プロパティ Properties このオブジェクトプロパティの ResultPropertyCollection コレクション取得します
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

SearchResult クラス
System.DirectoryServices 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からSearchResultを検索した結果を表示しています。
Weblioに収録されているすべての辞書からSearchResultを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からSearchResult を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「SearchResult」の関連用語

SearchResultのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SearchResultのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS