Skip to main content

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.

  1. Verify that JSmith is a member of %Developer but not SecurityTutorialRole. See Adding a User to a Role for instructions.

  2. Open Terminal by clicking the InterSystems Launcher in the System Tray.

  3. If Terminal does not open in the USER Namespace, use the ZN command to change to the USER Namespace.

    
    DOCBOOK>ZN "USER"
    USER>
    
    
  4. Now use $SYSTEM.Security.Login to log in JSmith.

    
    USER>Write $SYSTEM.Security.Login("JSmith","JSmith")
    1
    
    
  5. Now execute PrivRoutineExample.

    
    USER>Do ^PrivRoutineExample
    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.

  6. Close Terminal.

In the second case, JSmith is a member of both %Developer and SecurityTutorialRole.

  1. Use the Management Portal to add JSmith to SecurityTutorialRole. See Adding a User to a Role for instructions.

  2. Open Terminal. Change to the USER namespace, if necessary.

  3. Use $SYSTEM.Security.Login to log in JSmith.

  4. Now execute PrivRoutineExample again.

    
    USER>Do ^PrivRoutineExample
    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.

FeedbackOpens in a new tab