Share via


Constructed Properties

Certain directory attributes are constructed. Constructed attributes cannot be returned in a query unless specified. If you return an object using the DirectoryEntry class, then you can use the RefreshCache method to retrieve constructed attributes. If you use DirectorySearcher, you will use the PropertiesToLoad property to specify the attribute names, which may include constructed attribute.

The following code example shows how to read the constructed property 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);
}

The following code example shows how to write constructed properties using the System.DirectoryServices.PropertyValueCollection.Value property.

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();

See Also

Reference

System.DirectoryServices
PropertyValueCollection
DirectoryEntry
DirectorySearcher

Concepts

Directory Object Properties

Send comments about this topic to Microsoft.

Copyright © 2007 by Microsoft Corporation. All rights reserved.