Warm tip: This article is reproduced from serverfault.com, please click

How do I know that the current user can access a given security key?

发布于 2017-01-20 10:08:01

On my current Dynamics AX project, I must add a field group in a form, and protect this group by a given security key. For people with no access to this security key, I must display a replacement text.

How can I test that the current user has the right to access the security key, so that in this case I can hide the replacement text ?

Questioner
b2vincent
Viewed
0
Aliaksandr Maksimau 2017-01-20 19:14:05

You can use the following code to find whether user has the right to access the security key:

SecurityKeySet securityKeys; 
AccessType     accessType; 
; 

securityKeys = new SecurityKeySet(); 
securityKeys.loadUserRights(curUserId()); 
accessType = securityKeys.access(securityKeyNum("YourSekurityKey")); 
info(enum2str(accessType));