Share via


DirectoryEntries.Find Metoda

Definice

Vrátí člena této kolekce.

Přetížení

Find(String)

Vrátí člena této kolekce se zadaným názvem.

Find(String, String)

Vrátí člena této kolekce se zadaným názvem a zadaným typem.

Find(String)

Zdroj:
DirectoryEntries.cs
Zdroj:
DirectoryEntries.cs
Zdroj:
DirectoryEntries.cs

Vrátí člena této kolekce se zadaným názvem.

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

Parametry

name
String

Obsahuje název podřízeného objektu, pro který se má hledat.

Návraty

A DirectoryEntry , který představuje nalezený podřízený objekt.

Výjimky

Objekt Active Directory Domain Services není kontejner.

Během volání základního rozhraní došlo k chybě.

Poznámky

Pokud mají podřízené objekty různých typů stejný název, vrátí se první odpovídající podřízený objekt.

Poznámka

Zprostředkovatel Internetové informační služby (IIS) tuto metodu nepodporuje. Použijte přetíženou Find metodu a jako schemaClassName parametr zadejte prázdný řetězec ("").

Pokud se nenajde žádný odpovídající výsledek, DirectoryServicesCOMException vyvolá se kód chyby s 0x2030.

Platí pro

Find(String, String)

Zdroj:
DirectoryEntries.cs
Zdroj:
DirectoryEntries.cs
Zdroj:
DirectoryEntries.cs

Vrátí člena této kolekce se zadaným názvem a zadaným typem.

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

Parametry

name
String

Název podřízeného objektu adresáře, pro který se má hledat.

schemaClassName
String

Název třídy podřízeného objektu adresáře, pro který se má hledat.

Návraty

Objekt DirectoryEntry , který představuje nalezený podřízený objekt.

Výjimky

Objekt Active Directory Domain Services není kontejner.

Během volání základního rozhraní došlo k chybě.

Příklady

Následující příklad jazyka Visual Basic .NET vytvoří nový DirectoryEntry objekt se zadanou cestou, pak vytvoří novou položku v kontejneru a uloží ji. Pokusí se načíst nově vytvořenou položku.

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  

Následující příklad jazyka C# ukazuje, jak vytvořit nový DirectoryEntry objekt se zadanou cestou, pak v kontejneru vytvoří novou položku a uloží ji. Pokusí se načíst nově vytvořenou položku.

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);  
      }  
   }  
}  

Následující příklad jazyka C++ vytvoří nový DirectoryEntry objekt se zadanou cestou, pak vytvoří novou položku v kontejneru a uloží ji. Pokusí se načíst novou položku.

#using <mscorlib.dll>  
#using <System.dll>  
#using <System.Directoryservices.dll>  

using namespace System;  
using namespace System::DirectoryServices;   

int main() {  
    try {          
        DirectoryEntry* myEntry1;  
        DirectoryEntry* myEntry2;  
        String* strPath = S"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(S"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(S"CN=Sample Entry", myDE->SchemaClassName);  
        Console::WriteLine ("{0} is found in container.", myEntry2->Name);  
    } catch(Exception* e) {  
        Console::WriteLine("The following exception was raised : {0}", e->Message);  
    }  
}  

Poznámky

Pokud se nenajde žádný odpovídající výsledek, DirectoryServicesCOMException vyvolá se kód chyby s 0x2030.

Platí pro