Click here to Skip to main content
15,925,181 members
Home / Discussions / COM
   

COM

 
GeneralRe: SysFreeString Pin
13-Oct-01 15:41
suss13-Oct-01 15:41 
GeneralDCOM security on XP Pin
Tim Smith9-Oct-01 13:02
Tim Smith9-Oct-01 13:02 
QuestionHow to add new icons to the existing ms-word application Pin
RamiReddy8-Oct-01 20:25
RamiReddy8-Oct-01 20:25 
AnswerRe: How to add new icons to the existing ms-word application Pin
Shadi Al-Kahwaji11-Oct-01 3:18
Shadi Al-Kahwaji11-Oct-01 3:18 
GeneralDCOM and ConnectionPoint Pin
Firoz8-Oct-01 2:31
Firoz8-Oct-01 2:31 
GeneralRe: DCOM and ConnectionPoint Pin
Rashid Thadha9-Oct-01 2:35
Rashid Thadha9-Oct-01 2:35 
GeneralRe: DCOM and ConnectionPoint Pin
Tim Smith9-Oct-01 13:03
Tim Smith9-Oct-01 13:03 
GeneralRe: Ok, here is the info... Pin
Tim Smith10-Oct-01 3:14
Tim Smith10-Oct-01 3:14 
The first thing that should be done is that COM security should be turned off in the client. Of course, if your client is also acting as a server or is a DLL being loaded by another application, you might not have this option.

hResult = CoInitializeSecurity (NULL, -1, NULL, NULL,
    RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IDENTIFY,
    NULL, EOAC_NONE, NULL);


This needs to be done after you call CoInitialize or CoInitializeEx.

Next, you need a routine in your server such as the following.

//-----------------------------------------------------------------------------
//
// @func Remove all security
//
// @parm IUnknown * | pUnk | Interface to remove security
//
// @rdesc Routine results
//
//-----------------------------------------------------------------------------

inline HRESULT DtRemoveSecurity (IUnknown *pUnk)
{
	HRESULT hResult;

	//
	// Get the real IUnknown interface
	//

	CComPtr <IUnknown> pRealUnk;
	hResult = pUnk ->QueryInterface (IID_IUnknown, (void **) &pRealUnk);
	if (SUCCEEDED (hResult) && pRealUnk != pUnk)
	{
		hResult = CoSetProxyBlanket (pRealUnk, RPC_C_AUTHN_NONE,
			RPC_C_AUTHZ_NONE, 0, RPC_C_AUTHN_LEVEL_NONE, 
			RPC_C_IMP_LEVEL_ANONYMOUS, 0, EOAC_NONE);
	}

	//
	// Set the original unknown
	//

	hResult = CoSetProxyBlanket (pUnk, RPC_C_AUTHN_NONE, 
		RPC_C_AUTHZ_NONE, 0, RPC_C_AUTHN_LEVEL_NONE, 
		RPC_C_IMP_LEVEL_ANONYMOUS, 0, EOAC_NONE);
	return hResult;
}


Next thing you will need to do is modify your XXX::Advise method for your connection point. You might have to subclass the ATL routine do to this.

Inside the XXX::Advise routine, there is usally a point where the interface is queried for the actual interface needed. The code should be modified.

CComPtr <IUnknown> p;
HRESULT hResult = pUnkSink ->QueryInterface (*_piid, (void **) &p);
if (FAILED (hResult))
{
    DtRemoveSecurity (pUnkSink);
    hResult = pUnkSink ->QueryInterface (*_piid, (void **) &p);
    if (FAILED (hResult))
        return CONNECT_E_CANNOTCONNECT;
}


This code test to see if you can query the interface. If it fails then security is removed and then another attempt is made. At this stage it is important that you don't blindly remove security since that causes problems with connections on the local machine.

Now, if you are using a GIT based connection point, then after the interface is retrieved from the GIT, you will need to invoke DtRemoveSecurity on the retrieved interface. This can be done blindly on local or remote interfaces.

Hope this helps.

Tim Smith
Descartes Systems Sciences, Inc.
GeneralRe: Ok, here is the info... Pin
Rashid Thadha10-Oct-01 10:30
Rashid Thadha10-Oct-01 10:30 
GeneralRe: Ok, here is the info... Pin
Tim Smith10-Oct-01 12:36
Tim Smith10-Oct-01 12:36 
GeneralThats Great , but a small problem... Pin
Firoz10-Oct-01 19:59
Firoz10-Oct-01 19:59 
GeneralRe: DCOM and ConnectionPoint Pin
Shadi Al-Kahwaji11-Oct-01 1:13
Shadi Al-Kahwaji11-Oct-01 1:13 
GeneralRe: DCOM and ConnectionPoint Pin
Firoz11-Oct-01 2:35
Firoz11-Oct-01 2:35 
GeneralCalling a COM object in an MFC exe Pin
Aza7-Oct-01 5:37
Aza7-Oct-01 5:37 
GeneralRe: Calling a COM object in an MFC exe Pin
Rashid Thadha9-Oct-01 2:40
Rashid Thadha9-Oct-01 2:40 
Generalusing list view in ATL property page Pin
Sameer Bhat7-Oct-01 4:11
Sameer Bhat7-Oct-01 4:11 
GeneralRe: using list view in ATL property page Pin
Amit Dey13-Oct-01 6:27
Amit Dey13-Oct-01 6:27 
GeneralRe: using list view in ATL property page Pin
Sameer Bhat14-Oct-01 2:20
Sameer Bhat14-Oct-01 2:20 
GeneralOLE Control in Visual Basic Pin
7-Oct-01 0:22
suss7-Oct-01 0:22 
QuestionAbout Com:I need help with the following code(simplified)? Pin
star_see5-Oct-01 19:52
star_see5-Oct-01 19:52 
AnswerRe: About Com:I need help with the following code(simplified)? Pin
Shadi Al-Kahwaji6-Oct-01 23:21
Shadi Al-Kahwaji6-Oct-01 23:21 
GeneralRe: About Com:I need help with the following code(simplified)? Pin
star_see20-Oct-01 5:34
star_see20-Oct-01 5:34 
GeneralBeginning - direction Pin
john john mackey5-Oct-01 7:37
john john mackey5-Oct-01 7:37 
GeneralCreating a new thread from within an MTA Pin
Jeremy Pullicino4-Oct-01 5:15
Jeremy Pullicino4-Oct-01 5:15 
GeneralRe: Creating a new thread from within an MTA Pin
Shadi Al-Kahwaji6-Oct-01 23:33
Shadi Al-Kahwaji6-Oct-01 23:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.