NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programmatically retrieve Users File in LabVIEW

Solved!
Go to solution

Hi,

I would like to create custom User Manager tool in LabVIEW, but I can't get user container. I'm able to get Users array (I have only "administartor" item in Users File), but I'm not able to get subproperties 😞 I'm getting -17306 error in GetNumSubProperties.

I tried with the following code.

Get Users File.png

How to programmatically copy all Users File to LabVIEW Tree Control? Or at least list all in form of array.

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 1 of 10
(4,573 Views)
Solution
Accepted by bienieck

First of all I can tell you that it will always be 5 on the NumSubProperties.  🙂

 

The problem is you are using the name as the lookupString.  Pass an empty string and you will see what you want.  An empty string will get the number of subProperties of the current PropertyObject, which in this case is the User.

 

Or you can convert the reference of your GetPropertyObjectByOffset to a User by using a Variant to Data and use a refnum constant set to the TestStand API User.  This way you can use the TestStand API for User to get whatever you'd like.  I've attached a small example using LabVIEW 2011 and TestStand 2010

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 2 of 10
(4,560 Views)

"First of all I can tell you that it will always be 5 on the NumSubProperties."

So it is not possible to modify User data type?

 

Thank you for the solution with varinat, it is very elegant IMO. I will use this approach. Other, small but usefull, style convention is changing Close Referece primitives lables so they informs which reference are they closing. I will stick with that also 🙂

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 3 of 10
(4,525 Views)

Jigg I have a question related with your code.

Is User and User Object the same reference? Why do I need to use User Object Close Reference?

666.png

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 4 of 10
(4,501 Views)

I don't completely understand it, but basically they are different references.  I know that if you don't close both you will get an error message when you exit.  At least I did.

 

I think it has something to do with the Variant To Data node.  I believe that it is switching out activex components and therefore creating a different reference.

 

Sorry I'm not more versed in that.

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 5 of 10
(4,492 Views)

Jigg is correct,

 

VariantToData is getting an interface, which is a separate reference. It's mentioned briefly on page 63 and 64 of Using LabVIEW and LabWindowsTM/CVI with TestStand in the "Obtaining a Different Interface for TestStand Objects" and "Duplicating COM References in LabVIEW Code Modules" sections.

 

-Trent

https://www.linkedin.com/in/trentweaver
Message 6 of 10
(4,487 Views)

Can you share your method to get the previliges? i am corious about it! Thank you in advance!

0 Kudos
Message 7 of 10
(2,936 Views)

@open28 wrote:

Can you share your method to get the previliges? i am corious about it! Thank you in advance!


Do you want to check if the current user has a certain privilege?  Then use this method: https://zone.ni.com/reference/en-XX/help/370052AA-01/tsapiref/reftopics/engine_currentuserhasprivile...

 

Otherwise you can do: User.Privileges which will give you the privilege settings for that user.

 

Maybe I'm not clear what you are looking for?

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 8 of 10
(2,923 Views)

HI, thank you for your response.

I just now want to design a LABVIEW GUI and just use the TESTSTAND 2014 simple GUI labview source code.

For managing  the prevelliges such as operator can not config the setting, I hope i can get the prevellige after login a user, then i can judge the person whether have the prevellige to config ,and gray the setting button.

Now the most important problem is that i don`t know how to get the current user prevellige after the user login. And the methond you said is useful after the Test UUT is running and i just need to use the property to get it.But I want to get the prevellige before the test UUT is running.

Can you share me some other method?

Thank you in advance!

0 Kudos
Message 9 of 10
(2,907 Views)

Actually you don't need an execution in order to call those methods.  As long as you have a reference to the engine (which you should once the application manager calls the Start method), then you should be able to call those methods.  I do this all the time in user interfaces.

 

CurrentUserHasPrivilege.jpg

 
jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 10 of 10
(2,894 Views)