Platform SDK: Transaction Server

IObjectContext::IsCallerInRole Method

[This product will work only on Windows NT 4.0 versions and earlier. For Windows 2000 and later, see COM+ (Component Services).]

Indicates whether an object's direct caller is in a specified role (either individually or as part of a group).

Provided By

IObjectContext

HRESULT IObjectContext::IsCallerInRole (
    BSTR bstrRole, 
    BOOL* pfIsInRole
);

Parameters

bstrRole
[in] The name of the role in which you want to determine whether the caller is acting.

pfIsInRole
[out] TRUE if the caller is in the specified role, FALSE if not. This parameter will also be set to TRUE if security is not enabled.

Return Values

S_OK
The role specified in the bstrRole parameter is a recognized role, and the Boolean result returned in the pfIsInRole parameter indicates whether or not the caller is in that role.

CONTEXT_E_
ROLENOTFOUND
The role specified in the bstrRole parameter does not exist.

E_INVALIDARG
One or more of the arguments passed in is invalid.

E_UNEXPECTED
An unexpected error occurred. This can happen if one object passes its IObjectContext pointer to another object and the other object calls IsCallerInRole using this pointer. An IObjectContext pointer is not valid outside the context of the object that originally obtained it.

Remarks

You use this method to determine whether the direct caller of the currently executing method is associated with a specific role. A role is a symbolic name that represents a user or group of users who have specific access permissions to all components in a given package. Developers define roles when they create a component, and roles are mapped to individual users or groups at deployment time.

IsCallerInRole only applies to the direct caller of the currently executing method. (The direct caller is the process calling into the current server process. It can be either a base client process or a server process.) IsCallerInRole doesn't apply to the process that initiated the call sequence from which the current method was called, or to any other callers in that sequence.

Because IsCallerInRole returns TRUE when the object that invokes it is executing in a client's process, it's a good idea to call IsSecurityEnabled before calling IsCallerInRole. If security isn't enabled, IsCallerInRole won't return an accurate result.

Example

See Also

Programmatic Security, Basic Security Methods, Secured Components