This documentation is archived and is not being maintained.
SecurityCallContext Class
Visual Studio 2010
Describes the chain of callers leading up to the current method call.
Assembly: System.EnterpriseServices (in System.EnterpriseServices.dll)
The SecurityCallContext type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Callers | Gets a SecurityCallers object that describes the caller. |
![]() ![]() | CurrentCall | Gets a SecurityCallContext object that describes the security call context. |
![]() | DirectCaller | Gets a SecurityIdentity object that describes the direct caller of this method. |
![]() | IsSecurityEnabled | Determines whether security checks are enabled in the current context. |
![]() | MinAuthenticationLevel | Gets the MinAuthenticationLevel value from the ISecurityCallContext collection in COM+. |
![]() | NumCallers | Gets the NumCallers value from the ISecurityCallContext collection in COM+. |
![]() | OriginalCaller | Gets a SecurityIdentity that describes the original caller. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IsCallerInRole | Verifies that the direct caller is a member of the specified role. |
![]() | IsUserInRole | Verifies that the specified user is in the specified role. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
The following code example demonstrates the use of the SecurityCallContext class to interrogate the security context of calls to the methods of a ServicedComponent class.
// Accept a constructor string. [ConstructionEnabled] public ref class EmployeeInformation: public ServicedComponent { private: // The employee's user name and salary. String^ accountName; double salary; public: // Get the employee's name. All users can call this method. String^ GetName() { return (accountName); } // Set the employee's salary. Only managers can do this. void SetSalary( double ammount ) { if ( SecurityCallContext::CurrentCall->IsCallerInRole( "Manager" ) ) { salary = ammount; } else { throw gcnew UnauthorizedAccessException; } } // Get the employee's salary. Only the employee and managers can do this. double GetSalary() { if ( SecurityCallContext::CurrentCall->DirectCaller->AccountName == accountName || SecurityCallContext::CurrentCall->IsCallerInRole( "Manager" ) ) { return (salary); } else { throw gcnew UnauthorizedAccessException; } } protected: // Use the constructor string. // This method is called when the object is instantiated. virtual void Construct( String^ constructorString ) override { accountName = constructorString; } };
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show:
