NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting privileges using API's

Solved!
Go to solution

Hi,

 

I am a TestStand newbie. Please bear with me if this question seems very basic.

I am trying to build a C# wrapper around the user management module in TestStand. I have created a new UI that reads all the features of a user like his groupname , privileges etc. 

 

How can I access the NI_UserCustomPrivileges using API's?
I require to access custom priviliges under the Custom grouping in Privileges.

 

I would really appreciate any assistance in this.

0 Kudos
Message 1 of 6
(3,821 Views)
Solution
Accepted by topic author Arun Padmanabhan
Use the User.HasPrivilege method.  This method takes as a parameter a lookup string representing the particular privilege you're searching for.  For example, you can search for the base name, i.e. "RunSelectedTests" [User.HasPrivilege("RunSelectedTests")] or you can search for the full path, i.e. "Debug.RunSelectedTests."  In this manner, you should be able to search for Custom privileges like "Custom.MyPrivilegeName."  Note that if you search for only the base name and there are multiple instances of that basename that exist, TestStand will only operate on the first instance that it finds.
Message 2 of 6
(3,802 Views)

Thank you ga101 for you assistance. I tried to read the privilege using the privilige name and it worked.

One more question please. 

In this case I knew the name of the privilege and so was able to query appropriately. The privilegesof all the collections like admin, operator, developer etc. seem static. The contents of the Custom collection are dymanic.

Is it possible to get the name and the datatype of the privilege from the NI_UserCustomPrivileges collection using API's?

 

Thanks

 

0 Kudos
Message 3 of 6
(3,799 Views)

Hi,

 

The Custom Privileges for a user are just a container.  Once you use the TestStand API to retrieve a reference to the User Privileges container, you can iterate over all the Custom Privileges (items in the container) to retrieve references to each individual Privilege and then from that reference, get Name and Type information.

 

have a look at example below. (TestStand 4.1). You can use the exact same API calls from C to achieve the results.

 

Regards,

Vaibhav

 

 

.......^___________________^
....../ '---_BOT ____________ ]
...../_==O;;;;;;;;_______.:/
.....),---.(_(____)/.....
....// (..) ),----/....
...//____//......
..//____//......
.//____//......
..-------
0 Kudos
Message 4 of 6
(3,700 Views)

Hi Vaibhav,

 

It seems that you have forgotten to add the sample  :smileyhappy:

 

Please note that I am using TestStand 4.0.

 

Thanks

Arun

 

0 Kudos
Message 5 of 6
(3,694 Views)

sorry. here is the file.

 

 

.......^___________________^
....../ '---_BOT ____________ ]
...../_==O;;;;;;;;_______.:/
.....),---.(_(____)/.....
....// (..) ),----/....
...//____//......
..//____//......
.//____//......
..-------
0 Kudos
Message 6 of 6
(3,691 Views)