Skip to main content

This documentation is for an older version of this product. See the latest version of this content.Opens in a new tab

特権ルーチンの例のコード

以下は、特権ルーチンの例のコードです。IDE を使用してクラスを作成します。


Class SecurityTutorial.PrivilegedRoutineExample
{

ClassMethod PrivilegedRoutineEx(){

    Write !, "Welcome to the Privileged App Routine"
    Write !, "User before: ", $USERNAME
    Write !, "Roles before: ", $ROLES

    New $ROLES
    Set status=$System.Security.AddRoles("MyPrivilegedRoutineApplication")

    Write !, "User after: ", $USERNAME
    Write !, "Roles after: ", $ROLES
}

}

このコードは、以下のように動作します。

  1. ユーザがルーチンに入るときに、ユーザのユーザ名とロールを書き込みます。

  2. ルーチンのローカル環境内で新しい $ROLES 変数を宣言します。アプリケーション・ロールを追加するための AddRoles() を呼び出すに、このコマンドを発行することが重要です。これにより、ルーチンを終了すると、これらの変更が取り消され、ユーザの元のログイン・ロールがリストアされます。

  3. $SYSTEM.Security.AddRoles を使用して、ユーザを別のロールに追加します。ここで、MyPrivilegedRoutineApplication は特権ルーチン・アプリケーションの名前です。ロールの名前ではありません。ユーザは、特権ルーチン・アプリケーションに対するアプリケーション・ロールとしてリストされたロールに追加されます。

  4. ロールの変化を示すために、ユーザのユーザ名とロールをもう一度書き込みます。

FeedbackOpens in a new tab