March 26, 2015

Temporarily toggle admin mode in Dynamics AX 2012

The information in this post is based on Dynamics AX 2012 R3. It may or may not be valid for other versions.

Sometimes – especially when testing security elements – it is convenient to be able to temporarily disable your own administrator privileges. Of course, you could just remove yourself from the Administrators group, but that holds a very real risk of you locking yourself out of the system and needing assistance to get back in.

If you just need to be without administrative privileges temporarily in a single session, you can execute the below job instead. It simply toggles back and forth between admin mode, so just run it again to regain your administrator awesomeness.

static void ToggleAdminMode(Args _args)
{
    ;
    
    SecurityUtil::sysAdminMode(!SecurityUtil::sysAdminMode());
    info(strFmt('Admin mode: %1', SecurityUtil::sysAdminMode()));
}

Toggling administrative privileges this way also has the advantage that if you mess up and lose access to something you need, you can just restart the Dynamics AX client, at which point your privileges will be restored to normal.

facebooktwittergoogle_plusredditpinterestlinkedintumblrmail

Posted by Mikkel

I am a senior Dynamics AX developer by day and an open source/free-as-in-speech software enthusiast by night. In addition to many technology-related topics, my main interests are physical exercise, healthy cooking, heavy metal music and spending quality time with my girlfriend.

View more posts from this author