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

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 the Terminal by clicking the InterSystems Launcher in the System Tray.

  3. In the USER namespace use $SYSTEM.Security.Login to log in as JSmith.

    
    USER>Write $System.Security.Login("JSmith","JSmith")
    1
    
    
  4. 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.

  5. Close the 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 the Terminal by clicking the InterSystems Launcher in the System Tray.

  3. In the USER namespace, use $SYSTEM.Security.Login to log in JSmith.

  4. 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.

FeedbackOpens in a new tab