Below method will help to check security Privileges assigned for that user.
public static boolean hasUserSecurityPrivilege(SecurityPrivilegeName _securityPrivilege, UserId _userId = curUserId())
{
SecurityRolePrivilegeExplodedGraph securityRolePrivilegeExplodedGraph;
SecurityUserRole securityUserRole;
SecurityPrivilege securityPrivilege;
select firstonly securityPrivilege
where securityPrivilege.Identifier == _securityPrivilege
exists join securityRolePrivilegeExplodedGraph
where securityRolePrivilegeExplodedGraph.SecurityPrivilege == securityPrivilege.RecId
exists join securityUserRole
where securityUserRole.SecurityRole == securityRolePrivilegeExplodedGraph.SecurityRole
&& securityUserRole.User == _userId
&& securityUserRole.AssignmentStatus == RoleAssignmentStatus::Enabled
&& (securityUserRole.ValidFrom < DateTimeUtil::utcNow() || securityUserRole.ValidFrom == utcDateTimeNull())
&& (securityUserRole.ValidTo > DateTimeUtil::utcNow() || securityUserRole.ValidTo == utcDateTimeNull());
return securityPrivilege.RecId != 0;
}
Orelse you can use below method also with dummy control in form
Logic to implement user has specific privilege through code:
Created one dummy form control with visibility false and need permission manual and created privilege using below logic we can verify the access.
SecurityRights securityRights = SecurityRights::construct();
maxAccess = securityRights.formControlAccessRight(formStr(SalesTable), formControlStr(SalesTable, QTQSalesStatus));
=============
verify user has specific role assigned or not.
if (xUserInfo::checkUserRole(roleStr(InventMaterialsManager))
|| xUserInfo::checkUserRole(roleStr(InventQualityControlManager))
|| xUserInfo::checkUserRole(roleStr(WMSWarehouseManager))
|| Global::isSystemAdministrator())
No comments:
Post a Comment