12-20-2016 02:20 PM
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
Solved! Go to Solution.
12-20-2016 02:39 PM
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.
12-20-2016 03:11 PM
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.
12-20-2016 03:42 PM
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.
12-21-2016 07:52 AM
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!
12-23-2016 06:11 AM
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
12-23-2016 08:35 AM
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
12-23-2016 08:50 AM
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
12-23-2016 09:39 AM
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
12-28-2016 11:23 AM
Thank you very much for your time and the complete solution i needed to implement it.
Regards,
Alejandro