Directory Services |
This topic shows how to identify properties that are currently in the property cache and how to refresh the property cache.
The PropertyNames property is used to find the names of all the properties that are presently in the property cache. The following code example shows how to use PropertyNames without refreshing the property cache.
try { // Create an empty DirectoryEntry object. DirectoryEntry ent = new DirectoryEntry(); // Use PropertyNames to iterate through the property names // that are presently in the cache. foreach(String propName in ent.Properties.PropertyNames) { // Write out the property names. Console.WriteLine(propName); } } catch { // Handle errors. }
The following code example shows how to refresh all of the properties in the property cache.
Try { // Create a DirectoryEntry object. DirectoryEntry ent = new DirectoryEntry(); // Refresh the cache. ent.RefreshCache(); } Catch { // Handle errors. }
The following code example shows how to refresh selected properties in the property cache using RefreshCache.
try { // Create a DirectoryEntry object. DirectoryEntry ent = new DirectoryEntry(); // Refresh the objectClass, dc, and whenCreated properties. ent.RefreshCache(new string[]{"objectClass","dc","whenCreated"}); // Iterate through each property name. foreach(String propName in ent.Properties.PropertyNames) { // Write the property names. There should only be three. Console.WriteLine(propName); } } catch { // Handle errors. }