Home All Groups Group Topic Archive Search About

ASP.NET - Impersonation - CoInitializeSecurity, CoInitializeEx

Author
15 Mar 2005 9:09 PM
POnfri
I am having a ASP.NET application that makes calls to a COM Component.
The COM Component has calls to CoInitializeEx, ConitializeSecurity etc.

What Thread options and Impersonation and capabilities I have to set for
these calls.

Actually, I tried with the default ASPNET and impersonating the web
application with local machine admin user; and I have tried with several
combinations of levels in the calls. Also, I have tried using the compat
attribute for the ASP.NET page.
I have got a variety of errors including Access denied, Catastrophic
failure(when trying to do some operation), "Security must be Initialized
before Interfaces are Marshalled or Unmarshalled ....etc". I think I am
missing something fundamental

To be a bit more clear...
* I have IIS 6.0 running.
* I have Set comAuthenticationLevel ="PktPrivacy",
comImpersonationLevel="Impersonate" in machine.config's processModel
section.
* I also created a few registry keys, based on an article I read somewhere
that IIS 6.0 does not use the above 2 settings in machine.config. They are -
MyComputer\HKLM\System\CurrentControlSet\Services\w3svc\Parameters:
1. CoInitializeSecurityParam = 1 (dword)
2. AuthenticationLevel = 6
3. ImpersonationLevel = 1
4. AuthenticationCapabilities = 0x00003040(12352)
* I have specified compat="true" for the ASP.NET web form
* I have set |identity impersonte="true" user="someprivilegeduser"
password="password" /|
* Now this ASP.NET code calls a MC++ class. Which makes the following calls:
1. CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
2. CoInitializeSecurity(NULL, -1, NULL, NULL,
RPC_C_AUTHN_LEVEL_PKT_PRIVACY, RPC_C_IMP_LEVEL_IMPERSONATE, NULL,
EOAC_DYNAMIC_CLOAKING, NULL)
3. Followed by some COM component calls.

This is what happens when I run the code:
1. I get "Security must be Initialized before Interfaces are Marshalled
or Unmarshalled...." error.

Thanks

AddThis Social Bookmark Button