NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Can user priviledges be changed programmatically.

We would like to allow the privileges associated with a profile to be edited with our CVI operator interface we are writing. Is this possible?
0 Kudos
Message 1 of 5
(3,472 Views)
I think so. I believe your CVI could would look something like this:

/* first get handle to engine */
TS_SeqContextGetProperty (sequenceContext, NULL, TS_SeqContextEngine, CAVT_OBJHANDLE, &engineHandle);

/* then get handle to profile you want */
TS_EngineGetUserProfile (engineHandle, NULL, "Operator", &userProfileHandle);

/* I'm a little fuzzy on this part - not sure if you can use the get/set property functions at this point or not */
TS_PropertySetValBoolean (userProfileHandle, NULL,
"Privileges.Operate.Execute", 0,
VFALSE);

Good luck, Mark
0 Kudos
Message 2 of 5
(3,472 Views)
This appears to work, but the change does not seem to be permanent. Is there something I need to do to write the users.ini file or something?
0 Kudos
Message 3 of 5
(3,472 Views)
Yes, I'm sure you do need to do something to save the file. The answer is somewhere in the TestStand Programmers Help. My guess is that you need to do something like this.

TS_UsersFileAsPropertyObjectFile (engineHandle, NULL, userFileHandle);
TS_PropertyObjectFileSaveFileIfModified (userFileHandle, NULL, VTRUE,);

For the first function, I'm not sure if it is looking for the engine handle, or some other handle.
0 Kudos
Message 4 of 5
(3,472 Views)
This eventually worked. The first function need a handle to the users file which I obtained with something like this:

TS_EngineGetProperty (engineH, &errorInfo, TS_EngineUsersFile, CAVT_OBJHANDLE, &usersFileH)

The confusing part was that it seems that the engine does not know that the user file is modified unless you tell it with something like:

TS_PropertyObjectFileIncChangeCount (usersFileAsPropObjH, &errorInfo)
0 Kudos
Message 5 of 5
(3,472 Views)