SecurityCallContext Class
TOC
Collapse the table of content
Expand the table of content

SecurityCallContext Class

 

Describes the chain of callers leading up to the current method call.

Namespace:   System.EnterpriseServices
Assembly:  System.EnterpriseServices (in System.EnterpriseServices.dll)

System.Object
  System.EnterpriseServices.SecurityCallContext

public sealed class SecurityCallContext

NameDescription
System_CAPS_pubpropertyCallers

Gets a SecurityCallers object that describes the caller.

System_CAPS_pubpropertySystem_CAPS_staticCurrentCall

Gets a SecurityCallContext object that describes the security call context.

System_CAPS_pubpropertyDirectCaller

Gets a SecurityIdentity object that describes the direct caller of this method.

System_CAPS_pubpropertyIsSecurityEnabled

Determines whether security checks are enabled in the current context.

System_CAPS_pubpropertyMinAuthenticationLevel

Gets the MinAuthenticationLevel value from the ISecurityCallContext collection in COM+.

System_CAPS_pubpropertyNumCallers

Gets the NumCallers value from the ISecurityCallContext collection in COM+.

System_CAPS_pubpropertyOriginalCaller

Gets a SecurityIdentity that describes the original caller.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodIsCallerInRole(String)

Verifies that the direct caller is a member of the specified role.

System_CAPS_pubmethodIsUserInRole(String, String)

Verifies that the specified user is in the specified role.

System_CAPS_pubmethodToString()

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 class EmployeeInformation : ServicedComponent
{

    // The employee's user name and salary.
    private string accountName;
    private double salary = 0;


    // Get the employee's name. All users can call this method.
    public string GetName ()
    {
      return(accountName);
    }


    // Set the employee's salary. Only managers can do this.
    public void SetSalary (double ammount)
    {
        if (SecurityCallContext.CurrentCall.IsCallerInRole("Manager"))
        {
            salary = ammount;
        }
        else
        {
            throw new UnauthorizedAccessException();
        }
    }


    // Get the employee's salary. Only the employee and managers can do this.
    public double GetSalary ()
    {
        if ( SecurityCallContext.CurrentCall.DirectCaller.AccountName == accountName ||
             SecurityCallContext.CurrentCall.IsCallerInRole("Manager") )
        {
            return(salary);
        }
        else
        {
          throw new UnauthorizedAccessException();
        }
    }


    // Use the constructor string.
    // This method is called when the object is instantiated.
    protected override void Construct (string constructorString)
    {
        accountName = constructorString;
    }

}

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft