AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 20.07.2012, 00:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
ax-erp: Adding a role to all or multiple users using X++ Code [Dynamics AX 2012]
Источник: http://microsoft-dynamics-ax-erp.blo...ple-users.html
==============


Friends,
In AX 2012, we can add a role to all the users by running the automated role assignment job based on the rule which we define in the “Assign users to Role” form.
Navigation : System administration >> Setup >> Security >> Assign users to roles
And the code behind this is :
SysSecurityDynamicRoleAssignment::synchronize(args.record().RecId); // selected Role (this is Security Role table buffer) in the form
I tried to run the above code independently by passing the “Budget clerk” Security Role but did not work due to obvious reasons as it needed a rule assignment table buffer.
The equivalent code to assign a role to all users is below.
This doesn’t need to add any rules like what we do in the form.This is just an experiment to handle the roles through code and request to test the code before using it.
staticvoid SR_AssignRoleToAllUsers(Args _args)
{
SecurityRole role;
SecurityUserRole userRole;
boolean added;
UserInfo userInfo;
;


select role where role.Name == ‘Budget clerk’;
whileselect userInfo
{
select * from userRole
where userRole.SecurityRole == role.RecId &&
userRole.User == userInfo.id;


if (!userRole || (userRole.AssignmentStatus != RoleAssignmentStatus::Enabled))
{
info(strFmt(‘Role %1 added to the user %2 successfully.’, role.Name, userInfo.id));


userRole.User = userInfo.id;
userRole.SecurityRole = role.RecId;
userRole.AssignmentMode = RoleAssignmentMode::Manual;
userRole.AssignmentStatus = RoleAssignmentStatus::Enabled;
SecuritySegregationOfDuties::assignUserToRole(userRole, null);
}
else
{
warning(strFmt(‘skipping – Role %1 to the user %2.’, role.Name, userInfo.id));
}
}
}


Happy dax6ng,
Sreenath Reddy



Источник: http://microsoft-dynamics-ax-erp.blo...ple-users.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
dax-lessons: Adding a role to all or multiple users using X++ Code [Dynamics AX 2012] Blog bot DAX Blogs 0 27.04.2012 22:11
rumicrosofterp: Dynamics AX на Convergence 2012 Blog bot Microsoft и системы Microsoft Dynamics 0 13.01.2012 11:11
semanticax: Dynamics AX 2009 Installation - Application Blog bot DAX Blogs 0 22.12.2010 08:11
emeadaxsupport: List of fixes that improve performance of certain features in Dynamics AX 2009 Blog bot DAX Blogs 0 13.10.2009 19:06
axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series Blog bot DAX Blogs 0 06.08.2008 12:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 01:50.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.