Directory Services

Adding an ADAM Contact Class

[This documentation is preliminary and subject to change.]

To programmatically extend the ADAM schema, you must have sufficient rights to modify the schema. To modify the schema, bind to the schema partition of an ADAM instance, create a new object or attribute class, and set appropriate properties of the new class.

Programmatic extension of the ADAM schema is sometimes desirable. Unlike using an LDIF file to extend the schema, you can make a programmatic extension invariant to change by building and supplying only an executable file.

For more information about programmatically extending the schema in Active Directory, see Programmatic Extension.

After you extend the schema with the following code example, create Contact objects by Creating Contact Objects in ADAM.

The following VBScript code example binds to the schema of an ADAM instance, creates an attributeSchema object for a new attribute named "Additional-Information" and sets its properties, and creates a classSchema object for a new class named "Contact" and sets its properties.

' Extend ADAM Schema with Contact Class
'  and Additional-Information Attribute.

Option Explicit

' Global declarations.
Const ADS_PROPERTY_APPEND			 = 3  ' Append operation.
Const DS_INSTANCETYPE_NC_IS_WRITEABLE = 4  ' Writeable attribute.
Dim objRoot				 ' Root of ADAM instance.
Dim objSchema			 ' Schema partiton.
Dim strSchemaNamingContext  ' Schema DN.

' Get schema path.
Set objRoot = GetObject("LDAP://localhost:389/RootDSE")
strSchemaNamingContext = objRoot.Get("schemaNamingContext")
Set objSchema = GetObject("LDAP://localhost:389/" & _

WScript.Echo "Schema path: " & objSchema.ADsPath

' Declarations for new attribute.
Const strAttributeName = "Additional-Information"  ' Attribute name.
Dim objNewAttribute								' New attribute.
Dim strCNAttributeName							 ' Attribute CN.

' Create new attribute.
strCNAttributeName = "CN=" & strAttributeName
Set objNewAttribute = objSchema.Create("attributeSchema", _

' Set selected values for the attribute.
objNewAttribute.Put "instanceType", DS_INSTANCETYPE_NC_IS_WRITEABLE
objNewAttribute.Put "attributeID", "1.2.840.113556.1.4.265"
objNewAttribute.Put "attributeSyntax", ""
objNewAttribute.Put "isSingleValued", True
objNewAttribute.Put "rangeUpper", 32768
objNewAttribute.Put "showInAdvancedViewOnly", True
objNewAttribute.Put "adminDisplayName", strAttributeName
objNewAttribute.Put "adminDescription", strAttributeName
objNewAttribute.Put "oMSyntax", 64
objNewAttribute.Put "searchFlags", 0
objNewAttribute.Put "lDAPDisplayName", "notes"
objNewAttribute.Put "name", strAttributeName
objNewAttribute.Put "systemOnly", False
objNewAttribute.Put "systemFlags", 16
objNewAttribute.Put "objectCategory", "CN=Attribute-Schema," & _
WScript.Echo "Created attributeSchema class object: " & _

' Update schema cache.
WScript.Echo "Updating the schema cache."
objRoot.Put "schemaUpdateNow", 1

' Declarations for new class.
Const strClassName = "Contact"  ' Class name.
Dim objNewClass				 ' New class.
Dim strCNClassName			' Class CN.

' Create new class.
strCNClassName = "CN=" & strClassName
Set objNewClass = objSchema.Create("classSchema", strCNClassName)

' Set selected values for class.
objNewClass.Put "instanceType", DS_INSTANCETYPE_NC_IS_WRITEABLE
objNewClass.Put "subClassOf", "organizationalPerson"
objNewClass.Put "governsID", "1.2.840.113556.1.5.15"
objNewClass.Put "rDNAttID", "cn"
objNewClass.Put "showInAdvancedViewOnly", True
objNewClass.Put "adminDisplayName", strClassName
objNewClass.Put "adminDescription", strClassName
objNewClass.Put "objectClassCategory", 1
objNewClass.Put "lDAPDisplayName", strClassName
objNewClass.Put "name", strClassName
objNewClass.Put "systemOnly", False
				"systemPossSuperiors", Array("organizationalUnit", _
objNewClass.Put "systemMayContain", "notes"
objNewClass.Put "systemMustContain", "cn"
objNewClass.Put "defaultSecurityDescriptor", _
objNewClass.Put "systemFlags", 16
objNewClass.Put "defaultHidingValue", False
objNewClass.Put "objectCategory", "CN=Class-Schema," & _
objNewClass.Put "defaultObjectCategory", "CN=Person," & _
WScript.Echo "Created classSchema class object: " & objNewClass.Name

' Update schema cache.
WScript.Echo "Updating the schema cache."
objRoot.Put "schemaUpdateNow", 1