DirectoryEntries.Add(String, String) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
コンテナーに新しいエントリを作成します。
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 オブジェクトを作成し、コンテナーに新しいエントリを作成して保存します。
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.")
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.");
注釈
作成を永続的にするには、新しいエントリで CommitChanges メソッドを呼び出す必要があります。 このメソッドを呼び出すと、新しいエントリに必須のプロパティ値を設定できます。 プロバイダーにはそれぞれ、 CommitChanges メソッドの呼び出しを行う前に設定する必要があるプロパティの要件が異なります。 これらの要件が満たされていない場合、プロバイダーは例外をスローする可能性があります。 変更をコミットする前に、どのプロパティを設定する必要があるかどうかをプロバイダーに確認してください。