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!

# re: Function to Print DirectoryEntry properties

Left by Mad Coder at 9/18/2008 1:05 AM
Gravatar
I hope you've grown up since '06 and no longer prefix variables with "s" or pluralize singular valued variables a-la sPropertyValues nor include unused parameters "sComment" and by the way... this is a method, not a function.

# re: Function to Print DirectoryEntry properties

Left by jim franks at 1/21/2009 3:27 PM
Gravatar
Keeeeyrist MadCoder: Who died and annointed you king of all syntax?

And why would you care anyway - trolling for some young poon to 'train'?

# re: Function to Print DirectoryEntry properties

Left by C++Rules at 3/19/2009 6:58 AM
Gravatar
Thanks. Simple short and works.

# re: Function to Print DirectoryEntry properties

Left by Parag at 4/15/2009 5:16 PM
Gravatar
Fantastic. A quick way to get properties!!!
Helped a lot. Thanks.

# re: Function to Print DirectoryEntry properties

Left by adf at 5/5/2009 2:33 PM
Gravatar
great job!!!

# re: Function to Print DirectoryEntry properties

Left by web development company at 8/14/2009 11:26 AM
Gravatar
it is handy and good
thanks

Your comment:



(not displayed)

 
 
 
 
 

Live Comment Preview:

 
«October»
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678