Example: Executing the Privileged Routine Application
After completing the steps described on the previous pages, we can test MyPrivilegedRoutineApplication. In this example, we execute the PrivRoutineExample routine twice with our user JSmith: once with JSmith as a member of %Developer only and once with JSmith a member of SecurityTutorialRole as well as %Developer.
In the first case, JSmith is a member of %Developer but not SecurityTutorialRole.
-
Verify that JSmith is a member of %Developer but not SecurityTutorialRole. See Adding a User to a Role for instructions.
-
Open the Terminal by clicking the InterSystems Launcher in the System Tray.
-
In the USER namespace use $SYSTEM.Security.Login to log in as JSmith.
USER>Write $System.Security.Login("JSmith","JSmith")
1
-
Now execute the PrivilgedRoutineEx() method:
USER>Do ##class(SecurityTutorial.PrivilegedRoutineExample).PrivilegedRoutineEx()
Welcome to the Privileged App Routine
User before: JSmith
Roles before: %Developer
User after: JSmith
Roles after: %Developer
Note that the routine does not add JSmith to any roles. This is because JSmith is not a member of SecurityTutorialRole.
-
Close the Terminal.
In the second case, JSmith is a member of both %Developer and SecurityTutorialRole.
-
Use the Management Portal to add JSmith to SecurityTutorialRole. See Adding a User to a Role for instructions.
-
Open the Terminal by clicking the InterSystems Launcher in the System Tray.
-
In the USER namespace, use $SYSTEM.Security.Login to log in JSmith.
-
Now execute the PrivilgedRoutineEx() method again.
USER>Do Do ##class(SecurityTutorial.PrivilegedRoutineExample).PrivilegedRoutineEx()
Welcome to the Privileged App Routine
User before: JSmith
Roles before: %Developer,SecurityTutorialRole
User after: JSmith
Roles after: %Developer,PrivRoutineRole,SecurityTutorialRole
This time the routine adds JSmith to PrivRoutineRole.