Can anyone provide an example of how to loop through a System.DirectoryServices.PropertyCollection and output the property name and value?
I am using C#.
@JaredPar - The PropertyCollection does not have a Name/Value property. It does have a PropertyNames and Values, type System.Collection.ICollection. I do not know the basline object type that makes up the PropertyCollection object.
@JaredPar again - I originally mislabeled the question with the wrong type. That was my bad.
Update: Based on Zhaph - Ben Duguid input, I was able to develop the following code.
using System.Collections;
using System.DirectoryServices;
public void DisplayValue(DirectoryEntry de)
{
if(de.Children != null)
{
foreach(DirectoryEntry child in de.Children)
{
PropertyCollection pc = child.Properties;
IDictionaryEnumerator ide = pc.GetEnumerator();
ide.Reset();
while(ide.MoveNext())
{
PropertyValueCollection pvc = ide.Entry.Value as PropertyValueCollection;
Console.WriteLine(string.Format("Name: {0}", ide.Entry.Key.ToString()));
Console.WriteLine(string.Format("Value: {0}", pvc.Value);
}
}
}
}