共用方式為


SearchResult.Properties 屬性

定義

取得這個物件之屬性的 ResultPropertyCollection 集合。

public:
 property System::DirectoryServices::ResultPropertyCollection ^ Properties { System::DirectoryServices::ResultPropertyCollection ^ get(); };
public System.DirectoryServices.ResultPropertyCollection Properties { get; }
member this.Properties : System.DirectoryServices.ResultPropertyCollection
Public ReadOnly Property Properties As ResultPropertyCollection

屬性值

這個物件上屬性集的 ResultPropertyCollection

範例

下列範例是 中的 SearchResult範例摘錄。 原始範例會建立具有所需路徑的新 DirectoryEntry 物件,並使用 FindOne 方法來起始搜尋。 執行搜尋之後,此範例會 GetDirectoryEntry 使用 方法來擷取搜尋結果中所識別的實時目錄專案。

在這裡範例中,搜尋結果會放入 ResultPropertyCollection。 然後,每個屬性都會顯示在主控台視窗。

' Get the properties for '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  
// Get the properties for '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);  
   }  
}  
// Get the properties for '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);  
    }  
}  

備註

此集合只包含透過 DirectorySearcher.PropertiesToLoad明確要求的屬性。

適用於