NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Add user to User group in Users.ini file using C#

Solved!
Go to solution

Hi,

 

Using a C# application, we are trying to add/delete a user from TestStand Users.ini file.

The CreateDeleteUsers.seq file in the TestStand  samples is being used as reference.

 

We have observed that we are able to add the user to the user file list using

engine.UsersFile.UserList.SetPropertyObjectByOffset(0, 0X1, newUser.AsPropertyObject());

 

However, when we try to add the user to the user group, the sample in  CreateDeleteUsers.seq file says

RunState.Engine.GetUserGroup(Locals.GroupName).Members.SetPropertyObjectByOffset(0, 0x1, Locals.User.AsUser.LoginName)

 

If we try to replicate this in C#, the API looks for the final parameter (which is LoginName in the CreateDeleteUsers.seq file) as a property object

engine.GetUserGroup(this.GroupName).Members.SetPropertyObjectByOffset(0, 0X1, newUser.AsPropertyObject());

 

This causes an object reference exception when we run the application.

 

Please advise on the proper procedure to follow.

 

Thanks

 

0 Kudos
Message 1 of 2
(3,175 Views)
Solution
Accepted by topic author Arun Padmanabhan

Arun -

The members property is an array of string, so the 3rd parameter to SetPropertyObjectByOffset requires a string property object, ie. the user name, and not the user object. Passing the user object will error with "-17308; Specified value does not have the expected type.". The example should really be using SetValStringByOffset to be more clear so that you specify only the actual string user name.

Message Edited by Scott Richardson on 11-17-2008 10:44 AM
Scott Richardson
Message 2 of 2
(3,167 Views)