Editar

Compartir a través de


SearchResult.Properties Property

Definition

Gets a ResultPropertyCollection collection of properties for this object.

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

Property Value

A ResultPropertyCollection of properties set on this object.

Examples

The following example is an excerpt of the example in SearchResult. The original example creates a new DirectoryEntry object with the desired path and uses the FindOne method to initiate the search. After performing the search, the example uses the GetDirectoryEntry method to retrieve the live directory entry that is identified in the search results.

In this example, the search result is put into a ResultPropertyCollection. Then, each property is displayed to the console window.

' 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);  
    }  
}  

Remarks

This collection only contains properties that were explicitly requested through DirectorySearcher.PropertiesToLoad.

Applies to