List 5-2 Managerロールに属するユーザー以外は1000万円を超える額は扱えないようにする
  1: Public Sub sendmoney(money As Currency, user As String)
  2:     'moneyで指定された金額をuserの口座に振り込むメソッド 
  3:     Dim objContext As ObjectContext
  4:     Set objContext = GetObjectContext()
  5:     If money >= 10000000 Then
  6:         '1000万円以上ならば,ロールのチェック
  7:         If Not objContext.IsSecurityEnabled() Then
  8:             'セキュリティが設定されていない
  9:             Err.Raise 1 + 513 + vbObjectError, "Money", _
                           "セキュリティが設定されていません"
 10:         End If
 11:         If Not objContext.IsCallerInRole("Manager") Then
 12:            'Managerに属さないので,拒否
 13:             Err.Raise 2 + 513 + vbObjectError, "Money",    _ 
                           "Managerに属していないため,そのような金額は受け付けられません"
 14:         End If
 15:     End If
 16:     '実際に金額を振り込む処理が続く  
 17: End Sub