Directory Services

Reading the Abstract Schema

This topic provides a code example and guidelines for reading from the abstract schema, which provides a subset of the data stored in the attributeSchema and classSchema objects in the schema container. To retrieve data that is unavailable in the abstract schema, read the data directly from the schema container as described in Reading attributeSchema and classSchema Objects.

Use the "LDAP://schema" binding string to bind to an IADsContainer pointer on the abstract schema. Use this pointer to enumerate the class, attribute, and syntax entries in the abstract schema. You can also use the GetObject method to retrieve individual entries.

// Bind to the abstract schema.
IADsContainer *pAbsSchema = NULL;
hr = ADsGetObject(L"LDAP://schema",
				IID_IADsContainer,
				(void**)&pAbsSchema);
' Bind to the abstract schema.
Dim adschema As IADsContainer
Set adschema = GetObject("LDAP://schema")

Use a similar binding string, "LDAP://schema/object", to bind directly to a class or attribute entry in the abstract schema. In this string, object is the lDAPDisplayName of a class or attribute. For classes bind to the IADsClass interface; for attributes, bind to IADsProperty.

// Bind to the user class entry in the abstract schema.
IADsClass *pClass;
hr = ADsGetObject(L"LDAP://schema/user",
				IID_IADsClass,
				(void**)&pClass);
Bind to the user class entry in the abstract schema.
Dim userclass As IADsClass
Set userclass = GetObject("LDAP://schema/user")

In addition, the IADs interface provides the IADs::get_Schema method. This method returns the ADsPath for the object class in abstract schema binding string format. If you have an IADs pointer to an object, you can bind to its class in the abstract schema using the ADsPath returned from IADs::get_Schema.

For classes, the following table lists key properties provided by the abstract schema.

Method (Property) Meaning
IADsClass::get_Abstract Indicates whether this is an abstract class.
IADsClass::get_Auxiliary Indicates whether this is an auxiliary class.
IADsClass::get_AuxDerivedFrom Array of auxiliary classes this class derives from.
IADsClass::get_Container Indicates whether objects of this class can contain other objects, which is true if any class includes this class in its list of possibleSuperiors.
IADsClass::get_DerivedFrom Array of classes that this class is derived from.
IADsClass::get_MandatoryProperties Retrieves an array of the mandatory properties that must be set for an instance of the class. The returned list includes all the mustContain and systemMustContain values for the class and the classes from which it is derived, including superclasses and auxiliary classes.
IADsClass::get_OID Retrieves the governsID of the class.
IADsClass::get_OptionalProperties Retrieves an array of the optional properties that might be set for an instance of the class. The returned list includes all the mayContain and systemMayContain values for the class and the classes from which it is derived, including superclasses and auxiliary classes.
IADsClass::get_PossibleSuperiors Retrieves an array of the possSuperiors values for the class, which indicates the object classes that can contain objects of this class.

The abstract schema is stored in the subSchema object in the schema container. To get the distinguished name of the subSchema object, bind to rootDSE and read the subSchemaSubEntry property, as described in Serverless Binding and RootDSE. Be aware that it is more efficient to read the abstract schema by binding to LDAP://schema, than by binding directly to the subSchema object.