Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Is there a way to check, from a service, if a specific user (note: not the current user) has access to a specific entity ?
It would be enouth to check "visibility" access.
That service would be run by an admin-level user.
It should works like the " Permissions | Access Reports" utility on the composer
Hi @iguerra
Currently there is no OOTB service to quickly determine if a ThingWorx user has visibility to a ThingWorx entity
but please check this article there is a example code present in it which will return a Boolean of TRUE or FALSE if the specified user has specific visibility to the entity
Regards,
Toolika Dixit
Hello @tdixit
this is what I'm doing ... checking Visibility permissions set directly on the entity, unfortunately this method does not consider the "collection" permissions.
The article is referred to thingworx 7.0 ... strange on version 8.5 or 9+ this is still not possible.
I found now that there is a service on CollectionFunctions -> CheckPermissionForUser
but it returns a boolean, and is not clear the function of parameters
// result: BOOLEAN
var result = Resources["CollectionFunctions"].CheckPermissionForUser({
name: undefined /* STRING */,
type: undefined /* STRING */,
user: undefined /* USERNAME */
});
May be "name" is entity name , and "type" is the specific permission to check (visibility ... runtume execution...) ?
The service never gives error codes...
Hi @iguerra
"Check Permission for User" service is used to check if any entity has a specific runtime permission for a specific user
Parameters:
Output : Boolean
Regards,
Toolika Dixit
Name is "entity name" or a property/service/event name...fora specific entity ?
How can I pass the entity name and also a sub property ?
Whatever I write on params it returns me FALSE ... do you have an example ?
My need is currently to check just visibility permission.
Hi @iguerra
In order to check the visibility permission on collection level. You can consider using below service
// result: INFOTABLE dataShape: Permissions
var result = Resources["CollectionFunctions"].GetCollectionVisibilityPermissions(params);
Regards,
Toolika Dixit
But this works for the current user (who runs the service), not for a user that I can pass as parameter ....
Hi @iguerra.
If you feel your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.
Regards.
--Sharon
I can't use
Resources["CollectionFunctions"].CheckPermissionForUser
always returns false, and never gives errors (also with bad parameters)
Can someone give a working example ?
I have Thingworx 8.5 SP9
yes you are right. Service is executing without result and error. I just tried the same service directly from the resources in 9.1 version but hard luck. May be i can check this internally and get back to you.
Regards,
Mohit
Please check below screenshot for working example of service CheckPermissionForUser(Check to see if an entity has a specific run time permission for a specific user),
Twxuser has run time PropertyRead permission for the mentioned property hence it returns true.
The valid inputs for the type parameter are (case sensitive): PropertyRead, PropertyWrite, EventSubscribe , EventInvoke, and ServiceInvoke
name - Name of the resource (i.e. property, service, event) to check
I created a new PermissionTestUser and did not provide any permissions and ran this service for the new user and it returned false.
On the name field (name of the resource), how can I define the thing name and property name ?
is it possible to check just the visibility permission for an entity ?
Hi @iguerra.
If any of the previous posts were helpful, please mark the appropriate one as the Accepted Solution for the benefit of others with the same question.
Regards.
--Sharon