469,909 Members | 1,757 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

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 1381
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 discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.