DirectoryEntries.Find 메서드

정의

이 컬렉션의 멤버를 반환합니다.

오버로드

Find(String)

지정된 이름을 가진 이 컬렉션의 멤버를 반환합니다.

Find(String, String)

지정된 이름을 가진 지정된 형식의 이 컬렉션 멤버를 반환합니다.

Find(String)

지정된 이름을 가진 이 컬렉션의 멤버를 반환합니다.

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

매개 변수

name
String

검색할 자식 개체의 이름을 포함합니다.

반환

DirectoryEntry

찾은 자식 개체를 나타내는 DirectoryEntry입니다.

예외

Active Directory 도메인 서비스 개체가 컨테이너가 아닌 경우

기본 인터페이스를 호출하는 동안 오류가 발생한 경우

설명

다른 형식의 자식 개체 이름이 동일한 경우 첫 번째 일치 하는 자식 개체가 반환 됩니다.

참고

인터넷 정보 서비스 (IIS) 공급자는이 메서드를 지원 하지 않습니다. 사용 하 여 오버 로드 된 Find 메서드 빈 문자열을 지정 하 고 ("")에 대 한는 schemaClassName 매개 변수입니다.

일치 하는 결과가 없습니다. 있으면는 DirectoryServicesCOMException 오류 코드 0x2030과 throw 됩니다.

적용 대상

Find(String, String)

지정된 이름을 가진 지정된 형식의 이 컬렉션 멤버를 반환합니다.

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

매개 변수

name
String

검색할 자식 디렉터리 개체의 이름입니다.

schemaClassName
String

검색할 자식 디렉터리 개체의 클래스 이름입니다.

반환

DirectoryEntry

찾은 자식 개체를 나타내는 DirectoryEntry 개체입니다.

예외

Active Directory 도메인 서비스 개체가 컨테이너가 아닌 경우

기본 인터페이스를 호출하는 동안 오류가 발생한 경우

예제

다음 Visual Basic.NET 예제에서는 새 DirectoryEntry 지정된 된 경로 사용 하 여 개체, 한 다음 컨테이너에 새 항목을 만듭니다 및 저장 합니다. 새로 만든된 항목을 검색 하려고 합니다.

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  

다음 C# 예제에서는 새로 만드는 방법을 보여 줍니다 DirectoryEntry 지정된 된 경로 사용 하 여 개체, 한 다음 컨테이너에 새 항목을 만듭니다 및 저장 합니다. 검색 하려고 시도 하는 새로-항목을 생성 합니다.

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

다음 c + + 예제에서는 새 DirectoryEntry 지정된 된 경로 사용 하 여 개체, 한 다음 컨테이너에 새 항목을 만듭니다 및 저장 합니다. 새 항목을 검색 하려고 합니다.

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

설명

일치 하는 결과가 없습니다. 있으면는 DirectoryServicesCOMException 오류 코드 0x2030과 throw 됩니다.

적용 대상