Get AX User-Role-Privilege-Entry point in X++

获取一个用户的角色和duty

static void lyc_getPrivilegeSummary_SMC(Args _args)
{
    //<Security Varibales>
    SecurityRole                securityRole;
    SecurityUserRole            securityUserRole;
    SecurityRoleTaskGrant       securityRoleTaskGrant;
    SecurityTask                securityTask;
    UserInfo                    tblUserInfo;
    //</Security Varibales>
    
    select id from tblUserInfo
        where tblUserInfo.id == 'annal';
    
    setPrefix("User Name: "+tblUserInfo.id);
    
    while select * from securityRole
            join securityUserRole
                where securityRole.RecId == SecurityUserRole.SecurityRole
                        && SecurityUserRole.User == tblUserInfo.id
            {

                setPrefix("Role: "+securityRole.Name);
                while select securityRoleTaskGrant
                    where securityRoleTaskGrant.SecurityRole == securityRole.RecId
                {
                    while select securityTask
                       where securityTask.RecId == securityRoleTaskGrant.SecurityTask
                        && securityTask.Type == SecurityTaskType::Duty
                        {
                            info(strFmt('Security Duty: %1',securityTask.Name));
                        }
                }
            }
}

获取一个privilege的Entry point

 static void lyc_getPrivilegeInnerObjects_SMC(Args _args)
    {
        SecurityTask            SecurityTask;
        SecurityTaskEntryPoint  SecurityTaskEntryPoint;
        SecurableObject         SecurableObject;

        ;
        while select * from securityTask
            where securityTask.Type == SecurityTaskType::Privilege
                   && SecurityTask.AotName == 'MainAccountDetailsMaintain'
        {


            setPrefix(strFmt('Privilege Name: %1  Privilege  RecId %2',SecurityTask.AotName,SecurityTask.RecId));
            while select * from SecurityTaskEntryPoint
            join SecurableObject
                where SecurableObject.RecId == SecurityTaskEntryPoint.EntryPoint
                && SecurityTaskEntryPoint.SecurityTask == SecurityTask.RecId
            {
                info(strFmt('Object Type: %1 ; Object Name %2 : Permission %3  RecId: %4',SecurableObject.Type,SecurableObject.Name,SecurityTaskEntryPoint.PermissionGroup,SecurityTaskEntryPoint.RecId));
            }
        }
    }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • CPU Rings, Privilege, and Protection 原文地址:http://duartes....
    houchen阅读 2,200评论 0 1
  • 让每一个与你接触的人感受到他们是卓越的甚至比你还优秀,你就离成功不远了! 20161115 09:01 灵感来自《...
    萌少MZ阅读 593评论 0 0
  • 今天实在太困了,就先不写了,昨晚一夜没睡,身体也不舒服。晚安好梦
    Fine婧婧阅读 123评论 2 0
  • 1、与朋友 说到朋友,我们要在内心问自己一句什么是朋友,朋友是在你不开心或者无助的时候能陪你聊天,能宽慰你的人,虽...
    小石读史阅读 313评论 0 7
  • 我的天使, 你是如此的美丽, 好比黑夜中的一盏明灯, 照亮我的心灵。 我的天使, 你是如此的动人, 你的魅力就好比...
    帝师阅读 179评论 0 0