Directory Services

IADsExtension Usage

IADsExtension is an optional interface implemented by the extension writer when at least one of the following conditions are met:

If an extension component supports the IADsExtension interface for for the first reason, the IADsExtension::PrivateGetIDsOfNames and IADsExtension::PrivateInvoke methods can return E_NOTIMPL. Alternatively, if an extension component supports a dual or dispatch interface , the Operate method can ignore the data and return an HRESULT of E_NOTIMPL.

The following code shows an extension implementing IADsExtension.

STDMETHOD(Operate)(ULONG dwCode, VARIANT varData1, VARIANT varData2, VARIANT varData3)
{
	HRESULT hr = S_OK;
	switch (dwCode) 
	{
	case ADS_EXT_INIT:
		 // Prompt for a credential.
		 // MessageBox(NULL, "INITCRED", "ADsExt", MB_OK);
		break;
	default:
		hr = E_FAIL;
		break;
}	
	return hr; 
}
 
STDMETHOD(PrivateGetIDsOfNames)(REFIID riid, OLECHAR ** rgszNames, unsigned int cNames, LCID lcid, DISPID  * rgdispid)
{ 
	if (rgdispid == NULL)
	{
		return E_POINTER;
}
	return  DispGetIDsOfNames(m_pTypeInfo, rgszNames, cNames, rgdispid);
}
 
STDMETHOD(PrivateInvoke)(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, UINT * puArgErr)
{
 return DispInvoke( (IHelloWorld*)this, 
		 m_pTypeInfo,
		dispidMember, 
		wFlags, 
		pdispparams, 
		pvarResult, 
		pexcepinfo, 
		puArgErr );
}