473,320 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

brain frozen on enumerator

Hi. I am trying to understand the weird System.DirectoryServices object
model. I have a DirectoryEntry object. I want to enumerate through the
PropertyCollection. So I looked at GetEnumerator. Lovely. My memory cannot
dredge up how to use an enumerator. I do not understand the documentation,
whcih does not contain little code snippets of examples like MSDN Oct 2001
for older technologies did. Can someone give me an enumerator basics 101
reference? I cannot find one.

DirectoryEntry test = new DirectoryEntry("IIS://" + serverName +
"/w3svc/1/root", serverName + "\\administrator", password,
AuthenticationTypes.Secure);
DirectoryEntry schema = test.SchemaEntry;

I want to loop through schema and look at all the property names and values.

Thanks
Nov 16 '05 #1
2 1482
An enumerator will implement IEnumerator. An enumerator basically iterates
some list and enables you to get the items in order.

When you get an enumerator it will be primed and ready to get the first item
in the list. You index each item with the MoveNext command so you can do...

while(myEnumerator.MoveNext())
{
//do something with myEnumerator.Current here
}
//we get here when the list is exhausted

Probably the easiest way to use an enumerator is in conjunction with the
foreach statement so you might do something like:

foreach(string s in test.SchemaEntry.Properties.PropertyNames)
Console.WriteLine(s);

This will dump the names of the properties in the directory entry
--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Stephanie Stowe" <No****@IWishICould.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Hi. I am trying to understand the weird System.DirectoryServices object
model. I have a DirectoryEntry object. I want to enumerate through the
PropertyCollection. So I looked at GetEnumerator. Lovely. My memory cannot
dredge up how to use an enumerator. I do not understand the documentation,
whcih does not contain little code snippets of examples like MSDN Oct 2001
for older technologies did. Can someone give me an enumerator basics 101
reference? I cannot find one.

DirectoryEntry test = new DirectoryEntry("IIS://" + serverName + "/w3svc/1/root", serverName + "\\administrator", password,
AuthenticationTypes.Secure);
DirectoryEntry schema = test.SchemaEntry;

I want to loop through schema and look at all the property names and values.
Thanks

Nov 16 '05 #2
Ah. Lights turning on and things are warming up. Thanks.
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:uT**************@TK2MSFTNGP14.phx.gbl...
An enumerator will implement IEnumerator. An enumerator basically iterates
some list and enables you to get the items in order.

When you get an enumerator it will be primed and ready to get the first item in the list. You index each item with the MoveNext command so you can do...
while(myEnumerator.MoveNext())
{
//do something with myEnumerator.Current here
}
//we get here when the list is exhausted

Probably the easiest way to use an enumerator is in conjunction with the
foreach statement so you might do something like:

foreach(string s in test.SchemaEntry.Properties.PropertyNames)
Console.WriteLine(s);

This will dump the names of the properties in the directory entry
--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Stephanie Stowe" <No****@IWishICould.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Hi. I am trying to understand the weird System.DirectoryServices object
model. I have a DirectoryEntry object. I want to enumerate through the
PropertyCollection. So I looked at GetEnumerator. Lovely. My memory cannot dredge up how to use an enumerator. I do not understand the documentation, whcih does not contain little code snippets of examples like MSDN Oct 2001 for older technologies did. Can someone give me an enumerator basics 101
reference? I cannot find one.

DirectoryEntry test = new DirectoryEntry("IIS://" +
serverName +
"/w3svc/1/root", serverName + "\\administrator", password,
AuthenticationTypes.Secure);
DirectoryEntry schema = test.SchemaEntry;

I want to loop through schema and look at all the property names and

values.

Thanks


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul | last post by:
Hi I'm trying to build a standalone COM exe server using Python 2.2 + Mark Hammond's windows extensions + Py2Exe. I've built the example linked on the Py2Exe homepage and get this error when...
47
by: Will Stuyvesant | last post by:
Hello all, So Zope still lives, yay. Well, I like that they use Python. <rant> What amazed me is they write that they "added types to the variables and hope that it will be added to the...
6
by: Michael C | last post by:
I'm reading about Iterators and the article I'm reading states that an enumerator must load all of the objects into memory, which is obviously a big waste if there are a large number of objects and...
1
by: ronnysaid | last post by:
Hi all, I was wondering if there is a way to get the range from the frozen panes in excel using interop v.12?? Or is there a property associated with the range indicating its frozen or not?? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.