AccessControlService
MacroExpansionProvider.AccessControlService
The AccessControlService provides an API against a small subset of the InVision access control system.
Methods:
IsMemberOfAccessGroupAsync
Task<bool> IsMemberOfAccessGroupAsync(string identityId, string accessGroupName)
HasObjectAccessAsync
Task<bool> HasObjectAccessAsync(string identityId, string objectId)
HasWorkbookAccessAsync
Task<bool> HasWorkbookAccessAsync(string identityId, string workbookName)
HasWorkbookPageAccessAsync
Task<bool> HasWorkbookPageAccessAsync(string identityId, string workbookName, string pageName)
Example:
This example shows how to check whether the current user is a member of the “Admins” Access Group. Note that we’re using Context.GetUserUniqueId() to get the id of the current user.
namespace Local;using System.Threading.Tasks;using Profitbase.Invision.Scripting.Dynamic;public class MyMacros : MacroExpansionProvider{public async Task<string> GetQuery(string input){var userIsAdmin = await this.AccessControlService.IsMemberOfAccessGroupAsync(this.Context.GetUserUniqueId(), "Admins");if(userIsAdmin){return "IPAddress, CertificateRevocationDate, MachineName";}else{return "MachineName";}}}