NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How can it be got the list of groups the current user belongs to?

Solved!
Go to solution

Good afternoon, 

I need to get all the groups the current user logged in belongs to. That is to say, the group privilegies enabled for the current user.

This info will be used to determine if it has capability on doing some action or not on a specific step defined particularly for my sequence.

Regards, 

Alejandro

0 Kudos
Message 1 of 12
(4,413 Views)

Hi AlePinto,

 

The CurrentUser object exists in StationGlobals. To access their privileges, you'd use StationGlobals.TS.CurrentUser.Privileges and parse through each object in the container as necessary.

 

StationGlobals.TS is a hidden property by default, you can show hidden properties by selecting the option from the Preferences tab in the Station Options menu.

Steven Gloor
Staff Customer Engineer - CTA, CLD
0 Kudos
Message 2 of 12
(4,406 Views)

I did not know all that info was present in that container and i appreciate your quick answer. Anyway, what i am looking for is what group privileges such as Auditor, Operator, Technician, Developer and Administrator, available in User Manager, are enabled for the current user in order to determine its capabilities without accessing each privilege individually through the container you mention.

Another way might be asking the list of users that belong to Administrator group, for example, and checking if one of them matches the current user to determine if it is Administrator but i do not know how to do it.

 

0 Kudos
Message 3 of 12
(4,397 Views)

Take a look at this KnowledgeBase Article: "Is It Possible to Obtain the Profile or Group of an Existing User?"  I think it will help to answer your question.

Steven Gloor
Staff Customer Engineer - CTA, CLD
Message 4 of 12
(4,387 Views)

Yes, that is exactly what i need! I have read this article but as i am not familiar with using methods (TestStand APIs) for example i couldn't implement it yet.

I think i have to use a Statement step with Expression similar to this:

RunState.Engine.GetUserGroup("administrator")
User.Members
RunState.Engine.CurrentUser() 

But i need more help to make it work...

Thanks!

0 Kudos
Message 5 of 12
(4,362 Views)

Hi Alejandro,

 

I've put together a sequence that should get you started:

 

GetUserGroups(string User, array of strings[0..empty] Groups)

You can pass in the current user login name and the sequence will search through all group members for a match and return back an array of groups the user is a member of.

 

(see attached sequence file).

 

I hope this helps,

 

Regards,

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

0 Kudos
Message 6 of 12
(4,315 Views)

Hello CharlieRodway,

 

Thank you very much for the solution! Anyway, i couldn't open this file since i have installed TestStand 2013 and i would need a downgrade of that sequence file to access to it.

 

Regards,

 

Alejandro

0 Kudos
Message 7 of 12
(4,305 Views)

Hi Alejandro,

 

i'll save it as a TS2013 sequence file shortly.

 

 

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

0 Kudos
Message 8 of 12
(4,300 Views)
Solution
Accepted by topic author AlePinto

Hi,

 

Please find attached the TestStand 2013 copy of the sequence file.

 

Regards,

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

Message 9 of 12
(4,292 Views)

Thank you very much for your time and the complete solution i needed to implement it. 

Regards, 

Alejandro

0 Kudos
Message 10 of 12
(4,254 Views)