DirectoryEntries.Add メソッド
名前空間: System.DirectoryServices
アセンブリ: System.DirectoryServices (system.directoryservices.dll 内)
構文


作成を永続的にするには、新しいエントリの CommitChanges メソッドを呼び出す必要があります。このメソッドを呼び出すと、新しいエントリの必須プロパティ値を設定できます。CommitChanges メソッドを呼び出す前に設定する必要があるプロパティの要件は、プロバイダによって異なります。この要件を満たさない場合は、プロバイダによって例外がスローされることがあります。プロバイダを確認して、変更をコミットする前に設定する必要があるプロパティを判断してください。

指定したパスを持つ新しい DirectoryEntry オブジェクトを作成し、そのコンテナ内に新しいエントリを作成し、それを保存する Visual Basic .NET コード例を次に示します。
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'. myDirectoryEntry.CommitChanges() Console.WriteLine(myDirectoryEntry.Name + " entry is created in container.")
指定したパスを持つ新しい DirectoryEntry オブジェクトを作成し、そのコンテナ内に新しいエントリを作成し、それを保存する C# コード例を次に示します。
[C#]
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'. myDirectoryEntry.CommitChanges(); Console.WriteLine (myDirectoryEntry.Name + " entry is created in container.");
指定したパスを持つ新しい DirectoryEntry オブジェクトを作成し、そのコンテナ内に新しいエントリを作成し、それを保存する C++ コード例を次に示します。
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'. myDirectoryEntry->CommitChanges(); Console::WriteLine("{0} entry is created in container.", myDirectoryEntry->Name);

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DirectoryEntries.Add メソッドのページへのリンク