A useful feature of schema-based directory services is the ability of administrators to add properties to objects. For example, administrators at the "ABX" organization might want to create an "ABXuser" based on the standard Active Directory user object, which contains additional properties useful at ABX.
Assume that ABX wants to add a Card Key number to the user object, and call the new object type "ABXuser." Active Directory makes this simple. First, a new class is created in the SCHEMA container, and is marked as derived from the desired base class. New properties are added to the new Class. The Visual Basic code to perform this extension appears below.
Example 7: Extending the Schema
Dim schema as IOleDsSchema Dim user as IOleDsClass Dim ABXuser as IOleDsClass Dim CardKey as IOleDsProperty ' bind to the schema container set schema = GetObject("@NS!ABX\Schema") ' get the base user object to derive from set user = GetObject("@NS!ABX\Schema\user") ' create a new class in the schema set ABXuser = schema.create("class","ABXuser") ' set the properties of the new class - we don't want to override the base
' object, so we copy the base object's properties ABXuser.CLSID = user.CLSID ABXuser.PrimaryInterface = user.CLSID ABXuser.Container = False ABXuser.DerivedFrom = user.PrimaryInterface ABXuser.Containment = user.Containment ' write out the new class ABXuser.SetInfo 'create a new property in the class set CardKey = ABXuser.create("property","CardKey") CardKey.syntax = "Bstr" CardKey.SetInfo 'Done!