DirectoryEntries.Add(String, String) DirectoryEntries.Add(String, String) DirectoryEntries.Add(String, String) DirectoryEntries.Add(String, String) Method

定義

コンテナーに新しいエントリを作成します。Creates a new entry in the container.

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 String String String

新しいエントリの名前。The name of the new entry.

schemaClassName
String String String String

新しいエントリで使用されるスキーマの名前。The name of the schema that is used for the new entry.

戻り値

新しいエントリを表す DirectoryEntry オブジェクト。A DirectoryEntry object that represents the new entry.

例外

基になるインターフェイスへの呼び出し中にエラーが発生しました。An error occurred during the call to the underlying interface.

次の Visual Basic .NET の例は、新しい作成DirectoryEntryオブジェクトのパスを指定して、コンテナーに新しいエントリを作成し、保存します。The following Visual Basic .NET example creates a new DirectoryEntry object with a specified path, then creates a new entry in the container and saves it.

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オブジェクトのパスを指定して、コンテナーに新しいエントリを作成し、保存します。The following C# example creates a new DirectoryEntry object with a specified path, then creates a new entry in the container and saves it.

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オブジェクトのパスを指定して、コンテナーに新しいエントリを作成し、保存します。The following C++ example creates a new DirectoryEntry object with a specified path, then creates a new entry in the container and saves it.

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永続的な作成できるように、新しいエントリのメソッド。You must call the CommitChanges method on the new entry to make the creation permanent. このメソッドを呼び出すときに、新しいエントリの必須プロパティの値を設定できます。When you call this method, you can then set mandatory property values on the new entry. 各プロバイダーのプロパティを呼び出す前に設定する必要があるさまざまな要件がある、CommitChangesメソッドを作成します。The providers each have different requirements for properties that need to be set before a call to the CommitChanges method is made. それらの要件が満たされていない場合、プロバイダーは例外をスローします。If those requirements are not met, the provider might throw an exception. 確認、プロバイダーの変更をコミットする前にプロパティを設定する必要がありますかを確認してください。Check with your provider to determine which properties must be set before committing changes.

適用対象