Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hello, Is there a way to get that information programmatically, if so, could you please share sample script?
Solved! Go to Solution.
General configuration idea is -- 1. Use the GetEntityList service of EntityServices resource. It will return a list of entities the user has visibility to; 2. Create a datashape that is used for listing the result of permission; 3. Use the CheckPermissionForUser service of the SecurityService resource. Then sort out the query result to an infotable with the defined datashape.
Take an example of listing user's permission:
var entities = Resources["EntityServices"].GetEntityList({
maxItems: undefined /* NUMBER */,
nameMask: "*Thing" /* STRING */,
type: "Thing" /* STRING */,
tags: undefined /* TAGS */
});
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(CheckPermissionDataShape)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "CheckPermissionDataShape"
});
var row = new Object();
for (var i=0;i<entities.length;i++){
row.user=UserName;
row.entity=entities[i].name;
row.PropertyRead = Resources["SecurityServices"].CheckPermissionForUser({
name: entities[i].name /* STRING */,
type: "PropertyRead" /* STRING */,
user: UserName /* USERNAME */
});
row.PropertyWrite = Resources["SecurityServices"].CheckPermissionForUser({
name: entities[i].name /* STRING */,
type: "PropertyWrite" /* STRING */,
user: UserName /* USERNAME */
});
row.serviceInvoke = Resources["SecurityServices"].CheckPermissionForUser({
name: entities[i].name /* STRING */,
type: "ServiceInvoke" /* STRING */,
user: UserName /* USERNAME */
});
row.EventInvoke = Resources["SecurityServices"].CheckPermissionForUser({
name: entities[i].name /* STRING */,
type: "EventInvoke" /* STRING */,
user: UserName /* USERNAME */
});
row.EventSubscribe = Resources["SecurityServices"].CheckPermissionForUser({
name: entities[i].name /* STRING */,
type: "EventInvoke" /* STRING */,
user: UserName /* USERNAME */
});
result.AddRow(row);
}
The result looks like below:
General configuration idea is -- 1. Use the GetEntityList service of EntityServices resource. It will return a list of entities the user has visibility to; 2. Create a datashape that is used for listing the result of permission; 3. Use the CheckPermissionForUser service of the SecurityService resource. Then sort out the query result to an infotable with the defined datashape.
Take an example of listing user's permission:
var entities = Resources["EntityServices"].GetEntityList({
maxItems: undefined /* NUMBER */,
nameMask: "*Thing" /* STRING */,
type: "Thing" /* STRING */,
tags: undefined /* TAGS */
});
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(CheckPermissionDataShape)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "CheckPermissionDataShape"
});
var row = new Object();
for (var i=0;i<entities.length;i++){
row.user=UserName;
row.entity=entities[i].name;
row.PropertyRead = Resources["SecurityServices"].CheckPermissionForUser({
name: entities[i].name /* STRING */,
type: "PropertyRead" /* STRING */,
user: UserName /* USERNAME */
});
row.PropertyWrite = Resources["SecurityServices"].CheckPermissionForUser({
name: entities[i].name /* STRING */,
type: "PropertyWrite" /* STRING */,
user: UserName /* USERNAME */
});
row.serviceInvoke = Resources["SecurityServices"].CheckPermissionForUser({
name: entities[i].name /* STRING */,
type: "ServiceInvoke" /* STRING */,
user: UserName /* USERNAME */
});
row.EventInvoke = Resources["SecurityServices"].CheckPermissionForUser({
name: entities[i].name /* STRING */,
type: "EventInvoke" /* STRING */,
user: UserName /* USERNAME */
});
row.EventSubscribe = Resources["SecurityServices"].CheckPermissionForUser({
name: entities[i].name /* STRING */,
type: "EventInvoke" /* STRING */,
user: UserName /* USERNAME */
});
result.AddRow(row);
}
The result looks like below:
@EM_9923519 : If the previous response answered your question, please mark it as the Accepted Solution for the benefit of others with the same question.
When using the code you share I get this error message
Error executing service myService. Message :: Type not found: [CheckPermissionDataShape] - See Script Error Log for more details.
Do I need to create this CheckPermissionDataShape? Is there a way to get the result as a plain infotable?