Share via


DirectoryEntries.Find Yöntem

Tanım

Bu koleksiyonun bir üyesini döndürür.

Aşırı Yüklemeler

Find(String)

Belirtilen ada sahip bu koleksiyonun üyesini döndürür.

Find(String, String)

Belirtilen ada ve belirtilen türe sahip bu koleksiyonun üyesini döndürür.

Find(String)

Kaynak:
DirectoryEntries.cs
Kaynak:
DirectoryEntries.cs
Kaynak:
DirectoryEntries.cs

Belirtilen ada sahip bu koleksiyonun üyesini döndürür.

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

Parametreler

name
String

Aranacak alt nesnenin adını içerir.

Döndürülenler

DirectoryEntry Bulunan alt nesneyi temsil eden bir.

Özel durumlar

Active Directory Domain Services nesnesi bir kapsayıcı değil.

Temel alınan arabirime yapılan çağrı sırasında bir hata oluştu.

Açıklamalar

Farklı türlerdeki alt nesneler aynı ada sahipse, eşleşen ilk alt nesne döndürülür.

Not

Internet Information Services (IIS) sağlayıcısı bu yöntemi desteklemiyor. Aşırı yüklenmiş Find yöntemini kullanın ve parametresi için schemaClassName boş bir dize ("") belirtin.

Eşleşen sonuç bulunmazsa, hata kodu 0x2030 içeren bir DirectoryServicesCOMException oluşturulur.

Şunlara uygulanır

Find(String, String)

Kaynak:
DirectoryEntries.cs
Kaynak:
DirectoryEntries.cs
Kaynak:
DirectoryEntries.cs

Belirtilen ada ve belirtilen türe sahip bu koleksiyonun üyesini döndürür.

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

Parametreler

name
String

Aranacak alt dizin nesnesinin adı.

schemaClassName
String

Aranacak alt dizin nesnesinin sınıf adı.

Döndürülenler

DirectoryEntry Bulunan alt nesneyi temsil eden nesne.

Özel durumlar

Active Directory Domain Services nesnesi bir kapsayıcı değil.

Temel alınan arabirime yapılan çağrı sırasında bir hata oluştu.

Örnekler

Aşağıdaki Visual Basic .NET örneği, belirtilen yola sahip yeni DirectoryEntry bir nesne oluşturur, ardından kapsayıcıda yeni bir giriş oluşturur ve bunu kaydeder. Yeni oluşturulan girdiyi almaya çalışır.

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  

Aşağıdaki C# örneği, belirtilen yola sahip yeni DirectoryEntry bir nesnenin nasıl oluşturulacağını gösterir, ardından kapsayıcıda yeni bir giriş oluşturur ve bunu kaydeder. Yeni oluşturulan girdiyi almaya çalışır.

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

Aşağıdaki C++ örneği, belirtilen yola sahip yeni DirectoryEntry bir nesne oluşturur, ardından kapsayıcıda yeni bir giriş oluşturur ve bunu kaydeder. Yeni girişi almayı dener.

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

Açıklamalar

Eşleşen sonuç bulunmazsa, hata kodu 0x2030 içeren bir DirectoryServicesCOMException oluşturulur.

Şunlara uygulanır