Skip to main content
Apr 15, 2021 2:46 PM UTC
Question

Check permission for a specific user

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

 

 

 

13 replies

Apr 16, 2021 1:21 PM UTC

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

iguerraAuthor
Apr 19, 2021 7:57 AM UTC

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...

Apr 19, 2021 11:45 AM UTC

Hi @iguerra 

 

"Check Permission for User" service is used to check if any entity has a specific runtime permission for a specific user 

 

Parameters:

  1. name / Name of the resource(i.e property, service, event) to check : string
  2. type / Permission Type : String
  3. user / User name : USERNAME

Output : Boolean

 

Regards,

Toolika Dixit

 

 

May 10, 2021 6:45 PM UTC

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

iguerraAuthor
May 11, 2021 7:08 AM UTC

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

May 11, 2021 9:08 AM UTC

@iguerra 

 

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

May 21, 2021 8:11 PM UTC

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