Skip to main content
16-Pearl
April 15, 2021
Question

Check permission for a specific user

  • April 15, 2021
  • 3 replies
  • 4815 views

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 " PermissionsAccess Reports" utility on the composer

 

 

 

3 replies

5-Regular Member
April 16, 2021

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

iguerra16-PearlAuthor
16-Pearl
April 19, 2021

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

5-Regular Member
April 19, 2021

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

 

 

Support
May 10, 2021

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

iguerra16-PearlAuthor
16-Pearl
May 11, 2021

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

5-Regular Member
May 11, 2021

@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

Support
May 21, 2021

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