2

Security API

 2 years ago
source link: https://dev.goshoom.net/2020/02/security-api/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Security API – Goshoom.NET Dev Blog

The product that used to be called Microsoft Dynamics 365 for Finance and Operations (I truly don’t know how I should call it these days) allows defining security elements both by developers (delivered together with code) and by power users though GUI (stored in database). You may have a need to work with security objects in code and you want to get information from both sources. An API providing a unified view would be handy.

I’m not going to cover it in detail, but let me show you an example: an iteration of security privileges and getting information about security permissions contained in privileges:

using Microsoft.Dynamics.AX.Security.Management.Domain;
 
class SecurityApiDemo
{
    public static void main(Args _args)
    {
        var privilegesRepo = SysSecurity::GetSecurityRepository().Privileges;
        var privEnumerator = privilegesRepo.LoadAll().GetEnumerator();
 
        while (privEnumerator.MoveNext())
        {
            Privilege privilege = privEnumerator.Current;
            setPrefix(strFmt("Privilege %1", privilege.Name));
 
            var grantEnumerator = privilege.ActionMenuItemGrants.GetEnumerator();
            while (grantEnumerator.MoveNext())
            {
                MenuItemGrant grant = grantEnumerator.Current;
                info(strFmt("%1 (%2)", grant.Name, grant.Grant.ToString()));
            }
        }
    }
}

Apart from ActionMenuItemGrants, there are also DisplayMenuItemGrants, OutputMenuItemGrants, DataEntityGrants, ServiceOperationGrants and DataModelGrants.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK