Directory Services

Constructed Properties

Certain directory attributes are constructed. Constructed attributes cannot be returned in a query unless specified. If you return an object using DirectoryEntry, 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.

[Visual Basic .NET]
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 prop
[C#]
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 PropertyValueCollection.Value property.

[Visual Basic .NET]
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()
[C#]
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();