web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

in X++ Bring the menu item names from entry points against its security privilege through code in d365.

(0) ShareShare
ReportReport
Posted on by 1,215

Hi, guys

  Bring the menu item names from entry points against its security privilege through code in d365

 what should i do?

regards,

Riyas ahamed F 

I have the same question (0)
  • Community Member Profile Picture
    on at

    From X++ not sure but, from SQL, may be try below. I got this long time back in github.

    Use [AXDB]

    go

    DECLARE @Duties TABLE

    (

          IDENTIFIER nvarchar(81),

          XMLData xml

    )

    DECLARE @DutiesPrivilege TABLE

    (

          Privilege nvarchar(100),

          Duty nvarchar(200)

    )

    INSERT INTO @Duties(Identifier, XMLData)

     SELECT [IDENTIFIER], (CAST([DATA] as XML))

       FROM [AxDB].[dbo].[SECURITYPRIVILEGEPARENTREFERENCES]

    ;WITH XMLNAMESPACES (DEFAULT 'schemas.datacontract.org/.../Microsoft.Dynamics.AX.Security.Management')    

    INSERT INTO @DutiesPrivilege(Privilege, Duty)

    SELECT T.IDENTIFIER,(Cast(T2.Duties.query('text()') as nvarchar(200))) as Duty

    FROM  @Duties T

    CROSS APPLY T.XMLData.nodes('/PrivilegeParents/Duties/node()') as T2(Duties)

    select

    Role1.AOTNAME as RoleAOTName,

    Role1.NAME as RoleName,

    Duty.IDENTIFIER as DutyIdentifier,

    Duty.NAME as DutyName,

    DP.Privilege as PrivilegeIdentifier,

    P.NAME as PrivilegeName

    from dbo.SECURITYROLEDUTYEXPLODEDGRAPH graph

    join dbo.SECURITYDUTY Duty on Duty.RECID = graph.SECURITYDUTY

    join dbo.SECURITYROLE Role1 on Role1.RECID = graph.SECURITYROLE

    join @DutiesPrivilege DP on DP.Duty = Duty.IDENTIFIER

    join dbo.SECURITYPRIVILEGE P on P.IDENTIFIER = DP.Privilege

    select PP.PRIVILEGEIDENTIFIER,P.Name,

    case PP.SECURABLETYPE

    when 1 then 'menuitemdisplay'

    when 2 then 'menuitemoutput'

    when 3 then 'menuitemaction'

    when 55 then 'weburlitem'

    when 56 then 'webactionitem'

    when 57 then 'webdisplaycontentitem'

    when 58 then 'weboutputcontentitem'

    when 75 then 'webmanagedcontentitem'

    when 73 then 'webcontrol'

    when 59 then 'webletitem'

    when 44 then 'tablefield'

    when 45 then 'classmethod'

    when 76 then 'serviceOperation'

    when 11 then 'FormControl'

    when 82 then 'formpart'

    when 81 then 'infopart'

    when 85 then 'ssrsreport'

    when 18 then 'report'

    when 115 then 'codepermission'

    when 143 then 'formdatasource'

    when 67 then 'dataentity'

    when 146 then 'dataentitymethod'

    End as SecurableType,

    PP.AOTName  as PermissionAOTname,

    PP.AOTCHILDNAME      as PermissionAOTChildName,

    PP.READACCESS as ReadAccess,

    PP.UPDATEACCESS as UpdateAccess,

    PP.CREATEACCESS as CreateAccess,

    PP.CorrectAccess as CorrectAccess,

    PP.DeleteAccess as DeleteAccess,

    PP.INVOKEACCESS as InvokeAccess from

    dbo.[SECURITYRESOURCEPRIVILEGEPERMISSIONS] PP

    join dbo.SECURITYPRIVILEGE P on P.IDENTIFIER = PP.PRIVILEGEIDENTIFIER

  • Riyas ahamed F Profile Picture
    1,215 on at

    Thanks for your quickly replay Bharath Byndoor

    but, i want to X++ only it is any similer option.

  • Community Member Profile Picture
    on at

    Oh yes, i remember, there were  some entities like SystemSecurityPermissionEntity.

    Search security in aot and check under, Data entities, you'll find them.

  • Verified answer
    André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    Hi Riyas,

    You can check the logic used on the form Security configuration. It also gives an overview of menu items per privilege. Note that a privilege can contain multiple type of permissions; not only menu items.

  • alexmeyer.itguy Profile Picture
    648 on at

    I work for a company called Fastpath that specializes in security, audit, and compliance reporting. Here's how we get data like this:

    In X++:

    SecurityRepository securityRepository = SysSecurity::GetSecurityRepository();

    Security::GetPrivilegeAccess(securityRepository);

    In .NET:

    public class Security

    public static ArrayList GetPrivilegeAccess(SecurityRepository sr)
            {
                //Create return array list
                var lstPrivAccess = new ArrayList();

                RelatedSecurityObjectsFinder rsof = new RelatedSecurityObjectsFinder(sr);

                //Get privilege list
                IReadOnlyPrivilegeRepository pr = sr.Privileges;

                //Iterate privilege list
                foreach (var priv in pr.ListObjects())
                {
                    //License aggregate variable
                    ComputedLicense licAggregate;
                    //Get privilege access
                    ISecurityRelatedObjectsData srod = rsof.FindRelatedSecurityObjectsForPrivilegeWithLicenseInfo(priv, out licAggregate);
                    //Iterate privilege access
                    foreach (var ro in srod.RelatedObjects)
                    {

                    //ro is a SecurityRelatedObjectsRecord which contains the object and access, build object you want to return and add it to lstPrvAccess list

                    }

                 //Return array list
                return lstPrivAccess;

    }

    Feel free to reach out with any questions you might have.

  • Awaxx Profile Picture
    229 on at

    Hi

    Why using .net code in the second part ?

    Thanksfully.

  • alexmeyer.itguy Profile Picture
    648 on at

    For a couple reasons:

    1) .NET handles collections much better than X++ in my opinion

    2) If using .NET code you get things like LINQ and nuget packages to help perform business operations

    3) Most organizations (including the one I work for) have many more .NET developers than X++, so by offloading as much logic to .NET as possible makes it much easier (and cheaper) to support

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans