NI TestStand

Showing results for 
Search instead for 
Did you mean: 

get group name of currently logged in user

I have the following problem,
a operator user named Jan is logged in. I would like to use the teststand API to get the group of the user that is logged in. So for user Jan this would be the group operator.
I can't find the right method to get the group of the logged in user.
Is there anybody who has an idea?
0 Kudos
Message 1 of 9
Hello GertW,

there is no direct support through the TestStand API that allows to access the group property of a user. But you can do one of the following:

1. Create a reference to the user object of the user group as described in the following KB:

At least you need to know the name of the groups that are present in the system in order to check for the membership of a specific user.

2. Follow the steps described in the following thread:

This example evaluates the group membership through the priviledges of a user.

Currently there is no alternative, even in TestStand 4.0. The direct feature has been proposed by many customers, but not yet been implemented.

Hope this helps,


C.L. - NI Germany
0 Kudos
Message 2 of 9


The type information  I believe is not available from the User information. The only way would be to use the privileges.


Ray Farmer

Ray Farmer
0 Kudos
Message 3 of 9
Basically you would need to get the list of groups and look through them for a matching user.
Here are some helpful hints
You can get the current user from Engine.CurrentUser.
You can get the list of groups by Engine.UsersFile.UserGroupList
Each array item in the list of groups is a group (in the form of a user object)
You can get the list of users from a group by it's User.Members property
0 Kudos
Message 4 of 9
I was able to get the user group by interating through the different group and using the property object is equal.  I have a attached a screen shot of what I did in LV 6.1 and TS 2.0.
0 Kudos
Message 5 of 9

Hello, I had the same problem. Here is a smaller version to find the Group of the current User.

The VI get the members of a Group and match it with the Username.


Note :

If the User belongs to multiple Groups the the VI returns only the 1st Groupname

If the User belongs to no Group then the VI returns "unknown Group"

The VI is written with LabVIEW 2010 and TestStand 4.2.1

Download All
Message 6 of 9

This should help some people. Took two full days to figure out how to access the correct members...


TestStand Users and Groups C# API



0 Kudos
Message 7 of 9



Anyone know how to get the Groups names using Labwindows/CVI?


Created this code but for some reason im not getting the GroupName from this function 

TS_PropertyGetValStringByOffset (groupList, &errorInfo, i, 0, GroupName);


//Example to Retreive Groups Names and filter via group names
TS_EngineGetUsersFile (engine, NULL,&UserFile); TS_UsersFileGetUserGroupList (UserFile, &errorInfo, &groupList); TS_PropertyGetNumElements (groupList, &errorInfo, &numGroups); for(int i=0; i<numGroups; i++) { TS_PropertyGetPropertyObjectByOffset (groupList, &errorInfo, i, 0, &group); TS_PropertyGetValStringByOffset (groupList, &errorInfo, i, 0, GroupName); if(!stricmp(GroupName,"Operator")) { TS_UserGetMembers ((TSObj_User)group, &errorInfo, &members); } }


Help share your knowlegde
0 Kudos
Message 8 of 9

Here is a simple method that checks whether the user has a privilege that is owned by a group but not by any lower (less potent) group (this is C#):


if (user.HasPrivilege("Configure.GrantAll")) // only Administrators have this
    group = "Administrator";
else if (user.HasPrivilege("Develop.GrantAll")) // Technicians and Operators don't have this
    group = "Developer";
else if (user.HasPrivilege("Operate.GrantAll")) // Operators don't have this - surprisingly!
    group = "Technician";
    group = "Operator";

. 'user' is the User object obtained, for example, from Engine().UsersFile.UserList.GetPropertyObject(username, 0).

If a user is in multiple groups it returns the highest group.

0 Kudos
Message 9 of 9