次の方法で共有


Getting ADSI Interfaces from an IIS ADSI Extension

Oftentimes an extension needs to get information from the IIS object it binds to.

For example, an extension for IIsWebVirtualDir might need the LogType property of the current object.

This is easily achieved in the following example code by issuing a QueryInterface call to the aggregator's IUnknown. This code is intended as an example only.

HRESULT hr; 
IADs *pADs; // ADSI Interface to get and set attributes. 

hr = m_pOuterUnk->QueryInterface(IID_IADs,(void**)&pADs); 
if ( SUCCEEDED(hr) ) 
{ 
   VARIANT var; 
   VariantInit(&var); 
   hr  = pADs ->Get(L"LogType", &var); 
   printf("%S\n", V_BSTR(&var)); 
   VariantClear(&var); 
   pADs->Release(); 
} 

Note

Releasing the reference to the aggregator, as shown in the last line of code, prevents looping errors and allows early binding to function properly. Do not forget to release the reference to the aggregator to prevent looping errors and allow early binding to function properly.