I'm trying to write a C++ wrapper for an out-of-process COM server (on another machine). I'm hoping to hide all the COM-related nastiness from users of the class.
The security requirements force me to call CoSetSecurityBlanket on the server proxy. That is:
CoCreateInstance(CLSID_OutOfProcServer, &proxy);
CoSetProxyBlanket(proxy);
(I've left out lots of parameters). In addition, I must specify credentials in this call since the server requires a local account.
Now here's the problem. This server has lots of methods that return interfaces, and each of these interfaces is a brand new proxy on my side. Thus, I have to call CoSetProxyBlanket()
each time I get one. Here's what I want to accomplish:
- Have my wrapper hide the CoSetProxyBlanket calls (easy enough)
- Avoid storing the credentials in memory (devilishly difficult!)
So far, I've tried copying the blanket from one object to another using CoQueryProxyBlanket
and CoSetProxyBlanket
. This doesn't work because I can't recover the credentials (unless I store them in memory—which I'd like to avoid).
What's really frustrating is that I have an authenticated connection to the server. It seems like I should be able to copy its security context into the new proxy. (Or at least tell COM to do this for me when it creates the new proxy.) Is there any way to do this or am I stuck storing the credentials?