コンテナの新しいエントリを作成する要求を作成します。
Public Function Add( _
ByVal name As String, _ ByVal schemaClassName As String _) As DirectoryEntry
[C#]
public DirectoryEntry Add(stringname,stringschemaClassName);
[C++]
public: DirectoryEntry* Add(String* name,String* schemaClassName);
[JScript]
public function Add(
name : String,schemaClassName : String) : DirectoryEntry;
パラメータ
- name
新しいエントリの名前。 - schemaClassName
この新しいエントリで使用するスキーマの名前。
戻り値
新しいエントリを表す DirectoryEntry 。
例外
例外の種類 | 条件 |
---|---|
COMException | 基になるインターフェイスを呼び出すときにエラーが発生しました。 |
解説
メモ 作成を永続的にするには、新しいエントリの CommitChanges メソッドを呼び出す必要があります。これによって、新しいエントリの必須プロパティ値を設定できます。 CommitChanges メソッドを呼び出す前に設定する必要があるプロパティの要件は、プロバイダによって異なります。この要件を満たさない場合は、プロバイダによって例外がスローされることがあります。プロバイダを確認して、変更をコミットする前に設定する必要があるプロパティを判断してください。
使用例
[Visual Basic, C#, C++] 指定したパスを持つ新しい DirectoryEntry を作成し、そのコンテナ内に新しいエントリを作成し、それを保存する例を次に示します。
Dim strPath As String = "IIS://localhost/W3SVC/1/Root"
' Create a new 'DirectoryEntry' 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("Sample", myDE.SchemaClassName)
' Save changes of entry in the 'Active Directory'.
myDirectoryEntry.CommitChanges()
Console.WriteLine(myDirectoryEntry.Name + " entry is created in container.")
[C#]
String strPath = "IIS://localhost/W3SVC/1/Root";
// Create a new 'DirectoryEntry' 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("Sample", myDE.SchemaClassName);
// Save changes of entry in the 'Active Directory'.
myDirectoryEntry.CommitChanges();
Console.WriteLine (myDirectoryEntry.Name + " entry is created in container.");
[C++]
String* strPath = S"IIS://localhost/W3SVC/1/Root";
// Create a new 'DirectoryEntry' 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"Sample", myDE->SchemaClassName);
// Save changes of entry in the 'Active Directory'.
myDirectoryEntry->CommitChanges();
Console::WriteLine("{0} entry is created in container.", myDirectoryEntry->Name);
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
.NET Framework セキュリティ:
- 直前の呼び出し元の完全信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細の参照先 : 部分信頼コードからのライブラリの使用
参照
DirectoryEntries クラス | DirectoryEntries メンバ | System.DirectoryServices 名前空間 | DirectoryEntry