CreateObjectStub method
Collapse the table of content
Expand the table of content

IUnsecuredApartment::CreateObjectStub method

The CreateObjectStub method creates an object forwarder sink to assist in receiving asynchronous calls from Windows Management. This function binds an unsecured object sink to a local object sink so that COM security does not interfere with asynchronous retrieval of CIM objects. Because COM security is being bypassed, the remote Windows Management server is assumed to be a trusted component.

The general paradigm is that the original implementation of IWbemObjectSink in the client process is not directly used in asynchronous calls to IWbemServices. Rather, both the original implementation and a substitute object are created, bound together, and then the substitute object is used in the asynchronous methods of IWbemServices.


HRESULT CreateObjectStub(
  [in]  IUnknown *pObject,
  [out] IUnknown **ppStub


pObject [in]

Pointer to the client's in-process implementation of IWbemObjectSink.

ppStub [out]

Receives a pointer to a substitute object to be used in asynchronous IWbemServices calls. The user receives an IUnknown pointer and must call QueryInterface for IID_WbemObjectSink before using this object in asynchronous IWbemServices calls.

Return value

This method returns standard COM error codes for QueryInterface. It returns S_OK if the call succeeds. If the call fails because the requested interface was not supported, the method returns E_NOINTERFACE.

COM-specific error codes also may be returned if network problems cause you to lose the remote connection to Windows Management.


Note  Because the call-back to the sink might not be returned at the same authentication level as the client requires, it is recommended that you use semisynchronous instead of asynchronous communication. For more information, see Calling a Method.


For a complete example that shows how to use the IUnsecuredApartment interface, see Example: Receiving Event Notifications Through WMI.


Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008 R2


Wbemcli.h (include Wbemidl.h)





See also

Calling a Method
Setting Security on an Asynchronous Call
Lowering the Security for a Sink in a Separate Process
Performing Access Checks



© 2015 Microsoft