0
votes

I'm trying to configure access, launch permissions along with set run as to one of our custom DCOM application.

I have already gone through these links dcomcnfg functionality programmatically

and http://www.myitforum.com/articles/11/view.asp?id=9323 (downloaded c++ DCOMPerm library)

I tried the code from the first link above as is written by "longofest" but the following line of code

var value = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Ole", "DefaultAccessPermission", null);

always gives me back a null value,however when I looked into the registry entries on my machine the "DefaultAccessPermission" entry for Ole registry key does have a binary value there then why I always receive a null back, no idea.

Secondly I tried the c++ library downloaded from the second link above and tried to do a COM call to one of the methods with DLLImport attribution (for automating the launch permissions for the DCOM object) but some marshalling issue is not letting me pass in the C# types corresponding to C++ types and spitting out an exception that says PInvoke cannot return variants.

I couldn't find anything concrete after googling for several hours, any help on this account will be more than appreciated.

Never worked with C++, got very poor knowledge of this language.

Update:The null value issue is solved but I don't know how to set access permissions and set run as. I have seen in c++ code that for setting access permission the code needs a domain and username but what is the c# equivalent of that, no idea....

1
Is your code running as 32- or 64-bit process? This might help you.Jacob Seleznev
I have opted for Any CPU in the build tab of the project properties and it's on a 64-bit windows 7 machine.user2913184

1 Answers

0
votes

I used the tblimp.exe tool from Microsoft and created an interop .dll assembly out of DComPerm.dll (c++ assembly) to reference in C# code and by means of Run Time Callable Wrapper I'm calling various methods on COM objects to write my C# program, so no need of DLLImport or MarshalAs attribution since RCW will take care of all the marshalling and unmarshalling issues.