SearchResult.Properties Property

 

Gets a ResultPropertyCollection collection of properties for this object.

Namespace:   System.DirectoryServices
Assembly:  System.DirectoryServices (in System.DirectoryServices.dll)

public ResultPropertyCollection Properties { get; }

Property Value

Type: System.DirectoryServices.ResultPropertyCollection

A ResultPropertyCollection of properties set on this object.

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

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

.NET Framework
Available since 1.1
Return to top
Show: