(2) VB
GetSecurityCallContext( )
// Checking if security is enabled or not.
VARIANT_BOOL bIsSecurityEnabled ;
pCallCtx->IsSecurityEnabled (&bIsSecurityEnabled) ;
if (bIsSecurityEnabled) Display("Security is Enabled");
else Display("Security is Disabled");
// Checking role membership
VARIANT_BOOL bIsInRole ;
pCallCtx ->IsCallerInRole("Manager", &bIsInRole);
if(bIsInRole) Go ahead and perform the transaction
else output("Security is Disabled");
Code Explain:
HRESULT IsSecurityEnabled(
VARIANT_BOOL * pbIsEnabled
);
ISecurityCallContext::IsCallerInRole is used to ensure that action are performed only by members of a Managers role.