SecurityCallContext.IsCallerInRole メソッド
アセンブリ: System.EnterpriseServices (system.enterpriseservices.dll 内)
構文Dim instance As SecurityCallContext Dim role As String Dim returnValue As Boolean returnValue = instance.IsCallerInRole(role)
戻り値
直接の呼び出し元が、指定されたロールのメンバである場合は true。それ以外の場合は false。
使用例このメソッドを使用して、ServicedComponent メソッドの呼び出し元が指定されたロールに存在するかどうかを確認する方法のコード例を次に示します。
' Set the employee's salary. Only managers can do this. Public Sub SetSalary(ByVal ammount As Double) If SecurityCallContext.CurrentCall.IsCallerInRole("Manager") Then salary = ammount Else Throw New UnauthorizedAccessException() End If End Sub 'SetSalary
// 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(); } }
.NET Framework のセキュリティ
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照- SecurityCallContext.IsCallerInRole メソッドのページへのリンク