Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 146287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:34:32+00:00 2026-05-11T08:34:32+00:00

Can anyone provide an example of how to loop through a System.DirectoryServices.PropertyCollection and output

  • 0

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));                             }         }           }   } 
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:34:32+00:00Added an answer on May 11, 2026 at 8:34 am

    The PropertyCollection has a PropertyName collection – which is a collection of strings (see PropertyCollection.Contains and PropertyCollection.Item both of which take a string).

    You can usually call GetEnumerator to allow you to enumerate over the collection, using the usual enumeration methods – in this case you’d get an IDictionary containing the string key, and then an object for each item/values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone provide an example of using HTTParty using digest auth? I can't find
Can anyone provide an example of a system in which a performance improvement of
Can anyone provide a clear example of how to remove a supercolumn in Java
Can anyone provide me an example of how to use WM_CLOSE to close a
Can anyone provide me with a hello world example for a major mode in
I could really use an example of this. Can anyone provide me with a
Can anyone provide details on what the three of these mean? System::ContainerStartTime System::CreationDate System::StartTime
Can anyone provide an example of a singleton pattern and explain why they are
Can anyone provide an example of an ant build which checks if all files
Can anyone provide complete example of Stored Procedure call with Spring framework. Thanks, Raj

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.