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

获取一个用户的角色和duty

static void lyc_getPrivilegeSummary_SMC(Args _args)
{
    //
    SecurityRole                securityRole;
    SecurityUserRole            securityUserRole;
    SecurityRoleTaskGrant       securityRoleTaskGrant;
    SecurityTask                securityTask;
    UserInfo                    tblUserInfo;
    //
    
    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));
            }
        }
    }

你可能感兴趣的:(Get AX User-Role-Privilege-Entry point in X++)