Security Jobs related to Dynamics AX 2012 Role Based Security

While working on security setup for one of my client, I need to do some investigations related to security objects. Resulted I have created few jobs that help me in my work. I am sharing here; it may help others also.

Finding all the Privilege related to specific menu items

static void findAllThePrivillageWithSpecificMenuItem(Args _args)
{
SecurityTask securityTask;
SecuritySubTask securitySubTask;
SecurityTaskEntryPoint SecurityTaskEntryPoint;
SecurableObject SecurableObject;

while select * from SecurityTaskEntryPoint
join SecurableObject
where SecurableObject.RecId == SecurityTaskEntryPoint.EntryPoint
&& SecurableObject.Name == menuitemdisplayStr(ProjGrant)
{

// 1. How to the find record ID of the privilege
while select * from securityTask
where securityTask.RecId == SecurityTaskEntryPoint.SecurityTask
{
info(strFmt(“%1,%2,%3,%4”, securityTask.AOTNAME, securityTask.Name, securityTask.Type, SecurityTaskEntryPoint.PermissionGroup));
}
}
}

Finding all the Duties related to specific Privilege

static void findAllTheDutiesWithSpecificPrivilage(Args _args)
{
SecurityTask securityTask;
SecuritySubTask securitySubTask;

// privilage name
#define.SecurityTask(“ProjGrantMaintain”)

// 1. How to the find record ID of the privilege
select firstOnly RecId from securityTask
where securityTask.AotName == #SecurityTask
&& securityTask.Type == SecurityTaskType::Privilege;

// 2. How to the find all the duties containing the specified privilege
while select SecurityTask from securitySubTask
where securitySubTask.SecuritySubTask == securityTask.RecId
{
select firstOnly * from securityTask
where securityTask.RecId == securitySubTask.SecurityTask;

info(strFmt(“%1,%2,%3”, securityTask.AOTNAME, securityTask.Name, securityTask.Type));
}
}

%d bloggers like this: