Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

サンプルの設定 (続き)

PrivRoutineExample のコードは以下のとおりです。


PrivRoutineExample

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

 Set status=$SYSTEM.Security.AddRoles("MyPrivilegedRoutineApplication")

 write !, "User after: ", $USERNAME
 write !, "Roles after: ", $ROLES   

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

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

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

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

FeedbackOpens in a new tab