public static void SetProxySecurity(object server, IntPtr pAuthInfo)
{
// get the existing proxy settings.
uint pAuthnSvc = 0;
uint pAuthzSvc = 0;
string pServerPrincName = "";
uint pAuthnLevel = 0;
uint pImpLevel = 0;
IntPtr pAuthInfo2 = IntPtr.Zero;
uint pCapabilities = 0;
CoQueryProxyBlanket(
server,
ref pAuthnSvc,
ref pAuthzSvc,
ref pServerPrincName,
ref pAuthnLevel,
ref pImpLevel,
ref pAuthInfo2,
ref pCapabilities);
pAuthnSvc = RPC_C_AUTHN_WINNT;
pAuthzSvc = RPC_C_AUTHZ_NONE;
pAuthnLevel = RPC_C_AUTHN_LEVEL_CONNECT;
pImpLevel = RPC_C_IMP_LEVEL_IMPERSONATE;
pCapabilities = EOAC_DYNAMIC_CLOAKING;
// update proxy security settings.
CoSetProxyBlanket(
server,
pAuthnSvc,
pAuthzSvc,
COLE_DEFAULT_PRINCIPAL,
pAuthnLevel,
pImpLevel,
pAuthInfo,
pCapabilities);
}