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

            [Conditional("DEBUG")]

            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. 

 

posted @ Thursday, April 20, 2006 11:04 AM

Print

Comments on this entry:

# re: Function to Print DirectoryEntry properties

Left by butelmx at 10/23/2007 6:34 AM
Gravatar
Nice little snippet. Helped me out alot

# re: Function to Print DirectoryEntry properties

Left by Neo at 12/19/2007 6:34 AM
Gravatar
It is really a nice piece of code. Thanks for sharing it.

# re: Function to Print DirectoryEntry properties

Left by Deepak at 6/11/2008 5:33 PM
Gravatar
This was very handy. Thanks.

# re: Function to Print DirectoryEntry properties

Left by sandy at 7/29/2008 3:11 AM
Gravatar
awesome man. this is really handy. thanks!

Your comment:



 (will not be displayed)


 
 
 
Please add 5 and 6 and type the answer here:
 

Live Comment Preview:

 
«August»
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456