Example Code

Using TestStand Users to Restrict Access to Certain Test Sequences from a LabVIEW UI

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Teststand

Code and Documents

Attachment

Overview

This example shows how to check for specific permissions before running the rest of a sequence.  This can be useful to prevent certain users from unintentionally running diagnostic or debugging code.

 

Description

You may want to restrict which users have permission to run certain sequence files, for example, you may want to prevent an operator user from running a calibration routine.  To accomplish this, you can use the TestStand API to check whether the current user has a specific permission:

  

RunState.Engine.CurrentUser.HasPrivilege("Debug")

 

In this example, if this method returns false, the sequence file terminates and reports to the user that the sequence requires specific permissions to execute.

 

 

Hardware and Software Requirements

Require Privileges To Execute - TS2012.seq

TestStand 2012 or Compatible

 

Steps to Implement or Execute Code

  1. Open and run the attached example using Execute » Run MainSequence.
  2. Observe that the example executes with no issues.
  3. In the user manager, create an operator user with only the Operate privileges. 
  4. Log out of TestStand and log in with the new user.
  5. Open the sequence file again and run it.  Observe that a message is shown indicating that the "Debug" privilege is required, and the example terminates.

 

Additional Information or References

 

Aldo H
Ingenieria de Aplicaciones

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.