Getting Access denied on class message

As the title says it, you're receiving an Access denied: [ClassName] when you try to run some process in AX. In my case the scenario context was testing a custom AX Security Role.

The security role had only a few entry points, and even checking with the AX Security Tool the necessary permissions of the entire process callstack, the menu items that were leading to the calls of the class were added as Entry Points, so for sure that was not it (of course the class was called sometime along the path of the process by using a new MenuFunction). After debugging for a while, I realized the obvious: the class was a SysOperationServiceController class and it was failing right at the point of trying to create the DataContract which is done by reflection on the service operation method; that will call, among others, the checkAccess method.

Success. What you have to do in order to fix the issue is to add to the Ax Security Role (or to a Privilege) in the Server Methods node the service operation method (you will notice that you have to key in your method's name and not press Enter but instead navigate down with the arrow, as the IDE will not validate it as a proper method name, still it will work).

The code that throws the error, in the SysOperationController class:

/// <summary>
///    Microsoft internal use only.
/// </summary>
public void checkAccess()
{
    throw error(strFmt("@SYS316844", classId2Name(classIdGet(this))));
}

4 comments:

  1. Hi,

    Even I had faced the same issue yesterday and the solution for the same is add all the methods that has an datacontractattribute as a argument in Service operation class to server methods in the privilege.

    Though the method might drop from the lookup, you can manually type the method name and give the Invoke access for the method.

    Regards,
    Pradeep

    ReplyDelete
  2. We had a simular problem: "access denied to method run in class LedgerTransferOpening"
    I have solved this by adding the ledgertransferopening:run method to the server methods of the roles of this particular user.
    What i would like to know is what the cause be of this kind of error messages. Nothing has changed to the roles and privileges of this user.

    ReplyDelete
  3. We had a simular issue: "access denied to method run in class LedgerTransferOpening".
    I have solved this by adding the ledgertransferopening:run to the server methods of roles. What might have caused this. As far as i know nothing has changed to the roles and privileges of particular user.

    ReplyDelete
  4. Hi Carl,

    As you are also wondering, what could have caused this. If the supposition is right that nothing changed in the setup of the security, then maybe the way the service was being used changed? Was this a live instance with few to none changes done on it? Or a test machine?

    ReplyDelete