建構的屬性
某些目錄屬性是建構的。除非特別指定,否則無法在查詢中傳回建構的屬性。如果使用 DirectoryEntry 類別傳回物件,則可使用 RefreshCache 方法來擷取建構的屬性。如果使用 DirectorySearcher,您將使用 PropertiesToLoad 屬性 (property) 來指定屬性 (Attribute) 名稱,其中可能包含建構的屬性。
下列程式碼範例示範如何讀取建構的屬性 allowedChildClasses。
Dim ent As New DirectoryEntry()
ent.RefreshCache(New String() {"allowedChildClasses"})
Dim prop As [String]
For Each prop In ent.Properties("allowedChildClasses")
Console.WriteLine(prop)
Next
DirectoryEntry ent = new DirectoryEntry();
ent.RefreshCache(new string[] {"allowedChildClasses"});
foreach(String prop in ent.Properties["allowedChildClasses"])
{
Console.WriteLine(prop);
}
下列程式碼範例示範如何使用 System.DirectoryServices.PropertyValueCollection.Value 屬性寫入建構的屬性。
Dim ent As New DirectoryEntry()
ent.Properties("fsmoRoleOwner").Value = "CN=NTDS Settings,CN=FABRKM-DC-03,CN=Servers,CN=Bldg4,CN=Sites,CN=Configuration,DC=Fabrikam,DC=com"
ent.CommitChanges()
DirectoryEntry ent = new DirectoryEntry();
ent.Properties["fsmoRoleOwner"].Value =
"CN=NTDS Settings,CN=FABRKM-DC-03,CN=Servers,CN=Bldg4,CN=Sites,CN=Configuration,DC=Fabrikam,DC=com";
ent.CommitChanges();
請參閱
參考
System.DirectoryServices
PropertyValueCollection
DirectoryEntry
DirectorySearcher
概念
Send comments about this topic to Microsoft.
Copyright © 2007 by Microsoft Corporation.All rights reserved.