Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Para enumerar los objetos de un contenedor, cree un objeto DirectoryEntry que pueda utilizar para contener cada objeto y sus propiedades. A continuación, puede utilizar las propiedades proporcionadas por DirectoryEntry para obtener datos, por ejemplo, el atributo de nombre. Es posible ejecutar una iteración en cada objeto del contendor utilizando la instrucción Using foreach with Arrays.
El siguiente ejemplo de código muestra cómo enumerar un contendor de usuario.
Try
' Bind to the container to enumerate.
Dim ent As New DirectoryEntry("LDAP://CN=users,OU=Marketing,DC=fabrikam,DC=com")
' Create an object to use for individual objects in the container and iterate
' through the container.
Dim child As DirectoryEntry
For Each child In ent.Children
' Write the name and path for each object in the container.
Console.WriteLine("{0} {1}", child.Name, child.Path)
Next child
Catch Exception1 As Exception
' Handle errors.
End Try
try
{
// Bind to the container to enumerate.
DirectoryEntry ent = new DirectoryEntry("LDAP://CN=users,OU=Marketing,DC=fabrikam,DC=com");
// Create an object to use for individual objects in the container and iterate
// through the container.
foreach( DirectoryEntry child in ent.Children)
{
// Write the name and path for each object in the container.
Console.WriteLine( "{0} {1}", child.Name, child.Path);
}
}
catch
{
// Handle errors.
}
Consulte también
Referencia
System.DirectoryServices
DirectoryEntry
Conceptos
Send comments about this topic to Microsoft.
Copyright © 2007 Microsoft Corporation. Reservados todos los derechos.