The following is a brief review of COM aggregation and ADSI extension rules.
The IUnknown::QueryInterface method returns pointers to the interfaces that it supports, and errors for interfaces it does not support.
The IUnknown::AddRef method increments the reference count on the aggregated extension object itself.
The IUnkown::Release method decrements the reference count on the aggregated extension object itself and destroys itself when the reference count is 0.
IUnknown::QueryInterface calls m_pOuterUnknown->QueryInterface
IUnknown::AddRef calls m_pOuterUnknown->AddRef
IUnkown::Release calls m_pOuterUnknown->Release
Extension writers can choose any internal implementation they prefer as long as they obey standard COM aggregation rules. Be aware that an extension object does not have to work as a standalone object. Extensions are designed to work as aggregates. However, an extension can be written to work as both a standalone object and as an aggregate.
In addition to standard COM aggregation support, an extension object may support IADsExtension for more advanced features. If late binding is supported, the extension should: