Registering the Extension

Registry keys are used to associate a directory class name with the ADSI extension components. IIS objects are persisted in the metabase, while your extension and the IIS ADSI provider will be running on the client machine. IIS object examples include IIsServer, IIsComputer, and IIsApp. You can add a new class in ADSI and create a new extension for this new class as well.

The registry keys are used to associate a directory class name with the ADSI extension components. The following registry example represents the registry layout with keys for added extensions.

IIS Extensions Registry Hierarchy

Example:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ADs\Providers\IIS\Extensions\<ClassNameA>\{9f37f39c-6f49-11d1-8c18-00c04fd8d503}]
"Interfaces"={466841B0-E531-11d1-8718-00C04FD44407} {466841B1-E531-11d1-8718-00C04FD44407}

The lists of interfaces from each extension ( for example, ExtensionA1, A2, B1 and B2) can be different. The object, when it’s active, will support the interfaces of the aggregator (ADSI, in this case) and all the interfaces provided by the aggregate’s Extension1 and Extension2. If there is a conflict between interfaces (for example, if the same interface is supported by both the aggregator and the aggregates, or by multiple aggregates) it is resolved by assigning different priorities to the extensions. For more information on priorities, see the COM reference material in the Platform SDK.

You can also associate your extension to multiple object class names. For example, your extension can extend both the IIsWebServer and IIsFtpServer objects.

Here is an example of how to register an extension. This sample code is intended for example only and may not be completely valid for every situation.

// Register the class.
hr = RegCreateKeyEx( 
HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\<ClassNameA>\\{E1E3EDF8-48D1-11D2-B22B-0000F87A6B50}"),
 0,
 NULL,
 REG_OPTION_NON_VOLATILE,
 KEY_WRITE,
 NULL,
 &hKey,
 &dwDisposition );

// Register the Interface.
const TCHAR szIf[] = _T("{E1E3EDF7-48D1-11D2-B22B-0000F87A6B50}");
hr = RegSetValueEx( hKey, _T("Interfaces"), 0, REG_MULTI_SZ, (const BYTE *) szIf, sizeof(szIf) );
RegCloseKey(hKey);
return S_OK;
}

At this point you have an extension that early binding clients (such as C++ and Visual Basic) can access. So if you did a GetObject on IIS://LocalHost/W3SVC/ you could take the returned object and QueryInterface for IMyInterface and call any IMyInterface methods, where IMyInterface is the interface of your new extension.

For more information see Getting ADSI Interfaces from the Extension.

Note   If you have problems compiling, be sure you have included Iads.h in the header file.