Axapta 如何启用安全日志AX2012(SecurityTasks到SecurityRoles)
我想记录Axapta 如何启用安全日志AX2012(SecurityTasks到SecurityRoles),axapta,x++,dynamics-ax-2012,Axapta,X++,Dynamics Ax 2012,我想记录SecurityRole-SecurityTask的变化,而且由于EeUserRoleChangeLog记录User-SecurityRole的变化(对于爱沙尼亚,但注释掉语言检测,它也完美地记录了我们在荷兰的变化)。我认为这个基础可以用来记录这些变化 因此,我首先创建了表: EeRoleTaskChangeLog包含以下字段: AddRemoveEnumType:AddRemove ChangedByEDT:UserID SecurityRoleEDT:RefRecID Securit
SecurityRole
-SecurityTask
的变化,而且由于EeUserRoleChangeLog
记录User
-SecurityRole
的变化(对于爱沙尼亚,但注释掉语言检测,它也完美地记录了我们在荷兰的变化)。我认为这个基础可以用来记录这些变化
因此,我首先创建了表:
EeRoleTaskChangeLog
包含以下字段:
AddRemove
EnumType:AddRemove
ChangedBy
EDT:UserID
SecurityRole
EDT:RefRecID
SecurityTask
EDT:RefRecId
然后我注意到,在类SysSecRole
中,用户角色更改日志记录在方法removeFromSelectedUser
中触发。因此,每当有人从AOT或前端更改某些内容时,所有这些更改都会记录在EeUserRoleChangeLog
中
因此,我使用从SelectedRole中移除的方法扩展了SysSecTask
:
public void removeFromSelectedRole()
{
RefRecId SecurityRole;
SysSecTreeTasks taskTree;
SecurityRoleTaskGrant SecurityRoleTaskGrant;
taskTree = tree as SysSecTreeTasks;
securityRole = taskTree.getSecurityRole();
ttsbegin;
EePersonalDataAccessLogging::logRoleTaskChange(recId, 0, securityRole, AddRemove::Remove);
delete_from securityRoleTaskGrant where securityRoleTaskGrant.SecurityRole == securityRole && securityRoleTaskGrant.SecurityTask == recId;
ttscommit;
if (treeControl)
{
tree.deleteTreeItem(treeControl, idx);
}
}
然而,它不知何故无法识别触发器,因此无法填充我的表。
我希望在SecuryRoleTaskGrant
systemtable中添加一个delete/insert触发器,但这是完全关闭的,因此我不知道如何或在何处触发此方法
因此,我认为,作为一种“半工作”方法,让我们只记录前端所做的更改,因为这已经解决了常规工人的问题。因此,我决定在表单中找到一个类似的触发器,并使用方法assignRolesToSelectedUser
找到表单SysSecUserAddRoles
。此方法具有以下触发器:
if (added)
{
EePersonalDataAccessLogging::logUserRoleChange(secRole.RecId,0, userId, AddRemove::Add);
}
我决定将此触发器添加到允许工作人员更改任务角色的表单中:SysSecRoleAddTasks
methodaddTasksFromRole
,但不知何故,这似乎也无法解决问题。它没有填满桌子。我使用以下代码,前端更改仍然没有记录在我创建的EeRoleTaskChangeLog
表中
public int addTasksFromRole(SecurityRole _role, boolean _recursive = false)
{
SecurityRole childRole;
SecuritySubRole subRole;
SecurityTask task;
SecurityRoleTaskGrant srtGrant;
int nAdded = 0;
RefRecId securityRole;
boolean added;
if (_role.RecId == targetRoleId)
{
return 0;
}
startLengthyOperation();
while select task
join SecurityRole, SecurityTask from srtGrant
where srtGrant.SecurityRole == _role.RecId
&& srtGrant.SecurityTask == task.RecId
{
nAdded += this.addTask(task);
}
if (_recursive)
{
while select childRole
where childRole.RecId != targetRoleId
join SecurityRole, SecuritySubRole from subRole
where subRole.SecuritySubRole == childRole.RecId
&& subRole.SecurityRole == _role.RecId
{
this.addTasksFromRole(childRole, true);
}
}
endLengthyOperation();
if (added) //Added
{
EePersonalDataAccessLogging::logRoleTaskChange(securityTask.RecId,0, securityRole, AddRemove::Add);
}
return nAdded;
}
为什么这不会触发日志记录?
我需要提供更多的信息吗?
SysSecRoleAddTasks
表单也有addTask
方法,我在这里也尝试过,但这不会再次触发要填充的日志表
public int addTask(SecurityTask _task, boolean _trialAdd = false)
{
SecurityRoleTaskGrant srtGrant;
int nAdded = 0;
boolean added; //Added
RefRecId securityRole; //Added
select targetRole
where targetRole.RecId == targetRoleId; // make sure in sync
select forupdate srtGrant
where srtGrant.SecurityTask == _task.RecId
&& srtGrant.SecurityRole == targetRoleId;
if (!srtGrant)
{
if (!_trialAdd)
{
ttsbegin;
srtGrant.SecurityTask = _task.RecId;
srtGrant.SecurityRole = targetRoleId;
srtGrant.insert();
nAdded++;
myObjects.insert(_task.RecId, true);
if (added) //Added
{
EePersonalDataAccessLogging::logRoleTaskChange(securityTask.RecId,0, securityRole, AddRemove::Add);
}
ttscommit;
}
else if (targetRoleId != 0)
{
nAdded++;
}
//info('Added task "' + _task.Name + '" (' + int2str(appl.ttsLevel()) + ')');
}
/*
else
{
info('Not adding task "' + _task.Name + '"');
} */
return nAdded;
}
有什么建议吗?这个问题需要大量我认为需要解决的实际调试,不幸的是,我不确定有多少海报会这样做。您是否尝试过仅使用系统的数据库日志
SecurityRole
和SecurityTask
是系统表,存储在\system Documentation\tables\SecurityRole
下,因此我不知道在DB日志向导中的何处可以找到它们,但我编写了一个手动作业,我认为应该可以工作
我只使用UserInfo
对它进行了测试,这是另一个系统表,它似乎正确地记录了更改
static void AddTablesToDBLog(Args _args)
{
void logTable(TableId _tableId, DatabaseLogType _logType)
{
DatabaseLog dblog;
dblog.logTable = _tableId;
dblog.logField = 0;
dblog.logType = _logType;
dblog.insert();
}
ttsBegin;
logTable(tableNum(SecurityRole), DatabaseLogType::Insert);
logTable(tableNum(SecurityRole), DatabaseLogType::Update);
logTable(tableNum(SecurityRole), DatabaseLogType::Delete);
logTable(tableNum(SecurityTask), DatabaseLogType::Insert);
logTable(tableNum(SecurityTask), DatabaseLogType::Update);
logTable(tableNum(SecurityTask), DatabaseLogType::Delete);
ttsCommit;
SysFlushDatabaseLogSetup::main();
new MenuFunction(menuitemDisplayStr(SysDatabaseLogSetup), MenuItemType::Display).run(null);
info("Done");
}
这个问题需要大量我认为可以解决的实际调试,我不确定很多海报会不幸地做到这一点。您是否尝试过仅使用系统的数据库日志
SecurityRole
和SecurityTask
是系统表,存储在\system Documentation\tables\SecurityRole
下,因此我不知道在DB日志向导中的何处可以找到它们,但我编写了一个手动作业,我认为应该可以工作
我只使用UserInfo
对它进行了测试,这是另一个系统表,它似乎正确地记录了更改
static void AddTablesToDBLog(Args _args)
{
void logTable(TableId _tableId, DatabaseLogType _logType)
{
DatabaseLog dblog;
dblog.logTable = _tableId;
dblog.logField = 0;
dblog.logType = _logType;
dblog.insert();
}
ttsBegin;
logTable(tableNum(SecurityRole), DatabaseLogType::Insert);
logTable(tableNum(SecurityRole), DatabaseLogType::Update);
logTable(tableNum(SecurityRole), DatabaseLogType::Delete);
logTable(tableNum(SecurityTask), DatabaseLogType::Insert);
logTable(tableNum(SecurityTask), DatabaseLogType::Update);
logTable(tableNum(SecurityTask), DatabaseLogType::Delete);
ttsCommit;
SysFlushDatabaseLogSetup::main();
new MenuFunction(menuitemDisplayStr(SysDatabaseLogSetup), MenuItemType::Display).run(null);
info("Done");
}
这看起来像是解决方案,但在尝试之后,我注意到数据库日志没有跟踪这些表中所做的任何更改。它确实会在前端数据库日志查询中显示表,但不会向日志表中添加任何行。我确实添加了第三个表,但我认为这不是问题所在。我尝试向前端和AOT中的角色添加/删除/编辑现有任务和新任务,但没有跟踪任何更改。我添加的表是SecurityRoleTaskGrant。奇怪的是,它只记录角色中任务的删除操作(因此SecurityRoleTaskGrant记录1种类型的操作),而不记录添加的任务。对于这两个操作,SecurityRole和SecurityTask都不会被记录。是否要记录
SecurityUserRole
?这是接收从用户添加/删除的角色的表。这已在单独的表EEUserRoleChangeLog(因此不在DatabaseLog systemtable)中从框中注销。我的意思是改变角色的内容。因此,从角色中删除或添加任务。此数据保存在SecurityRoleTaskGrant.systemtable中。这是一个需要日志记录的问题,因为您可以给某人一个简单的角色,并在没有任何人知道的情况下向该简单角色添加所有安全权限……这看起来像是解决方案,但在尝试之后,我注意到数据库日志不会跟踪这些表中所做的任何更改。它确实会在前端数据库日志查询中显示表,但不会向日志表中添加任何行。我确实添加了第三个表,但我认为这不是问题所在。我尝试向前端和AOT中的角色添加/删除/编辑现有任务和新任务,但没有跟踪任何更改。我添加的表是SecurityRoleTaskGrant。奇怪的是,它只记录角色中任务的删除操作(因此SecurityRoleTaskGrant记录1种类型的操作),而不记录添加的任务。对于这两个操作,SecurityRole和SecurityTask都不会被记录。是否要记录SecurityUserRole
?这是接收从用户添加/删除的角色的表。这已在单独的表EEUserRoleChangeLog(因此不在DatabaseLog systemtable)中从框中注销。我的意思是改变角色的内容。因此,从角色中删除或添加任务。此数据保存在SecurityRoleTaskGrant.systemtable中。这是一个需要记录的,