Test or debug with specific user privileges in AX 2012

Sometimes there is a need for developers to test or debug how their solution behave with specific user privileges. Starting from Microsoft Dynamics AX 2012 there is an easy method to do it. To test or debug solution with specific privileges we need:
Step 1
Set up proper privileges on your user account.
Step 2
Switch off system administrator privileges by calling SecurityUtil::sysAdminMode(false);
We need to create and run a job like below:
static void switchAdminMode(Args _args)
{
SecurityUtil::sysAdminMode(false);
}
To go back to system administrator privileges we need to call SecurityUtil::sysAdminMode(true) or just restart Dynamics AX client.
See more

AGA pomaga – poznaj inteligentnego asystenta do przetwarzania zapytań ofertowych: ANEGIS Generative Assistant

Jak z pomocą narzędzi Power Platform, Microsoft Fabric i AI zrealizować plan na cyfrową transformację? ANEGIS Power Center

Obowiązkowy KSeF startuje za 4 miesiące! Umów się na bezpłatne konsultacje i przygotuj swój system na zmiany
Looking for a Microsoft partner? Let's talk about your project
Work with a team that has delivered implementations and projects for dozens of companies. Schedule an introductory call and see:
How to tailor Dynamics 365 to your company's processes, rather than the other way around
Which areas are worth automating to save time and reduce costs
Here is the step-by-step implementation process with Anegis: from analysis to post-launch support

