Freigeben über


SecurityCallContext.DirectCaller-Eigenschaft

Ruft ein SecurityIdentity-Objekt ab, das den direkten Aufrufer dieser Methode beschreibt.

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

Syntax

'Declaration
Public ReadOnly Property DirectCaller As SecurityIdentity
'Usage
Dim instance As SecurityCallContext
Dim value As SecurityIdentity

value = instance.DirectCaller
public SecurityIdentity DirectCaller { get; }
public:
property SecurityIdentity^ DirectCaller {
    SecurityIdentity^ get ();
}
/** @property */
public SecurityIdentity get_DirectCaller ()
public function get DirectCaller () : SecurityIdentity

Eigenschaftenwert

Ein SecurityIdentity-Wert.

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, wie diese Methode verwendet wird, um die Identität des direkten Aufrufers einer ServicedComponent-Methode zu überprüfen.

' Get the employee's salary. Only the employee and managers can do this.
Public Function GetSalary() As Double 
    If SecurityCallContext.CurrentCall.DirectCaller.AccountName = accountName OrElse SecurityCallContext.CurrentCall.IsCallerInRole("Manager") Then
        Return salary
    Else
        Throw New UnauthorizedAccessException()
    End If

End Function 'GetSalary
// 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();
    }
}
// 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;
   }
}
// Get the employee's salary. Only the employee and managers can do this.
public double GetSalary() throws System.UnauthorizedAccessException
{
    if (SecurityCallContext.get_CurrentCall().get_DirectCaller().
        get_AccountName().Equals(accountName) 
        || SecurityCallContext.get_CurrentCall().
        IsCallerInRole("Manager")) {
        return salary;
    }
    else {
        throw new UnauthorizedAccessException();
    }
} //GetSalary

.NET Framework-Sicherheit

  • Volle Vertrauenswürdigkeit für den unmittelbaren Aufrufer. Dieser Member kann von nur teilweise vertrauenswürdigem Code nicht verwendet werden. Weitere Informationen finden Sie unter .

Plattformen

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

SecurityCallContext-Klasse
SecurityCallContext-Member
System.EnterpriseServices-Namespace