NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I access the groups selected in DisplayNewUserDialog?

Solved!
Go to solution

I am developing a user manager for a deployment so that the production floor manager can add users as they are trained. I modified the simple OI to add a button "Manage users", which is implemented as a VI.

 

I have this pretty much working except when I add a user using the DisplayNewUserDialog, I don't see any way to access the groups that can be selected in the dialog. Selecting a group in the dialog apparently does nothing. I save the user object that gets passed back from the dialog and that "sticks". But the group selection doesn't stick nor do I see any way to access the selection. Using the DisplayEditUserDialog on the same user object does properly save selected group membership(s) without having to make an extra call.

 

I see that in the example CreateDeleteUsers.seq, there is a step "Add User to Group" which looks up the group by the name selected by the user. To paraphrase the steps:

 

  1. Add new user: RunState.Engine.UsersFile.UserList.SetPropertyObjectByOffset(0, 0x1, Locals.User)
  2. Add user to group (sets privileges): RunState.Engine.GetUserGroup(Locals.GroupName).Members.SetValStringByOffset(0, 0x1, Locals.User.AsUser.LoginName)

 

I don't see how I can programmatically retrieve that group name ("Locals.GroupName" above) from the dialog box, nor from the user object that is returned from the dialog box. Is this a bug?

0 Kudos
Message 1 of 8
(3,479 Views)

Update: I misunderstood the dialog somewhat. It allows you to copy privileges from a group, not select the group itself (although I still didn't see any evidence that the copied privileges stick either).  Since I want to put a newly added member in the "Operator" group, I will have to train the floor supervisors to first add the user and then edit (using the edit dialog) to add the user to the correct group. I'm kind of happy with the VI. Here are some screen shots:

 

The current user cannot delete himself. If he has admin privileges, he can add and edit.

AdminCannotDeleteSelfExample.png

 

Users with admin privileges can select from the list of users (alphabetized) and add, delete, or edit.

adminExample.png

 

Users without admin privileges can only change their own record, and only their password within that record.

NoOneLoggedInExample.png

 

0 Kudos
Message 2 of 8
(3,475 Views)

Hi,

 

If you want to programmatically access the group names, use the following:

 

RunState.Engine.UsersFile.Data.UserTemplates

 

This is an array of the groups, so querying the name of all of the elements will give you all of the group names.  You may want to have a second dialog appear after the users dialog which allows you to select a group for the newly created user, which contains a ring control populated with the elements of the UserTemplates property.

 

Hope this helps!

Al B.
Staff Software Engineer - TestStand
CTA/CLD
0 Kudos
Message 3 of 8
(3,469 Views)

How do I get to in LabVIEW? I only see UserGroupList, UserList, and UserList(putRef) as properties for the UsersFile.

 
 
0 Kudos
Message 4 of 8
(3,459 Views)

I figured out how to get the group list in LabVIEW:

list user groups.png

0 Kudos
Message 5 of 8
(3,454 Views)
Solution
Accepted by topic author gizmogal

Hi Gizmogal,

 

Your implementation will definately work.  To access the RunState.Engine.UsersFile.Data.UserTemplates property I mentioned, we need to use a lookup string:

 

1.png

Al B.
Staff Software Engineer - TestStand
CTA/CLD
0 Kudos
Message 6 of 8
(3,450 Views)

Thanks!  I tried both ways and got exactly the same results each way.

0 Kudos
Message 7 of 8
(3,443 Views)

By the way, I did add a dialog to ask the administrator to select the new user's group from that list, which I then use to add the new user to the group membership, so that was the solution to my initial question.

0 Kudos
Message 8 of 8
(3,440 Views)