Assalam u alaikum Ahmad,
Thank you for your post. It was extremely helpful. In my case, I was interested in the print management privileges of the current user. Hope others find the following code based on your code helpful.
List userRoles;
ListEnumerator userRolesEnumerator;
SecurityRights securityRights;
SysUserManagement userManagement;
SecurityRole securityRole;
SecurityRoleAotName securityRoleAotName;
SecurityTask securityTask, securityTaskSub;
SecurityTaskExplodedGraph securityTaskExplodedGraph;
SecurityRoleAllTasksView securityRoleAllTasksView;
Set printMgmtPrivileges;
securityRights = SecurityRights::construct();
// User is an administrator. Do not filter. Return all results.
if (securityRights.isSystemAdministrator())
{
//return valueAllRows;
}
printMgmtPrivileges = new Set(Types::String);
userManagement = new SysUserManagement();
userRoles = userManagement.getRolesForUser(curUserId());
userRolesEnumerator = userRoles.getEnumerator();
// Generate a set of all print management privileges to which the current user has access.
while (userRolesEnumerator.moveNext())
{
securityRoleAotName = userRolesEnumerator.current();
while select RecId from securityRole
where securityRole.AotName == securityRoleAotName
join RecId from securityRoleAllTasksView
where securityRoleAllTasksView.SecurityRole == securityRole.RecId
join RecId from securityTask
where securityTask.RecId == securityRoleAllTasksView.SecurityTask
&& securityTask.AotName like 'PrintMgmt*'
join RecId from securityTaskExplodedGraph
where securityTaskExplodedGraph.SecurityTask == securityTask.RecId
join RecId, AotName from securityTaskSub
where securityTaskSub.RecId == securityTaskExplodedGraph.SecuritySubTask
&& securityTaskSub.Type == SecurityTaskType::Privilege
{
printMgmtPrivileges.add(securityTaskSub.AotName);
}
}
- Mohammed Pasha