Geeks With Blogs

Michael Freidgeim's Blog MS .Net Development

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 on Thursday, April 20, 2006 11:04 AM | Back to top


Comments on this post: Function to Print DirectoryEntry properties

# re: Function to Print DirectoryEntry properties
Requesting Gravatar...
Nice little snippet. Helped me out alot
Left by butelmx on Oct 23, 2007 6:34 AM

# re: Function to Print DirectoryEntry properties
Requesting Gravatar...
It is really a nice piece of code. Thanks for sharing it.
Left by Neo on Dec 19, 2007 6:34 AM

# re: Function to Print DirectoryEntry properties
Requesting Gravatar...
This was very handy. Thanks.
Left by Deepak on Jun 11, 2008 5:33 PM

# re: Function to Print DirectoryEntry properties
Requesting Gravatar...
awesome man. this is really handy. thanks!
Left by sandy on Jul 29, 2008 3:11 AM

# re: Function to Print DirectoryEntry properties
Requesting 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.
Left by Mad Coder on Sep 18, 2008 1:05 AM

# re: Function to Print DirectoryEntry properties
Requesting 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'?
Left by jim franks on Jan 21, 2009 3:27 PM

# re: Function to Print DirectoryEntry properties
Requesting Gravatar...
Thanks. Simple short and works.
Left by C++Rules on Mar 19, 2009 6:58 AM

# re: Function to Print DirectoryEntry properties
Requesting Gravatar...
Fantastic. A quick way to get properties!!!
Helped a lot. Thanks.
Left by Parag on Apr 15, 2009 5:16 PM

# re: Function to Print DirectoryEntry properties
Requesting Gravatar...
great job!!!
Left by adf on May 05, 2009 2:33 PM

# re: Function to Print DirectoryEntry properties
Requesting Gravatar...
it is handy and good
thanks
Left by web development company on Aug 14, 2009 11:26 AM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net | Join free