Test or debug with specific user privileges in AX 2012

Test or debug with specific user privileges in AX 2012

Tutorial
Published on
May 27, 2015

Developers as default have a system administrator privileges so they can access all system functionality without any restrictions.

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.

Share it
New course!

Programming in Dynamics 365 for Operations

19-23 June 2017
Wroclaw, Poland
In-depth Dynamics 365 for Operations training course is now available in Poland!
Read more →
Written by
Wlodzimierz Wardega