0 out of 2 rated this helpful - Rate this topic

Reading Properties with Multiple Values 

This topic provides information and code examples for reading properties that contain multiple values. As with properties that contain a single value, properties with multiple values are read using the Value property from the PropertyValueCollection object.

For properties that contain multiple values, use either a foreach statement to retrieve a Properties collection, or enumerate property values using an array.

The following code example uses the Properties collection to read multiple values.


DirectoryEntry ent = new DirectoryEntry("LDAP://Fabrikam/CN=My Username,CN=Users,DC=Fabrikam,DC=com");
foreach(String s in ent.Properties["otherTelephone"] )
{
     Console.WriteLine(s);
} 

The following code example uses an array to read values.


DirectoryEntry ent = new DirectoryEntry("LDAP://Fabrikam/CN=My Username,CN=Users,DC=Fabrikam,DC=com");
{
     Console.WriteLine(ent.Properties["otherTelephone"][2]);
}

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.