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 必須設定的屬性有不同的要求。 若未符合這些條件,醫療提供者可能會提出例外。 在做出更改前,請先向你的醫療提供者確認哪些屬性必須設定。