Function to Print DirectoryEntry properties

When I debugging function that retrieved active directory properties, Visual Studio 2005 debugger show them as a collection , but not as an individual values. So I wrote function, copied from GetPropertyList function from LDAP, IIS and WinNT Directory Services  article written by


            public static void PrintDirectoryEntryProperties(System.DirectoryServices.DirectoryEntry entry, string sComment)


            // loop through all the properties and get the key for each

            foreach (string Key in entry.Properties.PropertyNames)


                string sPropertyValues = String.Empty;

                // now loop through all the values in the property;

                // can be a multi-value property

                foreach (object Value in entry.Properties[Key])

                    sPropertyValues += Convert.ToString(Value) + “;”;

                // cut off the separator at the end of the value list

                sPropertyValues = sPropertyValues.Substring(0, sPropertyValues.Length – 1);

                // now add the property info to the property list

                Debug.WriteLine(Key + “=” + sPropertyValues);



Ideally it should be possible to write  Debug Visualizer for them.