Configuring User Permissions in NI Auth for LabVIEW Web Services

Updated May 3, 2018

Reported In

Software

  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Professional

Issue Details

I would like to set up NI Auth for a LabVIEW Web Service that I am creating so that only users with the proper credentials can access it. How can I do this?

Solution

The following example will walk you through setting up NI Auth for a Web Service in LabVIEW 2011 or later. Instructions for LabVIEW 2010 and earlier can be found below. For both examples, we'll be using testuser2 as the username, testpassword2 as the password, and testpermission2 as the permission.

LabVIEW 2011 or later:
  1. Open a web browser and navigate to http://localhost:3580. This will launch the NI Web Monitoring and Configuration utility.
  2. Click the Login button at the top right corner and enter in the appropriate user name and password. The default user name is admin and the default password is left blank. Click OK.

Figure 1: NI Web Monitoring and Configuration Utility Login Screen
  1. Click the Security Configurations button on the left pane.

Figure 2: Security Configuration Button
  1. Click the '+' button at the bottom of the window in the Users tab.

Figure 3: New User Button
  1. Enter a username for the new user. In this example, the username will be testuser2.
  2. Enter a password for the new user by clicking on the Change Password button. The password will be testpassword2 for this example.
  3. Click the Save button at the bottom of the tab.
  4. Select the Permissions tab at the top of the window.

Figure 4: New Permissions Tab
  1. Click the '+' button at the bottom of the window in the Permissions tab.
  2. Enter a name for this new permission and remove the group called everyone in the These groups have this permission section. In this example, the permission will be named testpermission2.
  3. Click the Save button at the bottom of the window to save the permission.
  4. Create or open an existing project with VIs that you wish to use as part of your web service. In this example, we'll be using a simple project with one VI that adds two numbers called add.vi.
  1. In the Project Explorer window, right-click My Computer and select New » Web Service. 
  2. Drag add.vi into the Web Resources folder in the Project Explorer. Configure your web service as desired (i.e. Service name, Source files, etc.).
  3. Select the HTTP Method VI Settings category from the left pane of the Web Service Properties window and highlight add.vi.
  4. At the bottom of the Web Service Properties window, select the Security tab listed under Web Service VI Properties.

Figure 6: Web Service VI Properties Security Tab
  1. Click the blue '+' button to the right of the Required Permissions field underneath the Security tab.
  2. Type in the permission's name. 
  3. Finish configuring the properties of your web service as you desire and right-click the Web Service in the Project Explorer. From there, choose Application Web Server » Publish.
  4. To access this web service from a web browser, navigate to the appropriate URL mapping for the web service you configured. The URL can be found by right-clicking the add.vi in the Project Explorer and choosing  Show Method URL. For this example, the URL would be http://localhost:8080/testwebservice/add?y={x}&x={y} where {x} and {y} are the two numbers you wish to add. For example: http://localhost:8080/testwebservice/add/3/4
  5. This will take you to a login screen where you must enter in the username and password you created earlier.

Figure 7: Web Service Login in a Web Browser
  1. To access this web service from LabVIEW, you need to specify the username and password when you execute the Open Handle VI.

Figure 8: Web Service Login in LabVIEW 
LabVIEW 2010 or earlier:
  1. Open a web browser and navigate to http://localhost:3580. This will launch the NI Web Monitoring and Configuration utility. 
  2. Click the Login button at the top right corner and enter in the appropriate username and password. The default username is admin and the default password is blank. Click OK. 

Figure 1: NI Web Monitoring and Configuration Utility Login Screen
  1. Click on the Security Configurations button on the left pane.

Figure 2: Security Configuration Button
  1. Click on the New User button at the top.

Figure 3: New User Button
  1. Enter a username and password for this new user. 
  2. Click the Save button at the top of the tab.
  3. Click the New Permission button.

Figure 4: New Permission Button
  1. Enter a name for this new permission. 
  2. Assign the permission to the user you created in steps 4-6.

Figure 5: Assign Permission to User
  1. Click the Save button at the top of the window to save the permission.
  2. Click the Upload Changes button.

Figure 6: Upload Changes Button
  1. Create or open an existing project with VIs that you wish to use as part of your web service. We'll be using the same simple project with add.vi for this example.

Figure 7: add.vi
  1. In the Project Explorer window, right-click Build Specifications and select New » Web Service (RESTful). This will launch a properties dialog box to configure a web service. 
  2. Configure your web service as desired (i.e. Service name, Source files, etc.). In this example, we will name the web service testwebservice and use add.vi as our Service VI.

Figure 8: Service Name


Figure 9: Service VIs
  1. Select the URL Mappings category from the left pane and select the URL mapping you wish to assign an NI Auth permission to. in this example, we will use the default URL mapping for the add.vi service VI.
  2. At the bottom right corner of the window, click the blue plus sign (+) and enter in the name of the permission you created earlier.

Figure 10: Add Permission to URL Mapping
  1. Finish configuring the properties of your web service as you desire and click the Build button at the bottom of the window. Once the build is complete, click Done.
  2. Deploy the web service by right-clicking the web service name under Build Specifications and selecting Deploy.
  3. To access this web service from a web browser, navigate to the appropriate URL mapping for the web service you configured. For this example, the URL would be: http://localhost:8080/testwebservice/add/<y>/<x>, where <y> and <x> are the two numbers you wish to add. For example:  http://localhost:8080/testwebservice/add/3/4
  4. This will take you to a login screen where you must enter in the username and password you created earlier.

Figure 11: Web Service Login in a Web Browse
  1. To access this web service from LabVIEW, you need to specify the username and password when you execute the Open Handle VI.

Figure 12: Web Service Login in LabVIEW
 

WAS THIS ARTICLE HELPFUL?

Not Helpful