How does impersonation in DCOM work?

I have a DCOM client and server applications which use OLE automation marshaller. They work fine when run on the same PC but when the server is on a different PC not in the same domain I get E_ACCESSDENIED (0x80070005).

Server PC is configured with dcomcnfg to give all access to any DCOM object to the user whose login and password I specify on the client. ServerApp and its type library are registered on the server pc.

Type library is also registered on the client PC. I specify server name directly in the ClientApp so no dcomcnfg configuration is needed on the Client PC as far as I understand.

CreateInstanceEx() with server name, login, domain and password works fine. It returns IUnknown and at the same time starts ServerApp on server PC.

But when I try to QueryInterface() for the interface which server supports, I get E_ACCESSDENIED.

Analyzing the Security Event Log, I have two records there:

First, a successful network login by the user whose credentials I specify in ClientApp. This happens when I call CreateInstanceEx().

Next, a failed login attempt by the user under which I'm logged in on a client PC. Since two PCs are not in a domain, this user is unknown to server PC.

Now, why the heck would THIS user be logging into server, especially when I call QueryInterface of all things?

Studying CreateInterfaceEx params, it appears there's some kind of impersonation mechanism going on. But it's unclear who impersonates who. There are THREE user credentials involved:

  1. User under which ServerApp runs on the server PC (as configured in dcomcnfg).

  2. User whose credentials ClientApp specifies when connecting.

  3. User under whose credentials ClientApp runs on client PC.

No matter how you look at it, if #3 is involved it's one user too much. If DCOM is going to identify/impersonate #3 on server PC anyway, why do I need to specify #2's credentials? To what point?

It would have seem logical for DCOM to impersonate #2 because this is what I have explicitly specified as my credentials. But why the second login attempt then?

Can someone please explain how exactly the impersonation works, and also if there's a way to just ignore it and run as user which is specified in dcomcnfg?

14
задан himself 25 May 2011 в 10:52
поделиться