Из под компании DAT:
X++:
SecurityRole role;
SecurityUserRole userRole;
boolean added;
UserInfo userInfo;
container username = ['Mr.1', 'Mrs.1'];
Int I;
UserId parmName;
;
select role
where role.Name == 'Системный администратор';
If(role.RecId)
for( I = 1; I<=conLen(username); I++ )
{
parmName = conPeek(username,I);
If( parmName )
{
Select userInfo where userInfo.id == parmName;
If( userInfo.RecId )
{
select * from userRole
where userRole.SecurityRole == role.RecId &&
userRole.User == userInfo.id;
if (!userRole || (userRole.AssignmentStatus != RoleAssignmentStatus::Enabled))
{
userRole.User = userInfo.id;
userRole.SecurityRole = role.RecId;
userRole.AssignmentMode = RoleAssignmentMode::Manual;
userRole.AssignmentStatus = RoleAssignmentStatus::Enabled;
SecuritySegregationOfDuties::assignUserToRole(userRole, null);
}
}
}
}