DirectoryEntries.Add(String, String) 메서드

정의

컨테이너에 새 엔트리를 만듭니다.

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

매개 변수

name
String

새 엔트리의 이름입니다.

schemaClassName
String

새 엔트리에 사용된 스키마 이름입니다.

반환

DirectoryEntry

새 엔트리를 나타내는 DirectoryEntry 개체입니다.

예외

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

예제

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

Dim strPath As String = "IIS://localhost/W3SVC/1/Root"  
' Create a new 'DirectoryEntry' object with the given path.  
Dim myDE As New DirectoryEntry(strPath)  
Dim myEntries As DirectoryEntries = myDE.Children  
' Create a new entry 'Sample' in the container.  
Dim myDirectoryEntry As DirectoryEntry = myEntries.Add("CN=Sample", myDE.SchemaClassName)  
' Save changes of entry in the 'Active Directory Domain Services'.  
myDirectoryEntry.CommitChanges()  
Console.WriteLine(myDirectoryEntry.Name + " entry is created in container.")  

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

String strPath = "IIS://localhost/W3SVC/1/Root";  

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

// Create a new entry 'Sample' in the container.  
DirectoryEntry myDirectoryEntry =   
   myEntries.Add("CN=Sample", myDE.SchemaClassName);  
// Save changes of entry in the 'Active Directory Domain Services'.  
myDirectoryEntry.CommitChanges();  
Console.WriteLine (myDirectoryEntry.Name + " entry is created in container.");  

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

String* strPath = S"IIS://localhost/W3SVC/1/Root";  

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

// Create a new entry 'Sample' in the container.  
DirectoryEntry* myDirectoryEntry = myEntries->Add(S"CN=Sample", myDE->SchemaClassName);  
// Save changes of entry in the 'Active Directory Domain Services'.  
myDirectoryEntry->CommitChanges();  
Console::WriteLine("{0} entry is created in container.", myDirectoryEntry->Name);  

설명

호출 해야 합니다 CommitChanges 메서드 생성을 영구적으로 유지 되도록 새 항목입니다. 이 메서드를 호출 하면 새 항목에 필수 속성 값을 설정할 수 있습니다. 각 공급자 요구 사항이 서로 다를 호출 하기 전에 설정 해야 하는 속성에 대 한는 CommitChanges 메서드 구성 됩니다. 이러한 요구 사항을 충족 되지 않으면, 공급자 예외가 throw 될 수 있습니다. 변경 내용을 커밋하기 전에 설정 해야 하는 속성을 확인 하려면 공급자를 사용 하 여 확인 합니다.

적용 대상