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显式请求的属性。

适用于