Code Overview
The following figure is a conceptual representation of the blocks of code necessary to implement the ADSI example provider component. Each section is described in the following figure. Knowledgeable COM programmers may find this is all they need for an overview of the example provider component. For more details, each code file is detailed in Code Details.
ADSI Example Provider Component Source Code Description
- Loading the DLL (libmain.cpp, guid.cpp). The entry point for the DLL. Class factory static object definitions for the two provider objects: Guid.cpp contains the CLSID definitions for the implementations of the various Example provider component objects.
- Provider object class factory and creation code (cprovcf.cpp, cprov.cpp, stdfact.cpp). The provider object is the object that supports IParseDisplayName during the moniker binding operations as discussed in Finding and Binding in the Example Provider Component.
- Binding to an object (getobj.cpp). This code calls the parser to check that the given ADsPath is syntactically correct, and then performs any necessary mapping from the ADsPath to the native directory service path for the item being created as an Active Directory object. It looks up the schema definition for this type of object and fills in the mandatory properties. After creating the Active Directory object, an interface pointer to IUnknown is retrieved for the caller.
- Parser for the provider's namespace (parse.cpp). This is the code invoked by the step above. The parser simply checks that the ADsPath string passed in is syntactically correct for its own namespace.
- Class factory, creation, and enumeration for the namespace object (cnamcf.cpp, cnamesp.cpp, cenumns.cpp). The namespace object is a container object that can be enumerated to find all the root node objects for this namespace.
- Class factory and creation code for a generic Active Directory object, and class factory, creation and enumeration code for a generic ADs container object (cgenobj.cpp, cenumobj.cpp, common.cpp, core.cpp). This code is executed whenever an Active Directory object is created.
- Filtering and enumerating VARIANTs (cenumvar.cpp, object.cpp). When a collection of VARIANT elements of a single type are managed in within ADSI, this code is used.
- Globals (globals.cpp). Namespace keywords, syntax mapping structures from native data formats to the ADs Automation VARIANT type are all defined here.
- Marshaling/unmarshaling data (pack.cpp, property.cpp, smpoper.cpp). Conversion from native data formats to the supported set of Automation VARIANT types occurs when properties of an object are loaded into the property cache. Other special handling for data must be performed when structures with pointers are copied, deleted, or moved in memory.
- Property cache (cprops.cpp). Caching properties is a feature of the ADSI environment. The IADs::GetInfo, IADs::GetInfoEx, and IADs::SetInfo methods act on the property cache.
- Memory management (memory.cpp). Using one set of memory functions to allocate and free memory allows the example provider component to track memory use and ensure there are no memory leaks.
- Schema objects and management (cschobj.cpp, cprpobj.cpp, cclsobj.cpp, cenumsch.cpp). This includes routines to create, manage, and enumerate the schema objects. This includes schema class objects, property objects, and syntax objects, in addition to being able to enumerate the schema class container object.
- Operating-system specific calls (RegDSAPI.cpp). This includes all calls that reference the native operating system. Among other functions, they include functions opening, closing, reading, and modifying objects as well as those accessing the schema and property data. The example provider component happened to simulate a directory hierarchy by using the registry. Only function names should be of much interest to a provider writer.
- IDispatch implementation (cdispmgr.cpp). This code accesses the type library information to allow interface methods to be invoked in an Automation-compatible way.