cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Check permission for a specific user

iguerra
15-Moonstone

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

 

 

 

13 REPLIES 13
tdixit
15-Moonstone
(To:iguerra)

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

iguerra
15-Moonstone
(To:tdixit)

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

tdixit
15-Moonstone
(To:iguerra)

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

 

 

iguerra
15-Moonstone
(To:tdixit)

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.

tdixit
15-Moonstone
(To:iguerra)

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

iguerra
15-Moonstone
(To:tdixit)

But this works for the current user (who runs the service), not for a user that I can pass as parameter ....

slangley
23-Emerald II
(To:iguerra)

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

iguerra
15-Moonstone
(To:slangley)

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

mgoel
17-Peridot
(To:iguerra)

@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

@iguerra 

 

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): PropertyReadPropertyWriteEventSubscribe , EventInvoke, and ServiceInvoke

name - Name of the resource (i.e. property, service, event) to check 

SachinSharma_2-1620724378638.png

 

 

I created a new PermissionTestUser and did not provide any permissions and ran this service for the new user and it returned false.

SachinSharma_3-1620724477250.png

 

 

 

iguerra
15-Moonstone
(To:SachinSharma)

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 ?

@iguerra 

 

I don't think there is any OOTB service to check user's visibility permission on an entity. A enhancement ticket is already open with R&D for this feature and it might get included in future releases. Refer this article for a workaround.

 

Regards,

Sachin 

slangley
23-Emerald II
(To:iguerra)

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

Announcements


Top Tags