Langue

DirectoryEntries.Find Méthode

Définition

Retourne un membre de cette collection.

Surcharges

Nom Description
Find(String)

Retourne le membre de cette collection avec le nom spécifié.

Find(String, String)

Retourne le membre de cette collection avec le nom spécifié et le type spécifié.

Find(String)

Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs

Retourne le membre de cette collection avec le nom spécifié.

public:
 System::DirectoryServices::DirectoryEntry ^ Find(System::String ^ name);
public System.DirectoryServices.DirectoryEntry Find(string name);
member this.Find : string -> System.DirectoryServices.DirectoryEntry
Public Function Find (name As String) As DirectoryEntry

Paramètres

name
String

Contient le nom de l’objet enfant pour lequel effectuer une recherche.

Retours

Qui DirectoryEntry représente l’objet enfant trouvé.

Exceptions

L’objet services de domaine Active Directory n’est pas un conteneur.

Une erreur s’est produite pendant l’appel à l’interface sous-jacente.

Remarques

Si les objets enfants de différents types ont le même nom, le premier objet enfant correspondant est retourné.

Note

Le fournisseur Internet Information Services (IIS) ne prend pas en charge cette méthode. Utilisez la méthode surchargée Find et spécifiez une chaîne vide («  ») pour le schemaClassName paramètre.

Si aucun résultat correspondant n’est trouvé, un DirectoryServicesCOMException code d’erreur 0x2030 est levée.

S’applique à

Find(String, String)

Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs
Source:
DirectoryEntries.cs

Retourne le membre de cette collection avec le nom spécifié et le type spécifié.

public:
 System::DirectoryServices::DirectoryEntry ^ Find(System::String ^ name, System::String ^ schemaClassName);
public System.DirectoryServices.DirectoryEntry Find(string name, string? schemaClassName);
public System.DirectoryServices.DirectoryEntry Find(string name, string schemaClassName);
member this.Find : string * string -> System.DirectoryServices.DirectoryEntry
Public Function Find (name As String, schemaClassName As String) As DirectoryEntry

Paramètres

name
String

Nom de l’objet de répertoire enfant pour lequel effectuer une recherche.

schemaClassName
String

Nom de classe de l’objet de répertoire enfant pour lequel effectuer une recherche.

Retours

Objet DirectoryEntry qui représente l’objet enfant trouvé.

Exceptions

L’objet services de domaine Active Directory n’est pas un conteneur.

Une erreur s’est produite pendant l’appel à l’interface sous-jacente.

Exemples

L’exemple suivant crée un DirectoryEntry objet avec le chemin d’accès spécifié, puis crée une entrée dans le conteneur et l’enregistre. Il tente de récupérer l’entrée nouvellement créée.

Try
     Dim myEntry1 As DirectoryEntry
     Dim myEntry2 As DirectoryEntry
     Dim strPath As String = "LDAP://DC=fabrikam,DC=com"

     ' Create a 'DirectoryEntry' object with the given path.
     Dim myDE As New DirectoryEntry(strPath)
     Dim myEntries As DirectoryEntries = myDE.Children

     ' Create a new entry in the container.
     myEntry1 = myEntries.Add("CN=Sample Entry", myDE.SchemaClassName)
     ' Save changes in the 'Active Directory Domain Services' store.
     myEntry1.CommitChanges()

     ' Find a child in the 'DirectoryEntries' collection which has the
     ' specified name and type.
     myEntry2 = myEntries.Find("CN=Sample Entry", myDE.SchemaClassName)
     Console.WriteLine(myEntry2.Name + " is found in container.")

     Catch e As Exception
          Console.WriteLine("The following exception was raised : {0}", e.Message.ToString())
     End Try
using System;
using System.DirectoryServices;

class MyClass1
{
   static void Main()
   {
      try
      {
         DirectoryEntry myEntry1;
         DirectoryEntry myEntry2;
         String strPath = "LDAP://DC=fabrikam,DC=com";

         // Create a 'DirectoryEntry' object with the given path.
         DirectoryEntry myDE = new DirectoryEntry(strPath);
         DirectoryEntries myEntries = myDE.Children;

         // Create a new entry in the container.
         myEntry1 = myEntries.Add("CN=Sample Entry",myDE.SchemaClassName);
         // Save changes in the 'Active Directory Domain Services' store.
         myEntry1.CommitChanges();

         // Find a child in the 'DirectoryEntries' collection which has the
         // specified name and type.
         myEntry2 = myEntries.Find("CN=Sample Entry",myDE.SchemaClassName);
         Console.WriteLine (myEntry2.Name + " is found in container.");

      }
      catch(Exception e)
      {
         Console.WriteLine("The following exception was raised : {0}",e.Message);
      }
   }
}

Remarques

Si aucun résultat correspondant n’est trouvé, un DirectoryServicesCOMException code d’erreur 0x2030 est levée.

S’applique à